mirror of
https://github.com/corda/corda.git
synced 2024-12-26 16:11:12 +00:00
Added missing RigourousMock assertions.
This commit is contained in:
parent
d984b4722e
commit
16ef2df1d5
@ -1,6 +1,7 @@
|
|||||||
package com.r3.corda.enterprise.perftestcordapp.contracts.asset
|
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.*
|
||||||
import com.r3.corda.enterprise.perftestcordapp.utils.sumCash
|
import com.r3.corda.enterprise.perftestcordapp.utils.sumCash
|
||||||
import com.r3.corda.enterprise.perftestcordapp.utils.sumCashBy
|
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.TransactionBuilder
|
||||||
import net.corda.core.transactions.WireTransaction
|
import net.corda.core.transactions.WireTransaction
|
||||||
import net.corda.core.utilities.OpaqueBytes
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
|
import net.corda.node.services.api.IdentityServiceInternal
|
||||||
import net.corda.node.services.vault.NodeVaultService
|
import net.corda.node.services.vault.NodeVaultService
|
||||||
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
||||||
import net.corda.testing.*
|
import net.corda.testing.*
|
||||||
@ -32,6 +34,7 @@ import net.corda.testing.node.makeTestIdentityService
|
|||||||
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 org.mockito.Mockito.doReturn
|
||||||
import java.security.KeyPair
|
import java.security.KeyPair
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
@ -844,8 +847,9 @@ class CashTests {
|
|||||||
// Double spend.
|
// Double spend.
|
||||||
@Test
|
@Test
|
||||||
fun chainCashDoubleSpendFailsWith() = withTestSerialization {
|
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<IdentityServiceInternal>().also {
|
||||||
|
doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY)
|
||||||
|
}, MEGA_CORP.name, MEGA_CORP_KEY)
|
||||||
ledger(mockService) {
|
ledger(mockService) {
|
||||||
unverifiedTransaction {
|
unverifiedTransaction {
|
||||||
attachment(Cash.PROGRAM_ID)
|
attachment(Cash.PROGRAM_ID)
|
||||||
|
@ -4,6 +4,8 @@ package com.r3.corda.enterprise.perftestcordapp.flows
|
|||||||
// from net.corda.node.messaging
|
// from net.corda.node.messaging
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.Suspendable
|
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.DOLLARS
|
||||||
import com.r3.corda.enterprise.perftestcordapp.`issued by`
|
import com.r3.corda.enterprise.perftestcordapp.`issued by`
|
||||||
import com.r3.corda.enterprise.perftestcordapp.contracts.CommercialPaper
|
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 bankNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
|
doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey)
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val notary = mockNet.defaultNotaryIdentity
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val cashIssuer = bank.ref(1)
|
val cashIssuer = bank.ref(1)
|
||||||
@ -162,6 +165,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
|
doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey)
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1)
|
val issuer = bank.ref(1)
|
||||||
val notary = mockNet.defaultNotaryIdentity
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
@ -227,6 +231,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val notary = mockNet.defaultNotaryIdentity
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
|
doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey)
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
|
|
||||||
@ -511,7 +516,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
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)
|
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
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<Currency>, val anonymous: Boolean)
|
data class TestTx(val notaryIdentity: Party, val price: Amount<Currency>, val anonymous: Boolean)
|
||||||
|
|
||||||
private fun LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.runWithError(
|
private fun LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.runWithError(
|
||||||
|
ledgerIdentityService: IdentityServiceInternal,
|
||||||
bobError: Boolean,
|
bobError: Boolean,
|
||||||
aliceError: Boolean,
|
aliceError: Boolean,
|
||||||
expectedMessageSubstring: String
|
expectedMessageSubstring: String
|
||||||
@ -595,6 +601,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
|
doReturn(null).whenever(ledgerIdentityService).partyFromKey(bank.owningKey)
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
|
|
||||||
val bobsBadCash = bobNode.database.transaction {
|
val bobsBadCash = bobNode.database.transaction {
|
||||||
|
Loading…
Reference in New Issue
Block a user