From 890ef6852384497907600e4fd8477caef7f0b474 Mon Sep 17 00:00:00 2001 From: Michal Kit Date: Tue, 15 Aug 2017 17:41:35 +0100 Subject: [PATCH] Fixes after rebase --- .../com/r3/enclaves/verify/NativeSgxApiTest.kt | 2 +- .../enclaves/txverify/KryoSerializationScheme.kt | 15 ++------------- .../com/r3/enclaves/txverify/EnclaveletTest.kt | 11 ++++++----- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/verify-enclave/src/integration-test/kotlin/com/r3/enclaves/verify/NativeSgxApiTest.kt b/verify-enclave/src/integration-test/kotlin/com/r3/enclaves/verify/NativeSgxApiTest.kt index e91abbb63b..646d0abcd0 100644 --- a/verify-enclave/src/integration-test/kotlin/com/r3/enclaves/verify/NativeSgxApiTest.kt +++ b/verify-enclave/src/integration-test/kotlin/com/r3/enclaves/verify/NativeSgxApiTest.kt @@ -45,7 +45,7 @@ class NativeSgxApiTest { verifies() } - val req = TransactionVerificationRequest(wtx3.serialized, arrayOf(wtx1.serialized, wtx2.serialized), emptyArray()) + val req = TransactionVerificationRequest(wtx3.serialize(), arrayOf(wtx1.serialize(), wtx2.serialize()), emptyArray()) val serialized = req.serialize() assertNull(NativeSgxApi.verify(enclavePath, serialized.bytes)) } diff --git a/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoSerializationScheme.kt b/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoSerializationScheme.kt index d01157d904..c1c8b3d1fc 100644 --- a/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoSerializationScheme.kt +++ b/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoSerializationScheme.kt @@ -1,28 +1,17 @@ package com.r3.enclaves.txverify import net.corda.core.serialization.SerializationContext -import net.corda.core.serialization.SerializationDefaults +import net.corda.core.serialization.SerializationFactory import net.corda.core.utilities.ByteSequence import net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme -import net.corda.nodeapi.internal.serialization.KRYO_P2P_CONTEXT import net.corda.nodeapi.internal.serialization.KryoHeaderV0_1 -import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl @Suppress("UNUSED") -private class KryoVerifierSerializationScheme : AbstractKryoSerializationScheme() { +private class KryoVerifierSerializationScheme(serializationFactory: SerializationFactory) : AbstractKryoSerializationScheme(serializationFactory) { override fun canDeserializeVersion(byteSequence: ByteSequence, target: SerializationContext.UseCase): Boolean { return byteSequence == KryoHeaderV0_1 && target == SerializationContext.UseCase.P2P } override fun rpcClientKryoPool(context: SerializationContext) = throw UnsupportedOperationException() override fun rpcServerKryoPool(context: SerializationContext) = throw UnsupportedOperationException() - - private companion object { - init { - SerializationDefaults.SERIALIZATION_FACTORY = SerializationFactoryImpl().apply { - registerScheme(KryoVerifierSerializationScheme()) - } - SerializationDefaults.P2P_CONTEXT = KRYO_P2P_CONTEXT - } - } } diff --git a/verify-enclave/src/test/kotlin/com/r3/enclaves/txverify/EnclaveletTest.kt b/verify-enclave/src/test/kotlin/com/r3/enclaves/txverify/EnclaveletTest.kt index 32e9a8aeba..fa964edb05 100644 --- a/verify-enclave/src/test/kotlin/com/r3/enclaves/txverify/EnclaveletTest.kt +++ b/verify-enclave/src/test/kotlin/com/r3/enclaves/txverify/EnclaveletTest.kt @@ -11,6 +11,7 @@ import net.corda.testing.MEGA_CORP_PUBKEY import net.corda.testing.MINI_CORP_PUBKEY import net.corda.testing.ledger import org.junit.Test +import java.nio.file.Files import java.nio.file.Paths import kotlin.test.assertFailsWith import kotlin.test.assertTrue @@ -38,9 +39,9 @@ class EnclaveletTest { verifies() } - val req = TransactionVerificationRequest(wtx3.serialized, arrayOf(wtx1.serialized, wtx2.serialized), emptyArray()) + val req = TransactionVerificationRequest(wtx3.serialize(), arrayOf(wtx1.serialize(), wtx2.serialize()), emptyArray()) val serialized = req.serialize() - serialized.writeToFile(Paths.get("/tmp/req")) + Files.write(Paths.get("/tmp/req"), serialized.bytes) verifyInEnclave(serialized.bytes) } } @@ -63,11 +64,11 @@ class EnclaveletTest { input("c1") input("c2") output(Cash.State(3000.POUNDS `issued by` DUMMY_CASH_ISSUER, AnonymousParty(MINI_CORP_PUBKEY))) - failsWith("Required net.corda.core.contracts.FungibleAsset.Commands.Move command") + failsWith("Required ${Cash.Commands.Move::class.java.canonicalName} command") } - val req = TransactionVerificationRequest(wtx3.serialized, arrayOf(wtx1.serialized, wtx2.serialized), emptyArray()) + val req = TransactionVerificationRequest(wtx3.serialize(), arrayOf(wtx1.serialize(), wtx2.serialize()), emptyArray()) val e = assertFailsWith { verifyInEnclave(req.serialize().bytes) } - assertTrue(e.message!!.contains("Required net.corda.core.contracts.FungibleAsset.Commands.Move command")) + assertTrue(e.message!!.contains("Required ${Cash.Commands.Move::class.java.canonicalName} command")) } } } \ No newline at end of file