diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt index 0845271419..3d40f70dad 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt @@ -1,6 +1,7 @@ package com.r3.corda.enterprise.perftestcordapp.contracts.asset +import com.nhaarman.mockito_kotlin.whenever import com.r3.corda.enterprise.perftestcordapp.* import com.r3.corda.enterprise.perftestcordapp.utils.sumCash import com.r3.corda.enterprise.perftestcordapp.utils.sumCashBy @@ -21,6 +22,7 @@ import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.transactions.WireTransaction import net.corda.core.utilities.OpaqueBytes +import net.corda.node.services.api.IdentityServiceInternal import net.corda.node.services.vault.NodeVaultService import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.* @@ -32,6 +34,7 @@ import net.corda.testing.node.makeTestIdentityService import org.junit.After import org.junit.Before import org.junit.Test +import org.mockito.Mockito.doReturn import java.security.KeyPair import java.util.* import kotlin.test.* @@ -844,8 +847,9 @@ class CashTests { // Double spend. @Test fun chainCashDoubleSpendFailsWith() = withTestSerialization { - val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock(), MEGA_CORP.name, MEGA_CORP_KEY) - + val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock().also { + doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY) + }, MEGA_CORP.name, MEGA_CORP_KEY) ledger(mockService) { unverifiedTransaction { attachment(Cash.PROGRAM_ID) diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt index f7d74983c3..c5005a29b3 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt @@ -4,6 +4,8 @@ package com.r3.corda.enterprise.perftestcordapp.flows // from net.corda.node.messaging import co.paralleluniverse.fibers.Suspendable +import com.nhaarman.mockito_kotlin.doReturn +import com.nhaarman.mockito_kotlin.whenever import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` import com.r3.corda.enterprise.perftestcordapp.contracts.CommercialPaper @@ -110,6 +112,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bankNode = mockNet.createPartyNode(BOC_NAME) val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() + doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey) val bob = bobNode.info.singleIdentity() val notary = mockNet.defaultNotaryIdentity val cashIssuer = bank.ref(1) @@ -162,6 +165,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bankNode = mockNet.createPartyNode(BOC_NAME) val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() + doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey) val bob = bobNode.info.singleIdentity() val issuer = bank.ref(1) val notary = mockNet.defaultNotaryIdentity @@ -227,6 +231,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val notary = mockNet.defaultNotaryIdentity val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() + doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey) val bob = bobNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) @@ -511,7 +516,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { mockNet = MockNetwork(cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { - runWithError(true, false, "at least one cash input") + runWithError(ledgerIdentityService,true, false, "at least one cash input") } } @@ -520,7 +525,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { mockNet = MockNetwork(cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { - runWithError(false, true, "Issuances have a time-window") + runWithError(ledgerIdentityService,false, true, "Issuances have a time-window") } } @@ -582,6 +587,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { data class TestTx(val notaryIdentity: Party, val price: Amount, val anonymous: Boolean) private fun LedgerDSL.runWithError( + ledgerIdentityService: IdentityServiceInternal, bobError: Boolean, aliceError: Boolean, expectedMessageSubstring: String @@ -595,6 +601,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val alice = aliceNode.info.singleIdentity() val bob = bobNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() + doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey) val issuer = bank.ref(1, 2, 3) val bobsBadCash = bobNode.database.transaction {