Fixes after rebase

This commit is contained in:
Michal Kit 2017-08-15 17:41:35 +01:00
parent f5fc4ceeb8
commit 890ef68523
3 changed files with 9 additions and 19 deletions

View File

@ -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))
}

View File

@ -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
}
}
}

View File

@ -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<Exception> { 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"))
}
}
}