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