mirror of
https://github.com/corda/corda.git
synced 2025-04-07 11:27:01 +00:00
Read the balances off of the vault update.
This commit is contained in:
parent
d5ba8a2382
commit
9ba02b170b
@ -18,6 +18,7 @@ import net.corda.testing.node.MockNetwork
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class FxTransactionBuildTutorialTest {
|
||||
@ -68,13 +69,13 @@ class FxTransactionBuildTutorialTest {
|
||||
printBalances()
|
||||
|
||||
// Setup some futures on the vaults to await the arrival of the exchanged funds at both nodes
|
||||
val done2 = SettableFuture.create<Unit>()
|
||||
val done3 = SettableFuture.create<Unit>()
|
||||
val done2 = SettableFuture.create<Map<Currency, Amount<Currency>>>()
|
||||
val done3 = SettableFuture.create<Map<Currency, Amount<Currency>>>()
|
||||
val subs2 = nodeA.services.vaultService.updates.subscribe {
|
||||
done2.set(Unit)
|
||||
done2.set(nodeA.services.vaultService.cashBalances)
|
||||
}
|
||||
val subs3 = nodeB.services.vaultService.updates.subscribe {
|
||||
done3.set(Unit)
|
||||
done3.set(nodeB.services.vaultService.cashBalances)
|
||||
}
|
||||
// Now run the actual Fx exchange
|
||||
val doIt = nodeA.services.startFlow(ForeignExchangeFlow("trade1",
|
||||
@ -84,17 +85,11 @@ class FxTransactionBuildTutorialTest {
|
||||
nodeB.info.legalIdentity))
|
||||
// wait for the flow to finish and the vault updates to be done
|
||||
doIt.resultFuture.getOrThrow()
|
||||
done2.get()
|
||||
done3.get()
|
||||
// Get the balances when the vault updates
|
||||
val balancesA = done2.get()
|
||||
val balancesB = done3.get()
|
||||
subs2.unsubscribe()
|
||||
subs3.unsubscribe()
|
||||
// Check the final balances
|
||||
val balancesA = databaseTransaction(nodeA.database) {
|
||||
nodeA.services.vaultService.cashBalances
|
||||
}
|
||||
val balancesB = databaseTransaction(nodeB.database) {
|
||||
nodeB.services.vaultService.cashBalances
|
||||
}
|
||||
println("BalanceA\n" + balancesA)
|
||||
println("BalanceB\n" + balancesB)
|
||||
// Verify the transfers occurred as expected
|
||||
|
Loading…
x
Reference in New Issue
Block a user