mirror of
https://github.com/corda/corda.git
synced 2025-01-13 16:30:25 +00:00
Merge commit 'd072f6c275a5ff770aa66e37b9492a387d757329' into aslemmer-merge-19-Feb
This commit is contained in:
commit
66dd6afe2e
@ -1,7 +1,6 @@
|
||||
package com.r3.corda.networkmanage.common.persistence
|
||||
|
||||
import com.r3.corda.networkmanage.TestBase
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.internal.signWithCert
|
||||
import net.corda.nodeapi.internal.createDevNetworkMapCa
|
||||
import net.corda.nodeapi.internal.crypto.CertificateAndKeyPair
|
||||
@ -55,7 +54,7 @@ class PersistentNetworkMapStorageTest : TestBase() {
|
||||
val parametersSignature = networkParameters.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate).sig
|
||||
// Create network parameters
|
||||
val networkParametersHash = networkMapStorage.saveNetworkParameters(networkParameters, parametersSignature)
|
||||
val networkMap = NetworkMap(listOf(nodeInfoHash), networkParametersHash)
|
||||
val networkMap = NetworkMap(listOf(nodeInfoHash), networkParametersHash, null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
|
||||
// when
|
||||
@ -96,7 +95,7 @@ class PersistentNetworkMapStorageTest : TestBase() {
|
||||
// Create empty network map
|
||||
|
||||
// Sign network map making it current network map
|
||||
val networkMap = NetworkMap(emptyList(), networkParametersHash)
|
||||
val networkMap = NetworkMap(emptyList(), networkParametersHash, null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
networkMapStorage.saveNetworkMap(signedNetworkMap)
|
||||
|
||||
@ -125,7 +124,7 @@ class PersistentNetworkMapStorageTest : TestBase() {
|
||||
// Create network parameters
|
||||
val testParameters = testNetworkParameters(emptyList())
|
||||
val networkParametersHash = networkMapStorage.saveNetworkParameters(testParameters, testParameters.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate).sig)
|
||||
val networkMap = NetworkMap(listOf(nodeInfoHashA), networkParametersHash)
|
||||
val networkMap = NetworkMap(listOf(nodeInfoHashA), networkParametersHash, null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
|
||||
// Sign network map
|
||||
|
@ -47,7 +47,7 @@ class NetworkMapSignerTest : TestBase() {
|
||||
val signedNodeInfoHashes = listOf(SecureHash.randomSHA256(), SecureHash.randomSHA256())
|
||||
val currentParameters = testNetworkParameters(emptyList(), minimumPlatformVersion = 1)
|
||||
val latestNetworkParameters = testNetworkParameters(emptyList(), minimumPlatformVersion = 2)
|
||||
val networkMap = NetworkMap(signedNodeInfoHashes, currentParameters.serialize().hash)
|
||||
val networkMap = NetworkMap(signedNodeInfoHashes, currentParameters.serialize().hash, null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
whenever(networkMapStorage.getCurrentNetworkMap()).thenReturn(signedNetworkMap)
|
||||
whenever(networkMapStorage.getNodeInfoHashes(any())).thenReturn(signedNodeInfoHashes)
|
||||
@ -83,7 +83,7 @@ class NetworkMapSignerTest : TestBase() {
|
||||
// given
|
||||
val networkParameters = testNetworkParameters(emptyList())
|
||||
val networkMapParametersHash = networkParameters.serialize().bytes.sha256()
|
||||
val networkMap = NetworkMap(emptyList(), networkMapParametersHash)
|
||||
val networkMap = NetworkMap(emptyList(), networkMapParametersHash, null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
whenever(networkMapStorage.getCurrentNetworkMap()).thenReturn(signedNetworkMap)
|
||||
whenever(networkMapStorage.getNodeInfoHashes(any())).thenReturn(emptyList())
|
||||
|
@ -104,7 +104,7 @@ class NetworkMapWebServiceTest {
|
||||
|
||||
@Test
|
||||
fun `get network map`() {
|
||||
val networkMap = NetworkMap(listOf(randomSHA256(), randomSHA256()), randomSHA256())
|
||||
val networkMap = NetworkMap(listOf(randomSHA256(), randomSHA256()), randomSHA256(), null)
|
||||
val signedNetworkMap = networkMap.signWithCert(networkMapCa.keyPair.private, networkMapCa.certificate)
|
||||
|
||||
val networkMapStorage: NetworkMapStorage = mock {
|
||||
|
@ -32,7 +32,7 @@ class SetsSerializationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `check set can be serialized as part of SessionData`() {
|
||||
fun `check set can be serialized as part of DataSessionMessage`() {
|
||||
run {
|
||||
val sessionData = DataSessionMessage(setOf(1).serialize())
|
||||
assertEqualAfterRoundTripSerialization(sessionData)
|
||||
|
@ -10,6 +10,7 @@ import net.corda.core.flows.NotaryException
|
||||
import net.corda.core.flows.NotaryFlow
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.node.NotaryInfo
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.node.internal.StartedNode
|
||||
@ -17,7 +18,6 @@ import net.corda.node.services.config.MySQLConfiguration
|
||||
import net.corda.node.services.config.NotaryConfig
|
||||
import net.corda.nodeapi.internal.DevIdentityGenerator
|
||||
import net.corda.nodeapi.internal.network.NetworkParametersCopier
|
||||
import net.corda.nodeapi.internal.network.NotaryInfo
|
||||
import net.corda.testing.common.internal.testNetworkParameters
|
||||
import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.core.chooseIdentity
|
||||
@ -83,7 +83,7 @@ class MySQLNotaryServiceTests : IntegrationTest() {
|
||||
val firstSpend = node.services.startFlow(NotaryFlow.Client(firstSpendTx))
|
||||
mockNet.runNetwork()
|
||||
|
||||
firstSpend.resultFuture.getOrThrow()
|
||||
firstSpend.getOrThrow()
|
||||
|
||||
val secondSpendBuilder = TransactionBuilder(notaryParty).withItems(inputState).run {
|
||||
val dummyState = DummyContract.SingleOwnerState(0, node.info.chooseIdentity())
|
||||
@ -96,7 +96,7 @@ class MySQLNotaryServiceTests : IntegrationTest() {
|
||||
|
||||
mockNet.runNetwork()
|
||||
|
||||
val ex = assertFailsWith(NotaryException::class) { secondSpend.resultFuture.getOrThrow() }
|
||||
val ex = assertFailsWith(NotaryException::class) { secondSpend.getOrThrow() }
|
||||
val error = ex.error as NotaryError.Conflict
|
||||
assertEquals(error.txId, secondSpendTx.id)
|
||||
}
|
||||
@ -112,11 +112,11 @@ class MySQLNotaryServiceTests : IntegrationTest() {
|
||||
|
||||
val notarise = node.services.startFlow(NotaryFlow.Client(spendTx))
|
||||
mockNet.runNetwork()
|
||||
val signature = notarise.resultFuture.get().single()
|
||||
val signature = notarise.get().single()
|
||||
|
||||
val notariseRetry = node.services.startFlow(NotaryFlow.Client(spendTx))
|
||||
mockNet.runNetwork()
|
||||
val signatureRetry = notariseRetry.resultFuture.get().single()
|
||||
val signatureRetry = notariseRetry.get().single()
|
||||
|
||||
fun checkSignature(signature: TransactionSignature) {
|
||||
signature.verify(spendTx.id)
|
||||
|
@ -38,8 +38,8 @@ import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStra
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetwork.MockNode
|
||||
import net.corda.testing.node.MockNodeParameters
|
||||
import net.corda.testing.node.pumpReceive
|
||||
import net.corda.testing.node.internal.startFlow
|
||||
import net.corda.testing.node.pumpReceive
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType
|
||||
|
@ -33,10 +33,10 @@ class CashSelectionH2Test {
|
||||
// spend operation below.
|
||||
// Issuing Integer.MAX_VALUE will not cause an exception since PersistentCashState.pennies is a long
|
||||
nCopies(2, Integer.MAX_VALUE).map { issueAmount ->
|
||||
node.services.startFlow(CashIssueFlow(issueAmount.POUNDS, OpaqueBytes.of(1), mockNet.defaultNotaryIdentity)).resultFuture
|
||||
node.services.startFlow(CashIssueFlow(issueAmount.POUNDS, OpaqueBytes.of(1), mockNet.defaultNotaryIdentity))
|
||||
}.transpose().getOrThrow()
|
||||
// The spend must be more than the size of a single cash state to force the accumulator onto the second state.
|
||||
node.services.startFlow(CashPaymentFlow((Integer.MAX_VALUE + 1L).POUNDS, node.info.legalIdentities[0])).resultFuture.getOrThrow()
|
||||
node.services.startFlow(CashPaymentFlow((Integer.MAX_VALUE + 1L).POUNDS, node.info.legalIdentities[0])).getOrThrow()
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -52,8 +52,8 @@ class CashSelectionH2Test {
|
||||
val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary))
|
||||
val flow3 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary))
|
||||
|
||||
assertThatThrownBy { flow1.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
assertThatThrownBy { flow2.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
assertThatThrownBy { flow3.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
assertThatThrownBy { flow1.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
assertThatThrownBy { flow2.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
assertThatThrownBy { flow3.getOrThrow() }.isInstanceOf(CashException::class.java)
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ class CashExitFlowTests {
|
||||
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||
bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME)
|
||||
notary = mockNet.defaultNotaryIdentity
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary))
|
||||
mockNet.runNetwork()
|
||||
future.getOrThrow()
|
||||
}
|
||||
@ -46,7 +46,7 @@ class CashExitFlowTests {
|
||||
@Test
|
||||
fun `exit some cash`() {
|
||||
val exitAmount = 500.DOLLARS
|
||||
val future = bankOfCordaNode.services.startFlow(CashExitFlow(exitAmount, ref)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashExitFlow(exitAmount, ref))
|
||||
mockNet.runNetwork()
|
||||
val exitTx = future.getOrThrow().stx.tx
|
||||
val expected = (initialBalance - exitAmount).`issued by`(bankOfCorda.ref(ref))
|
||||
@ -59,7 +59,7 @@ class CashExitFlowTests {
|
||||
@Test
|
||||
fun `exit zero cash`() {
|
||||
val expected = 0.DOLLARS
|
||||
val future = bankOfCordaNode.services.startFlow(CashExitFlow(expected, ref)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashExitFlow(expected, ref))
|
||||
mockNet.runNetwork()
|
||||
assertFailsWith<CashException> {
|
||||
future.getOrThrow()
|
||||
|
@ -56,7 +56,7 @@ class CashIssueAndPaymentFlowTests {
|
||||
val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultService.trackBy<Cash.State>(criteria)
|
||||
val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria)
|
||||
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentFlow(expectedPayment, OpaqueBytes.of(1), payTo, false, notary)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentFlow(expectedPayment, OpaqueBytes.of(1), payTo, false, notary))
|
||||
mockNet.runNetwork()
|
||||
future.getOrThrow()
|
||||
|
||||
|
@ -67,7 +67,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) {
|
||||
= aliceNode.services.vaultService.trackBy<Cash.State>(criteria)
|
||||
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentNoSelection(
|
||||
expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary)).resultFuture
|
||||
expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary))
|
||||
mockNet.runNetwork()
|
||||
future.getOrThrow()
|
||||
|
||||
|
@ -43,7 +43,7 @@ class CashIssueFlowTests {
|
||||
fun `issue some cash`() {
|
||||
val expected = 500.DOLLARS
|
||||
val ref = OpaqueBytes.of(0x01)
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary))
|
||||
mockNet.runNetwork()
|
||||
val issueTx = future.getOrThrow().stx
|
||||
val output = issueTx.tx.outputsOfType<Cash.State>().single()
|
||||
@ -54,7 +54,7 @@ class CashIssueFlowTests {
|
||||
fun `issue zero cash`() {
|
||||
val expected = 0.DOLLARS
|
||||
val ref = OpaqueBytes.of(0x01)
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary))
|
||||
mockNet.runNetwork()
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
future.getOrThrow()
|
||||
|
@ -38,7 +38,7 @@ class CashPaymentFlowTests {
|
||||
aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
||||
mockNet.runNetwork()
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture
|
||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity))
|
||||
future.getOrThrow()
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class CashPaymentFlowTests {
|
||||
val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria)
|
||||
|
||||
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment,
|
||||
payTo)).resultFuture
|
||||
payTo))
|
||||
mockNet.runNetwork()
|
||||
future.getOrThrow()
|
||||
|
||||
@ -92,7 +92,7 @@ class CashPaymentFlowTests {
|
||||
val payTo = aliceNode.info.chooseIdentity()
|
||||
val expected = 4000.DOLLARS
|
||||
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected,
|
||||
payTo)).resultFuture
|
||||
payTo))
|
||||
mockNet.runNetwork()
|
||||
assertFailsWith<CashException> {
|
||||
future.getOrThrow()
|
||||
@ -104,7 +104,7 @@ class CashPaymentFlowTests {
|
||||
val payTo = aliceNode.info.chooseIdentity()
|
||||
val expected = 0.DOLLARS
|
||||
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected,
|
||||
payTo)).resultFuture
|
||||
payTo))
|
||||
mockNet.runNetwork()
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
future.getOrThrow()
|
||||
|
@ -550,7 +550,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
val buyerFlows: Observable<out FlowLogic<*>> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
|
||||
val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine }
|
||||
val seller = SellerInitiator(buyer, notary, assetToSell, 1000.DOLLARS, anonymous)
|
||||
val sellerResult = sellerNode.services.startFlow(seller).resultFuture
|
||||
val sellerResult = sellerNode.services.startFlow(seller)
|
||||
return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,15 @@ package com.r3.enclaves.txverify
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
import net.corda.core.serialization.internal.SerializationEnvironmentImpl
|
||||
import net.corda.core.serialization.internal.nodeSerializationEnv
|
||||
import net.corda.core.utilities.ByteSequence
|
||||
import net.corda.core.utilities.toHexString
|
||||
import net.corda.nodeapi.internal.serialization.*
|
||||
import net.corda.nodeapi.internal.serialization.CordaSerializationMagic
|
||||
import net.corda.nodeapi.internal.serialization.KRYO_P2P_CONTEXT
|
||||
import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl
|
||||
import net.corda.nodeapi.internal.serialization.amqp.AbstractAMQPSerializationScheme
|
||||
import net.corda.nodeapi.internal.serialization.amqp.AmqpHeaderV1_0
|
||||
import net.corda.nodeapi.internal.serialization.amqp.SerializerFactory
|
||||
import net.corda.nodeapi.internal.serialization.amqp.amqpMagic
|
||||
import net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme
|
||||
import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1
|
||||
import net.corda.nodeapi.internal.serialization.kryo.kryoMagic
|
||||
|
||||
@Suppress("UNUSED")
|
||||
private class EnclaveletSerializationScheme {
|
||||
@ -40,8 +41,8 @@ private class EnclaveletSerializationScheme {
|
||||
}
|
||||
|
||||
private object KryoVerifierSerializationScheme : AbstractKryoSerializationScheme() {
|
||||
override fun canDeserializeVersion(byteSequence: ByteSequence, target: SerializationContext.UseCase): Boolean {
|
||||
return byteSequence == KryoHeaderV0_1 && target == SerializationContext.UseCase.P2P
|
||||
override fun canDeserializeVersion(magic: CordaSerializationMagic, target: SerializationContext.UseCase): Boolean {
|
||||
return magic == kryoMagic && target == SerializationContext.UseCase.P2P
|
||||
}
|
||||
|
||||
override fun rpcClientKryoPool(context: SerializationContext) = throw UnsupportedOperationException()
|
||||
@ -49,8 +50,8 @@ private object KryoVerifierSerializationScheme : AbstractKryoSerializationScheme
|
||||
}
|
||||
|
||||
private object AMQPVerifierSerializationScheme : AbstractAMQPSerializationScheme(emptyList()) {
|
||||
override fun canDeserializeVersion(byteSequence: ByteSequence, target: SerializationContext.UseCase): Boolean {
|
||||
return (byteSequence == AmqpHeaderV1_0 && (target == SerializationContext.UseCase.P2P))
|
||||
override fun canDeserializeVersion(magic: CordaSerializationMagic, target: SerializationContext.UseCase): Boolean {
|
||||
return magic == amqpMagic && target == SerializationContext.UseCase.P2P
|
||||
}
|
||||
|
||||
override fun rpcClientSerializerFactory(context: SerializationContext): SerializerFactory = throw UnsupportedOperationException()
|
||||
|
@ -10,4 +10,5 @@ import java.io.ByteArrayInputStream
|
||||
@CordaSerializable
|
||||
class MockContractAttachment(override val id: SecureHash = SecureHash.zeroHash, val contract: ContractClassName, override val signers: List<Party> = ArrayList()) : Attachment {
|
||||
override fun open() = ByteArrayInputStream(id.bytes)
|
||||
override val size = id.size
|
||||
}
|
Loading…
Reference in New Issue
Block a user