From 75f2c4a0a441a8bb4dedbf5553f4b1276a652386 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Tue, 5 Jun 2018 21:43:03 +0100 Subject: [PATCH 1/2] Removed flow-library doc page as it's redundant (#3307) --- docs/source/api-flows.rst | 10 +++- docs/source/component-library-index.rst | 1 - docs/source/flow-library.rst | 61 ------------------------- docs/source/key-concepts-flows.rst | 2 +- 4 files changed, 10 insertions(+), 64 deletions(-) delete mode 100644 docs/source/flow-library.rst diff --git a/docs/source/api-flows.rst b/docs/source/api-flows.rst index 619090bcfe..932f7a9159 100644 --- a/docs/source/api-flows.rst +++ b/docs/source/api-flows.rst @@ -602,7 +602,7 @@ transaction ourselves, we can automatically gather the signatures of the other r :dedent: 12 Each required signer will need to respond by invoking its own ``SignTransactionFlow`` subclass to check the -transaction and provide their signature if they are satisfied: +transaction (by implementing the ``checkTransaction`` method) and provide their signature if they are satisfied: .. container:: codeset @@ -618,6 +618,14 @@ transaction and provide their signature if they are satisfied: :end-before: DOCEND 16 :dedent: 12 +Types of things to check include: + + * Ensuring that the transaction received is the expected type, i.e. has the expected type of inputs and outputs + * Checking that the properties of the outputs are expected, this is in the absence of integrating reference + data sources to facilitate this + * Checking that the transaction is not incorrectly spending (perhaps maliciously) asset states, as potentially + the transaction creator has access to some of signer's state references + SendTransactionFlow/ReceiveTransactionFlow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Verifying a transaction received from a counterparty also requires verification of every transaction in its diff --git a/docs/source/component-library-index.rst b/docs/source/component-library-index.rst index 415b81b71b..18a6b2d05a 100644 --- a/docs/source/component-library-index.rst +++ b/docs/source/component-library-index.rst @@ -4,7 +4,6 @@ Component library .. toctree:: :maxdepth: 1 - flow-library contract-catalogue financial-model contract-irs \ No newline at end of file diff --git a/docs/source/flow-library.rst b/docs/source/flow-library.rst deleted file mode 100644 index 59cbb0354a..0000000000 --- a/docs/source/flow-library.rst +++ /dev/null @@ -1,61 +0,0 @@ -Flow library -============ - -There are a number of built-in flows supplied with Corda, which cover some core functionality. - -FinalityFlow ------------- - -The ``FinalityFlow`` verifies the given transactions, then sends them to the specified notary. - -If the notary agrees that the transactions are acceptable then they are from that point onwards committed to the ledger, -and will be written through to the vault. Additionally they will be distributed to the parties reflected in the participants -list of the states. - -The transactions will be topologically sorted before commitment to ensure that dependencies are committed before -dependers, so you don't need to do this yourself. - -The transactions are expected to have already been resolved: if their dependencies are not available in local storage or -within the given set, verification will fail. They must have signatures from all necessary parties other than the notary. - -If specified, the extra recipients are sent all the given transactions. The base set of parties to inform of each -transaction are calculated on a per transaction basis from the contract-given set of participants. - -The flow returns the same transactions, in the same order, with the additional signatures. - - -CollectSignaturesFlow ---------------------- - -The ``CollectSignaturesFlow`` is used to automate the collection of signatures from the counterparties to a transaction. - -You use the ``CollectSignaturesFlow`` by passing it a ``SignedTransaction`` which has at least been signed by yourself. -The flow will handle the resolution of the counterparty identities and request a signature from each counterparty. - -Finally, the flow will verify all the signatures and return a ``SignedTransaction`` with all the collected signatures. - -When using this flow on the responding side you will have to subclass the ``AbstractCollectSignaturesFlowResponder`` and -provide your own implementation of the ``checkTransaction`` method. This is to add additional verification logic on the -responder side. Types of things you will need to check include: - -* Ensuring that the transaction you are receiving is the transaction you *EXPECT* to receive. I.e. is has the expected - type of inputs and outputs -* Checking that the properties of the outputs are as you would expect, this is in the absence of integrating reference - data sources to facilitate this for us -* Checking that the transaction is not incorrectly spending (perhaps maliciously) one of your asset states, as potentially - the transaction creator has access to some of your state references - -Typically after calling the ``CollectSignaturesFlow`` you then called the ``FinalityFlow``. - -SendTransactionFlow/ReceiveTransactionFlow ------------------------------------------- - -The ``SendTransactionFlow`` and ``ReceiveTransactionFlow`` are used to automate the verification of the transaction by -recursively checking the validity of all the dependencies. Once a transaction is received and checked it's inserted into -local storage so it can be relayed and won't be checked again. - -The ``SendTransactionFlow`` sends the transaction to the counterparty and listen for data request as the counterparty -validating the transaction, extra checks can be implemented to restrict data access by overriding the ``verifyDataRequest`` -method inside ``SendTransactionFlow``. - -The ``ReceiveTransactionFlow`` returns a verified ``SignedTransaction``. \ No newline at end of file diff --git a/docs/source/key-concepts-flows.rst b/docs/source/key-concepts-flows.rst index 1452efe2e8..982d646214 100644 --- a/docs/source/key-concepts-flows.rst +++ b/docs/source/key-concepts-flows.rst @@ -76,7 +76,7 @@ logic behind common processes such as: * Gathering signatures from counterparty nodes * Verifying a chain of transactions -Further information on the available built-in flows can be found in :doc:`flow-library`. +Further information on the available built-in flows can be found in :doc:`api-flows`. Concurrency ----------- From d620e71bb643de941c99cf072e3b0ef603aa75c9 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Wed, 6 Jun 2018 00:31:41 +0100 Subject: [PATCH 2/2] Replaced all uses of assert with require (#3309) JVM assertions have to be enabled with the -ea flag so it's possible for these checks to be ignored. --- .../corda/client/jfx/utils/FlattenedList.kt | 2 +- .../net/corda/client/rpc/RPCStabilityTests.kt | 2 +- .../java/net/corda/docs/FlowCookbookJava.java | 3 +- .../kotlin/net/corda/docs/FlowCookbook.kt | 2 +- .../io/cryptoblk/core/StatusTransitions.kt | 2 +- .../contracts/universal/UniversalContract.kt | 2 +- .../corda/finance/contracts/universal/Util.kt | 18 ++++----- .../net/corda/node/serialization/kryo/Kryo.kt | 4 +- .../node/services/RPCSecurityManagerTest.kt | 10 ++--- .../internal/carpenter/ClassCarpenter.kt | 2 +- .../internal/carpenter/MetaCarpenter.kt | 2 +- .../internal/carpenter/SchemaFields.kt | 4 +- .../internal/carpenter/ClassCarpenterTest.kt | 4 +- ...berCompositeSchemaToClassCarpenterTests.kt | 40 +++++++++---------- ...berCompositeSchemaToClassCarpenterTests.kt | 8 ++-- ...berCompositeSchemaToClassCarpenterTests.kt | 24 +++++------ 16 files changed, 65 insertions(+), 64 deletions(-) diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt index 21e8b2a5c3..f8d9f721af 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt @@ -106,7 +106,7 @@ class FlattenedList(val sourceList: ObservableList } } endChange() - assert(sourceList.size == indexMap.size) + require(sourceList.size == indexMap.size) } override fun get(index: Int): A = sourceList[index].value diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt index 4a4f49af47..fd322a291f 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt @@ -91,7 +91,7 @@ class RPCStabilityTests { // This is a less than check because threads from other tests may be shutting down while this test is running. // This is therefore a "best effort" check. When this test is run on its own this should be a strict equality. // In case of failure we output the threads along with their stacktraces to get an idea what was running at a time. - assert(threadsBefore.keys.size >= threadsAfter.keys.size, { "threadsBefore: $threadsBefore\nthreadsAfter: $threadsAfter" }) + require(threadsBefore.keys.size >= threadsAfter.keys.size, { "threadsBefore: $threadsBefore\nthreadsAfter: $threadsAfter" }) } finally { executor.shutdownNow() } diff --git a/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java b/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java index 56dea67577..13d89eb577 100644 --- a/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java +++ b/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java @@ -32,6 +32,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import static com.google.common.base.Preconditions.checkArgument; import static net.corda.core.contracts.ContractsDSL.requireThat; import static net.corda.core.crypto.Crypto.generateKeyPair; @@ -662,7 +663,7 @@ public class FlowCookbookJava { requireThat(require -> { // Any additional checking we see fit... DummyState outputState = (DummyState) stx.getTx().getOutputs().get(0).getData(); - assert (outputState.getMagicNumber() == 777); + checkArgument(outputState.getMagicNumber() == 777); return null; }); } diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt index 0528caeaf3..40f7487946 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt @@ -642,7 +642,7 @@ class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic() { override fun checkTransaction(stx: SignedTransaction) = requireThat { // Any additional checking we see fit... val outputState = stx.tx.outputsOfType().single() - assert(outputState.magicNumber == 777) + require(outputState.magicNumber == 777) } } diff --git a/experimental/corda-utils/src/main/kotlin/io/cryptoblk/core/StatusTransitions.kt b/experimental/corda-utils/src/main/kotlin/io/cryptoblk/core/StatusTransitions.kt index f469e52a48..af7db67dfa 100644 --- a/experimental/corda-utils/src/main/kotlin/io/cryptoblk/core/StatusTransitions.kt +++ b/experimental/corda-utils/src/main/kotlin/io/cryptoblk/core/StatusTransitions.kt @@ -67,7 +67,7 @@ class StatusTransitions>(priv // for each combination of in x out which should normally be at most 1... inputStates.forEach { inp -> outputStates.forEach { outp -> - assert((inp != null) || (outp != null)) + require(inp != null || outp != null) val options = matchingTransitions(inp?.status, outp?.status, cmd.value) val signerGroup = options.groupBy { it.signer }.entries.singleOrNull() diff --git a/experimental/src/main/kotlin/net/corda/finance/contracts/universal/UniversalContract.kt b/experimental/src/main/kotlin/net/corda/finance/contracts/universal/UniversalContract.kt index 529ee297cf..ef37f3114b 100644 --- a/experimental/src/main/kotlin/net/corda/finance/contracts/universal/UniversalContract.kt +++ b/experimental/src/main/kotlin/net/corda/finance/contracts/universal/UniversalContract.kt @@ -204,7 +204,7 @@ class UniversalContract : Contract { val rest = extractRemainder(arr, action) // for now - let's assume not - assert(rest is Zero) + require(rest is Zero) requireThat { "action must have a time-window" using (tx.timeWindow != null) diff --git a/experimental/src/main/kotlin/net/corda/finance/contracts/universal/Util.kt b/experimental/src/main/kotlin/net/corda/finance/contracts/universal/Util.kt index cca488f4c8..1d1e1099d0 100644 --- a/experimental/src/main/kotlin/net/corda/finance/contracts/universal/Util.kt +++ b/experimental/src/main/kotlin/net/corda/finance/contracts/universal/Util.kt @@ -125,7 +125,7 @@ fun actions(arrangement: Arrangement): Map = when (arrangement) } fun debugCompare(left: String, right: String) { - assert(left == right) + require(left == right) } fun debugCompare(perLeft: Perceivable, perRight: Perceivable) { @@ -142,7 +142,7 @@ fun debugCompare(perLeft: Perceivable, perRight: Perceivable) { if (perRight is PerceivableOperation) { debugCompare(perLeft.left, perRight.left) debugCompare(perLeft.right, perRight.right) - assert(perLeft.op == perRight.op) + require(perLeft.op == perRight.op) return } } @@ -152,7 +152,7 @@ fun debugCompare(perLeft: Perceivable, perRight: Perceivable) { debugCompare(perLeft.interest, perRight.interest) debugCompare(perLeft.start, perRight.start) debugCompare(perLeft.end, perRight.end) - assert(perLeft.dayCountConvention == perRight.dayCountConvention) + require(perLeft.dayCountConvention == perRight.dayCountConvention) return } } @@ -166,25 +166,25 @@ fun debugCompare(perLeft: Perceivable, perRight: Perceivable) { } } - assert(false) + require(false) } fun debugCompare(parLeft: Party, parRight: Party) { - assert(parLeft == parRight) + require(parLeft == parRight) } fun debugCompare(left: Frequency, right: Frequency) { - assert(left == right) + require(left == right) } fun debugCompare(left: LocalDate, right: LocalDate) { - assert(left == right) + require(left == right) } fun debugCompare(parLeft: Set, parRight: Set) { if (parLeft == parRight) return - assert(parLeft == parRight) + require(parLeft == parRight) } fun debugCompare(arrLeft: Arrangement, arrRight: Arrangement) { @@ -229,5 +229,5 @@ fun debugCompare(arrLeft: Arrangement, arrRight: Arrangement) { } } - assert(false) + require(false) } diff --git a/node/src/main/kotlin/net/corda/node/serialization/kryo/Kryo.kt b/node/src/main/kotlin/net/corda/node/serialization/kryo/Kryo.kt index 257cbcc78a..ec3046c682 100644 --- a/node/src/main/kotlin/net/corda/node/serialization/kryo/Kryo.kt +++ b/node/src/main/kotlin/net/corda/node/serialization/kryo/Kryo.kt @@ -74,7 +74,7 @@ class ImmutableClassSerializer(val klass: KClass) : Serializer() init { // Verify that this class is immutable (all properties are final) - assert(props.none { it is KMutableProperty<*> }) + require(props.none { it is KMutableProperty<*> }) } // Just a utility to help us catch cases where nodes are running out of sync versions. @@ -109,7 +109,7 @@ class ImmutableClassSerializer(val klass: KClass) : Serializer() } override fun read(kryo: Kryo, input: Input, type: Class): T { - assert(type.kotlin == klass) + require(type.kotlin == klass) val numFields = input.readVarInt(true) val fieldTypeHash = input.readInt() diff --git a/node/src/test/kotlin/net/corda/node/services/RPCSecurityManagerTest.kt b/node/src/test/kotlin/net/corda/node/services/RPCSecurityManagerTest.kt index 22b08adea1..f64d72ea87 100644 --- a/node/src/test/kotlin/net/corda/node/services/RPCSecurityManagerTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/RPCSecurityManagerTest.kt @@ -121,7 +121,7 @@ class RPCSecurityManagerTest { id = AuthServiceId("TEST")) val subject = userRealm.buildSubject("foo") for (action in allActions) { - assert(!subject.isPermitted(action)) { + require(!subject.isPermitted(action)) { "Invalid subject should not be allowed to call $action" } } @@ -143,24 +143,24 @@ class RPCSecurityManagerTest { for (request in permitted) { val call = request.first() val args = request.drop(1).toTypedArray() - assert(subject.isPermitted(request.first(), *args)) { + require(subject.isPermitted(request.first(), *args)) { "User ${subject.principal} should be permitted $call with target '${request.toList()}'" } if (args.isEmpty()) { - assert(subject.isPermitted(request.first(), "XXX")) { + require(subject.isPermitted(request.first(), "XXX")) { "User ${subject.principal} should be permitted $call with any target" } } } disabled.forEach { - assert(!subject.isPermitted(it)) { + require(!subject.isPermitted(it)) { "Permissions $permissions should not allow to call $it" } } disabled.filter { !permitted.contains(listOf(it, "foo")) }.forEach { - assert(!subject.isPermitted(it, "foo")) { + require(!subject.isPermitted(it, "foo")) { "Permissions $permissions should not allow to call $it with argument 'foo'" } } diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenter.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenter.kt index 679a198f86..7f25bef8f5 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenter.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenter.kt @@ -139,7 +139,7 @@ class ClassCarpenterImpl(cl: ClassLoader, override val whitelist: ClassWhitelist } } - assert(schema.name in _loaded) + require(schema.name in _loaded) return _loaded[schema.name]!! } diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/MetaCarpenter.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/MetaCarpenter.kt index 0d82f75006..e15e69e2a0 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/MetaCarpenter.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/MetaCarpenter.kt @@ -72,7 +72,7 @@ abstract class MetaCarpenterBase(val schemas: CarpenterMetaSchema, val cc: Class // carpented class existing and remove it from their dependency list, If that // list is now empty we have no impediment to carpenting that class up schemas.dependsOn.remove(newObject.name)?.forEach { dependent -> - assert(newObject.name in schemas.dependencies[dependent]!!.second) + require(newObject.name in schemas.dependencies[dependent]!!.second) schemas.dependencies[dependent]?.second?.remove(newObject.name) diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/SchemaFields.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/SchemaFields.kt index e6cd9cf58e..2cd35385a3 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/SchemaFields.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/carpenter/SchemaFields.kt @@ -67,7 +67,7 @@ open class NonNullableField(field: Class) : ClassField(field) { } override fun nullTest(mv: MethodVisitor, slot: Int) { - assert(name != unsetName) + require(name != unsetName) if (!field.isPrimitive) { with(mv) { @@ -103,7 +103,7 @@ class NullableField(field: Class) : ClassField(field) { } override fun nullTest(mv: MethodVisitor, slot: Int) { - assert(name != unsetName) + require(name != unsetName) } } diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt index 57f69e094c..123df44182 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt @@ -170,8 +170,8 @@ class ClassCarpenterTest { val iface = cc.build(schema1) - assert(iface.isInterface) - assert(iface.constructors.isEmpty()) + require(iface.isInterface) + require(iface.constructors.isEmpty()) assertEquals(iface.declaredMethods.size, 1) assertEquals(iface.declaredMethods[0].name, "getA") diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/CompositeMemberCompositeSchemaToClassCarpenterTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/CompositeMemberCompositeSchemaToClassCarpenterTests.kt index 36bc4ad4fe..cca81755e9 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/CompositeMemberCompositeSchemaToClassCarpenterTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/CompositeMemberCompositeSchemaToClassCarpenterTests.kt @@ -30,15 +30,15 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val b = B(A(testA), testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(b)) - assert(obj.obj is B) + require(obj.obj is B) val amqpObj = obj.obj as B assertEquals(testB, amqpObj.b) assertEquals(testA, amqpObj.a.a) assertEquals(2, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) - assert(obj.envelope.schema.types[1] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[1] is CompositeType) var amqpSchemaA: CompositeType? = null var amqpSchemaB: CompositeType? = null @@ -50,8 +50,8 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { } } - assert(amqpSchemaA != null) - assert(amqpSchemaB != null) + require(amqpSchemaA != null) + require(amqpSchemaB != null) // Just ensure the amqp schema matches what we want before we go messing // around with the internals @@ -68,9 +68,9 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val metaSchema = obj.envelope.schema.carpenterSchema(ClassLoader.getSystemClassLoader()) // if we know all the classes there is nothing to really achieve here - assert(metaSchema.carpenterSchemas.isEmpty()) - assert(metaSchema.dependsOn.isEmpty()) - assert(metaSchema.dependencies.isEmpty()) + require(metaSchema.carpenterSchemas.isEmpty()) + require(metaSchema.dependsOn.isEmpty()) + require(metaSchema.dependencies.isEmpty()) } // you cannot have an element of a composite class we know about @@ -92,7 +92,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(b)) val amqpSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"))) - assert(obj.obj is B) + require(obj.obj is B) amqpSchema.carpenterSchema(ClassLoader.getSystemClassLoader()) } @@ -111,7 +111,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val b = B(A(testA), testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(b)) - assert(obj.obj is B) + require(obj.obj is B) val amqpSchema = obj.envelope.schema.mangleNames(listOf(classTestName("B"))) val carpenterSchema = amqpSchema.carpenterSchema(ClassLoader.getSystemClassLoader()) @@ -122,7 +122,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { metaCarpenter.build() - assert(mangleName(classTestName("B")) in metaCarpenter.objects) + require(mangleName(classTestName("B")) in metaCarpenter.objects) } @Test @@ -139,7 +139,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val b = B(A(testA), testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(b)) - assert(obj.obj is B) + require(obj.obj is B) val amqpSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"), classTestName("B"))) val carpenterSchema = amqpSchema.carpenterSchema(ClassLoader.getSystemClassLoader()) @@ -149,9 +149,9 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { assertEquals(1, carpenterSchema.size) assertEquals(mangleName(classTestName("A")), carpenterSchema.carpenterSchemas.first().name) assertEquals(1, carpenterSchema.dependencies.size) - assert(mangleName(classTestName("B")) in carpenterSchema.dependencies) + require(mangleName(classTestName("B")) in carpenterSchema.dependencies) assertEquals(1, carpenterSchema.dependsOn.size) - assert(mangleName(classTestName("A")) in carpenterSchema.dependsOn) + require(mangleName(classTestName("A")) in carpenterSchema.dependsOn) val metaCarpenter = TestMetaCarpenter(carpenterSchema, ClassCarpenterImpl(whitelist = AllWhitelist)) @@ -172,8 +172,8 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { // second manual iteration, will carpent B metaCarpenter.build() - assert(mangleName(classTestName("A")) in metaCarpenter.objects) - assert(mangleName(classTestName("B")) in metaCarpenter.objects) + require(mangleName(classTestName("A")) in metaCarpenter.objects) + require(mangleName(classTestName("B")) in metaCarpenter.objects) // and we must be finished assertTrue(carpenterSchema.carpenterSchemas.isEmpty()) @@ -198,7 +198,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val c = C(B(testA, testB), testC) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(c)) - assert(obj.obj is C) + require(obj.obj is C) val amqpSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"), classTestName("B"))) @@ -224,7 +224,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val c = C(B(testA, testB), testC) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(c)) - assert(obj.obj is C) + require(obj.obj is C) val amqpSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"), classTestName("B"))) @@ -250,7 +250,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val c = C(B(testA, testB), testC) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(c)) - assert(obj.obj is C) + require(obj.obj is C) val carpenterSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"), classTestName("B"))) TestMetaCarpenter(carpenterSchema.carpenterSchema( @@ -273,7 +273,7 @@ class CompositeMembers : AmqpCarpenterBase(AllWhitelist) { val b = B(testA, testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(b)) - assert(obj.obj is B) + require(obj.obj is B) val carpenterSchema = obj.envelope.schema.mangleNames(listOf(classTestName("A"), classTestName("B"))) val metaCarpenter = TestMetaCarpenter(carpenterSchema.carpenterSchema()) diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/MultiMemberCompositeSchemaToClassCarpenterTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/MultiMemberCompositeSchemaToClassCarpenterTests.kt index d4ec3c4b98..8b50f9d996 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/MultiMemberCompositeSchemaToClassCarpenterTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/MultiMemberCompositeSchemaToClassCarpenterTests.kt @@ -21,13 +21,13 @@ class MultiMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWhi val a = A(testA, testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(testA, amqpObj.a) assertEquals(testB, amqpObj.b) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType @@ -65,13 +65,13 @@ class MultiMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWhi val a = A(testA, testB) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(testA, amqpObj.a) assertEquals(testB, amqpObj.b) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/SingleMemberCompositeSchemaToClassCarpenterTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/SingleMemberCompositeSchemaToClassCarpenterTests.kt index 32b5334cf2..abcf831091 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/SingleMemberCompositeSchemaToClassCarpenterTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/SingleMemberCompositeSchemaToClassCarpenterTests.kt @@ -18,12 +18,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val a = A(test) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType @@ -54,12 +54,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType val carpenterSchema = CarpenterMetaSchema.newInstance() @@ -84,12 +84,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val a = A(test) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType @@ -119,12 +119,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val a = A(test) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType @@ -154,12 +154,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val a = A(test) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType @@ -189,12 +189,12 @@ class SingleMemberCompositeSchemaToClassCarpenterTests : AmqpCarpenterBase(AllWh val a = A(test) val obj = DeserializationInput(factory).deserializeAndReturnEnvelope(serialise(a)) - assert(obj.obj is A) + require(obj.obj is A) val amqpObj = obj.obj as A assertEquals(test, amqpObj.a) assertEquals(1, obj.envelope.schema.types.size) - assert(obj.envelope.schema.types[0] is CompositeType) + require(obj.envelope.schema.types[0] is CompositeType) val amqpSchema = obj.envelope.schema.types[0] as CompositeType