Skip to content

Commit

Permalink
add sleep on restart lock test as token loading is now async
Browse files Browse the repository at this point in the history
  • Loading branch information
roastario committed Dec 7, 2021
1 parent 768a2b0 commit db195dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
corda_release_group = 'net.corda'
corda_release_version = '4.3'
tokens_release_group = "com.r3.corda.lib.tokens"
tokens_release_version = "1.2.4-SNAPSHOT"
tokens_release_version = "1.2.5-SNAPSHOT"
corda_gradle_plugins_version = '5.0.12'
kotlin_version = '1.2.71'
junit_version = '4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import freighter.machine.generateRandomString
import net.corda.core.contracts.Amount
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.getOrThrow
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
import utility.getOrThrow
import java.time.Duration
Expand All @@ -25,6 +26,10 @@ import java.util.stream.StreamSupport
import kotlin.concurrent.withLock
import kotlin.streams.toList

@Tag("LARGE_TEST")
annotation class LargeTest

@LargeTest
class HugeTokensLoadedOnRestartTest : DockerRemoteMachineBasedTest() {

val loadingThreads = 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ class TokenDriverTest {
listOf(50.USD issuedBy nodeParty heldBy nodeParty),
emptyList<Party>()
).returnValue.getOrThrow()
// Run select and lock tokens flow with 5 seconds sleep in it.
// Run select and lock tokens flow
node.rpc.startFlowDynamic(
SelectAndLockFlow::class.java,
50.GBP,
5.seconds
50.seconds
)
// Stop node
(node as OutOfProcess).process.destroyForcibly()
Expand All @@ -305,6 +305,8 @@ class TokenDriverTest {
// Restart the node
val restartedNode = startNode(providedName = DUMMY_BANK_A_NAME, customOverrides = mapOf("p2pAddress" to "localhost:30000")).getOrThrow()
// Try to spend same states, they should be locked after restart, so we expect insufficient not locked balance exception to be thrown.
Thread.sleep(15000) // because token loading is now async, we must wait a bit of time before we can attempt to select.

assertFailsWith<InsufficientNotLockedBalanceException> {
restartedNode.rpc.startFlowDynamic(
SelectAndLockFlow::class.java,
Expand Down

0 comments on commit db195dd

Please sign in to comment.