mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
CORDA-2333: Dependency update pass for tests and demos (#5211)
This commit is contained in:
@ -2,7 +2,7 @@ package net.corda.core.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import com.natpryce.hamkrest.*
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import net.corda.core.contracts.Attachment
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.flows.mixins.WithMockNet
|
||||
@ -48,18 +48,18 @@ class AttachmentTests : WithMockNet {
|
||||
val id = aliceNode.importAttachment(fakeAttachment("file1.txt", "Some useful content"))
|
||||
|
||||
// Get node one to run a flow to fetch it and insert it.
|
||||
assert.that(
|
||||
assertThat(
|
||||
bobNode.startAttachmentFlow(id, alice),
|
||||
willReturn(noAttachments()))
|
||||
|
||||
// Verify it was inserted into node one's store.
|
||||
val attachment = bobNode.getAttachmentWithId(id)
|
||||
assert.that(attachment, hashesTo(id))
|
||||
assertThat(attachment, hashesTo(id))
|
||||
|
||||
// Shut down node zero and ensure node one can still resolve the attachment.
|
||||
aliceNode.dispose()
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
bobNode.startAttachmentFlow(id, alice),
|
||||
willReturn(soleAttachment(attachment)))
|
||||
}
|
||||
@ -69,7 +69,7 @@ class AttachmentTests : WithMockNet {
|
||||
val hash: SecureHash = SecureHash.randomSHA256()
|
||||
|
||||
// Get node one to fetch a non-existent attachment.
|
||||
assert.that(
|
||||
assertThat(
|
||||
bobNode.startAttachmentFlow(hash, alice),
|
||||
willThrow(withRequestedHash(hash)))
|
||||
}
|
||||
@ -97,7 +97,7 @@ class AttachmentTests : WithMockNet {
|
||||
badAliceNode.updateAttachment(corruptAttachment)
|
||||
|
||||
// Get n1 to fetch the attachment. Should receive corrupted bytes.
|
||||
assert.that(
|
||||
assertThat(
|
||||
bobNode.startAttachmentFlow(id, badAlice),
|
||||
willThrow<FetchDataFlow.DownloadedVsRequestedDataMismatch>()
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.core.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import net.corda.core.contracts.Command
|
||||
import net.corda.core.contracts.StateAndContract
|
||||
import net.corda.core.contracts.requireThat
|
||||
@ -54,7 +54,7 @@ class CollectSignaturesFlowTests : WithContracts {
|
||||
val bConfidentialIdentity = bobNode.createConfidentialIdentity(bob)
|
||||
aliceNode.verifyAndRegister(bConfidentialIdentity)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.startTestFlow(alice, bConfidentialIdentity.party, charlie),
|
||||
willReturn(requiredSignatures(3))
|
||||
)
|
||||
@ -64,7 +64,7 @@ class CollectSignaturesFlowTests : WithContracts {
|
||||
fun `no need to collect any signatures`() {
|
||||
val ptx = aliceNode.signDummyContract(alice.ref(1))
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.collectSignatures(ptx),
|
||||
willReturn(requiredSignatures(1))
|
||||
)
|
||||
@ -74,7 +74,7 @@ class CollectSignaturesFlowTests : WithContracts {
|
||||
fun `fails when not signed by initiator`() {
|
||||
val ptx = miniCorpServices.signDummyContract(alice.ref(1))
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.collectSignatures(ptx),
|
||||
willThrow(errorMessage("The Initiator of CollectSignaturesFlow must have signed the transaction.")))
|
||||
}
|
||||
@ -88,7 +88,7 @@ class CollectSignaturesFlowTests : WithContracts {
|
||||
bob.ref(3))
|
||||
val signedByBoth = bobNode.addSignatureTo(signedByA)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.collectSignatures(signedByBoth),
|
||||
willReturn(requiredSignatures(2))
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ package net.corda.core.flows
|
||||
|
||||
import com.natpryce.hamkrest.and
|
||||
import com.natpryce.hamkrest.anything
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import com.natpryce.hamkrest.has
|
||||
import com.natpryce.hamkrest.isA
|
||||
import net.corda.core.CordaRuntimeException
|
||||
@ -52,30 +52,30 @@ class ContractUpgradeFlowRPCTest : WithContracts, WithFinality {
|
||||
// Create, sign and finalise dummy contract.
|
||||
val signedByA = aliceNode.signDummyContract(alice.ref(1), 0, bob.ref(1))
|
||||
val stx = bobNode.addSignatureTo(signedByA)
|
||||
assert.that(rpcA.finalise(stx, bob), willReturn())
|
||||
assertThat(rpcA.finalise(stx, bob), willReturn())
|
||||
|
||||
val atx = aliceNode.getValidatedTransaction(stx)
|
||||
val btx = bobNode.getValidatedTransaction(stx)
|
||||
|
||||
// Cannot upgrade contract without prior authorisation from counterparty
|
||||
assert.that(
|
||||
assertThat(
|
||||
rpcA.initiateDummyContractUpgrade(atx),
|
||||
willThrow<CordaRuntimeException>())
|
||||
|
||||
// Party B authorises the contract state upgrade, and immediately deauthorises the same.
|
||||
assert.that(rpcB.authoriseDummyContractUpgrade(btx), willReturn())
|
||||
assert.that(rpcB.deauthoriseContractUpgrade(btx), willReturn())
|
||||
assertThat(rpcB.authoriseDummyContractUpgrade(btx), willReturn())
|
||||
assertThat(rpcB.deauthoriseContractUpgrade(btx), willReturn())
|
||||
|
||||
// Cannot upgrade contract if counterparty has deauthorised a previously-given authority
|
||||
assert.that(
|
||||
assertThat(
|
||||
rpcA.initiateDummyContractUpgrade(atx),
|
||||
willThrow<CordaRuntimeException>())
|
||||
|
||||
// Party B authorise the contract state upgrade.
|
||||
assert.that(rpcB.authoriseDummyContractUpgrade(btx), willReturn())
|
||||
assertThat(rpcB.authoriseDummyContractUpgrade(btx), willReturn())
|
||||
|
||||
// Party A initiates contract upgrade flow, expected to succeed this time.
|
||||
assert.that(
|
||||
assertThat(
|
||||
rpcA.initiateDummyContractUpgrade(atx),
|
||||
willReturn(
|
||||
aliceNode.hasDummyContractUpgradeTransaction()
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.core.flows
|
||||
|
||||
import com.natpryce.hamkrest.*
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.core.flows.mixins.WithContracts
|
||||
import net.corda.core.flows.mixins.WithFinality
|
||||
@ -59,24 +59,24 @@ class ContractUpgradeFlowTest : WithContracts, WithFinality {
|
||||
val bobTx = bobNode.getValidatedTransaction(stx)
|
||||
|
||||
// The request is expected to be rejected because party B hasn't authorised the upgrade yet.
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.initiateContractUpgrade(aliceTx, DummyContractV2::class),
|
||||
willThrow<UnexpectedFlowEndException>())
|
||||
|
||||
// Party B authorises the contract state upgrade, and immediately de-authorises the same.
|
||||
assert.that(bobNode.authoriseContractUpgrade(bobTx, DummyContractV2::class), willReturn())
|
||||
assert.that(bobNode.deauthoriseContractUpgrade(bobTx), willReturn())
|
||||
assertThat(bobNode.authoriseContractUpgrade(bobTx, DummyContractV2::class), willReturn())
|
||||
assertThat(bobNode.deauthoriseContractUpgrade(bobTx), willReturn())
|
||||
|
||||
// The request is expected to be rejected because party B has subsequently de-authorised a previously authorised upgrade.
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.initiateContractUpgrade(aliceTx, DummyContractV2::class),
|
||||
willThrow<UnexpectedFlowEndException>())
|
||||
|
||||
// Party B authorises the contract state upgrade.
|
||||
assert.that(bobNode.authoriseContractUpgrade(bobTx, DummyContractV2::class), willReturn())
|
||||
assertThat(bobNode.authoriseContractUpgrade(bobTx, DummyContractV2::class), willReturn())
|
||||
|
||||
// Party A initiates contract upgrade flow, expected to succeed this time.
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.initiateContractUpgrade(aliceTx, DummyContractV2::class),
|
||||
willReturn(
|
||||
aliceNode.hasContractUpgradeTransaction<DummyContract.State, DummyContractV2.State>()
|
||||
@ -86,10 +86,10 @@ class ContractUpgradeFlowTest : WithContracts, WithFinality {
|
||||
|
||||
// We now test that the upgraded state can be upgraded further, to V3.
|
||||
// Party B authorises the contract state upgrade.
|
||||
assert.that(bobNode.authoriseContractUpgrade(upgradedState, DummyContractV3::class), willReturn())
|
||||
assertThat(bobNode.authoriseContractUpgrade(upgradedState, DummyContractV3::class), willReturn())
|
||||
|
||||
// Party A initiates contract upgrade flow which is expected to succeed.
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.initiateContractUpgrade(upgradedState, DummyContractV3::class),
|
||||
willReturn(
|
||||
aliceNode.hasContractUpgradeTransaction<DummyContractV2.State, DummyContractV3.State>()
|
||||
@ -125,14 +125,14 @@ class ContractUpgradeFlowTest : WithContracts, WithFinality {
|
||||
val stateAndRef = cashFlowResult.stx.tx.outRef<Cash.State>(0)
|
||||
|
||||
// The un-upgraded state is Cash.State
|
||||
assert.that(aliceNode.getBaseStateFromVault(), hasContractState(isA<Cash.State>(anything)))
|
||||
assertThat(aliceNode.getBaseStateFromVault(), hasContractState(isA<Cash.State>(anything)))
|
||||
|
||||
// Starts contract upgrade flow.
|
||||
assert.that(aliceNode.initiateContractUpgrade(stateAndRef, CashV2::class), willReturn())
|
||||
assertThat(aliceNode.initiateContractUpgrade(stateAndRef, CashV2::class), willReturn())
|
||||
|
||||
// Get contract state from the vault.
|
||||
val upgradedState = aliceNode.getCashStateFromVault()
|
||||
assert.that(upgradedState,
|
||||
assertThat(upgradedState,
|
||||
hasIssuedAmount(Amount(1000000, USD) `issued by` (alice.ref(1)))
|
||||
and belongsTo(anonymisedRecipient))
|
||||
|
||||
@ -146,8 +146,8 @@ class ContractUpgradeFlowTest : WithContracts, WithFinality {
|
||||
addCommand(CashV2.Move(), alice.owningKey)
|
||||
}
|
||||
|
||||
assert.that(aliceNode.finalise(spendUpgradedTx), willReturn())
|
||||
assert.that(aliceNode.getCashStateFromVault(), hasContractState(equalTo(movedState)))
|
||||
assertThat(aliceNode.finalise(spendUpgradedTx), willReturn())
|
||||
assertThat(aliceNode.getCashStateFromVault(), hasContractState(equalTo(movedState)))
|
||||
}
|
||||
|
||||
class CashV2 : UpgradedContractWithLegacyConstraint<Cash.State, CashV2.State> {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.core.flows
|
||||
|
||||
import com.natpryce.hamkrest.and
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import net.corda.core.flows.mixins.WithFinality
|
||||
import net.corda.core.flows.mixins.WithFinality.FinalityInvoker
|
||||
import net.corda.core.identity.Party
|
||||
@ -17,7 +17,6 @@ import net.corda.testing.internal.matchers.flow.willReturn
|
||||
import net.corda.testing.internal.matchers.flow.willThrow
|
||||
import net.corda.testing.node.internal.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
|
||||
@ -40,7 +39,7 @@ class FinalityFlowTests : WithFinality {
|
||||
val bob = createBob()
|
||||
val stx = aliceNode.issuesCashTo(bob)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.finalise(stx, bob.info.singleIdentity()),
|
||||
willReturn(
|
||||
requiredSignatures(1)
|
||||
@ -52,7 +51,7 @@ class FinalityFlowTests : WithFinality {
|
||||
// Charlie isn't part of this network, so node A won't recognise them
|
||||
val stx = aliceNode.issuesCashTo(CHARLIE)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
aliceNode.finalise(stx),
|
||||
willThrow<IllegalArgumentException>())
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.core.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import com.natpryce.hamkrest.assertion.assertThat
|
||||
import net.corda.core.flows.mixins.WithMockNet
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.utilities.UntrustworthyData
|
||||
@ -10,11 +10,10 @@ import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.internal.matchers.flow.willReturn
|
||||
import net.corda.testing.node.internal.InternalMockNetwork
|
||||
import net.corda.testing.node.internal.TestStartedNode
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.AfterClass
|
||||
import org.junit.Test
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ReceiveMultipleFlowTests : WithMockNet {
|
||||
companion object {
|
||||
@ -52,13 +51,13 @@ class ReceiveMultipleFlowTests : WithMockNet {
|
||||
// this is a closure, meaning you can access variables outside its scope e.g., `answer`.
|
||||
val receivedMessage = session.receive<String>().unwrap { it }
|
||||
logger.info("Got message from counterParty: $receivedMessage.")
|
||||
assertThat(receivedMessage).isEqualTo(message)
|
||||
assertEquals(message, receivedMessage)
|
||||
session.send(answer)
|
||||
}
|
||||
} as FlowLogic<Unit>
|
||||
}
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
nodes[0].startFlowAndRunNetwork(initiatingFlow),
|
||||
willReturn(answer as Any))
|
||||
}
|
||||
@ -70,7 +69,7 @@ class ReceiveMultipleFlowTests : WithMockNet {
|
||||
val stringValue = "Thriller"
|
||||
nodes[2].registerAnswer(AlgorithmDefinition::class, stringValue)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
nodes[0].startFlowAndRunNetwork(ParallelAlgorithmMap(nodes[1].info.singleIdentity(), nodes[2].info.singleIdentity())),
|
||||
willReturn(doubleValue * stringValue.length))
|
||||
}
|
||||
@ -82,7 +81,7 @@ class ReceiveMultipleFlowTests : WithMockNet {
|
||||
val value2 = 6.0
|
||||
nodes[2].registerAnswer(ParallelAlgorithmList::class, value2)
|
||||
|
||||
assert.that(
|
||||
assertThat(
|
||||
nodes[0].startFlowAndRunNetwork(ParallelAlgorithmList(nodes[1].info.singleIdentity(), nodes[2].info.singleIdentity())),
|
||||
willReturn(listOf(value1, value2)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user