From d9a1e352cdfdc5a3064d6e1a5998e8b5eb6674cd Mon Sep 17 00:00:00 2001 From: Qian Hong Date: Thu, 23 Mar 2017 17:41:36 +1100 Subject: [PATCH] Bank of Corda demo: Fix broken RPC client test. --- .../corda/bank/BankOfCordaRPCClientTest.kt | 24 ++++++++----------- .../kotlin/net/corda/testing/CoreTestUtils.kt | 5 ++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt index 26a7cb7468..6bb0390eb2 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt @@ -10,7 +10,7 @@ import net.corda.node.driver.driver import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User -import net.corda.testing.BOC_PARTY_REF +import net.corda.testing.BIG_CORP_PARTY_REF import net.corda.testing.expect import net.corda.testing.expectEvents import net.corda.testing.sequence @@ -20,20 +20,21 @@ class BankOfCordaRPCClientTest { @Test fun `issuer flow via RPC`() { driver(dsl = { - val user = User("user1", "test", permissions = setOf(startFlowPermission())) + val bocManager = User("bocManager", "password1", permissions = setOf(startFlowPermission())) + val bigCorpCFO = User("bigCorpCFO", "password2", permissions = emptySet()) val (nodeBankOfCorda, nodeBigCorporation) = Futures.allAsList( - startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type)), listOf(user)), - startNode("BigCorporation", rpcUsers = listOf(user)) + startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type)), listOf(bocManager)), + startNode("BigCorporation", rpcUsers = listOf(bigCorpCFO)) ).getOrThrow() // Bank of Corda RPC Client val bocClient = nodeBankOfCorda.rpcClientToNode() - bocClient.start("user1", "test") + bocClient.start("bocManager", "password1") val bocProxy = bocClient.proxy() // Big Corporation RPC Client - val bigCorpClient = nodeBankOfCorda.rpcClientToNode() // TODO This test is broken as this should be nodeBigCorporation - bigCorpClient.start("user1", "test") + val bigCorpClient = nodeBigCorporation.rpcClientToNode() + bigCorpClient.start("bigCorpCFO", "password2") val bigCorpProxy = bigCorpClient.proxy() // Register for Bank of Corda Vault updates @@ -47,7 +48,7 @@ class BankOfCordaRPCClientTest { ::IssuanceRequester, 1000.DOLLARS, nodeBigCorporation.nodeInfo.legalIdentity, - BOC_PARTY_REF, + BIG_CORP_PARTY_REF, nodeBankOfCorda.nodeInfo.legalIdentity).returnValue.getOrThrow() // Check Bank of Corda Vault Updates @@ -69,15 +70,10 @@ class BankOfCordaRPCClientTest { // Check Big Corporation Vault Updates vaultUpdatesBigCorp.expectEvents { sequence( - // ISSUE + // MOVE expect { update -> require(update.consumed.isEmpty()) { update.consumed.size } require(update.produced.size == 1) { update.produced.size } - }, - // MOVE - expect { update -> - require(update.consumed.size == 1) { update.consumed.size } - require(update.produced.isEmpty()) { update.produced.size } } ) } diff --git a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt index e784558e36..a42634bf6c 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt @@ -85,6 +85,11 @@ val BOC_PUBKEY: CompositeKey get() = BOC_KEY.public.composite val BOC: Party get() = Party("BankOfCorda", BOC_PUBKEY) val BOC_PARTY_REF = BOC.ref(OpaqueBytes.of(1)).reference +val BIG_CORP_KEY: KeyPair by lazy { generateKeyPair() } +val BIG_CORP_PUBKEY: CompositeKey get() = BIG_CORP_KEY.public.composite +val BIG_CORP: Party get() = Party("BigCorporation", BIG_CORP_PUBKEY) +val BIG_CORP_PARTY_REF = BIG_CORP.ref(OpaqueBytes.of(1)).reference + val ALL_TEST_KEYS: List get() = listOf(MEGA_CORP_KEY, MINI_CORP_KEY, ALICE_KEY, BOB_KEY, DUMMY_NOTARY_KEY) val MOCK_IDENTITY_SERVICE: MockIdentityService get() = MockIdentityService(listOf(MEGA_CORP, MINI_CORP, DUMMY_NOTARY))