From 687fa81894b8c843a8613aa7b354aade21cd76fa Mon Sep 17 00:00:00 2001 From: Christian Sailer Date: Tue, 9 Jul 2019 10:09:21 +0100 Subject: [PATCH] ETO-39 Move core tests (#5255) * Moved core.flows and core.contract tests * move internal tests * move node, schemas and serialization tests * Move transactions tests * Move test access helper into test package * Move remaining tests, and create access helpers to test internals. * Fix test dependencies. * Delete some cruft that flagged up on the API checker * Add readme explaing where tests need to go. * fix typo --- .idea/compiler.xml | 180 ++++++++++++++++++ core-tests/build.gradle | 158 +++++++++++++++ .../corda/coretests}/NodeVersioningTest.kt | 2 +- .../coretests}/cordapp/CordappSmokeTest.kt | 4 +- .../contracts/AmountParsingTest.java | 3 +- .../coretests}/flows/FlowsInJavaTest.java | 3 +- .../flows/SerializationApiInJavaTest.java | 2 +- .../coretests}/schemas/BadSchemaJavaV1.java | 5 +- .../schemas/BadSchemaNoGetterJavaV1.java | 5 +- .../coretests}/schemas/GoodSchemaJavaV1.java | 5 +- .../schemas/PoliteSchemaJavaV1.java | 5 +- .../schemas/TestJavaSchemaFamily.java | 2 +- .../schemas/TrickySchemaJavaV1.java | 5 +- .../corda/coretests}/contracts/AmountTests.kt | 6 +- .../contracts/ConstraintsPropagationTests.kt | 26 +-- .../contracts/ContractHierarchyTest.kt | 3 +- .../coretests}/contracts/ContractsDSLTests.kt | 5 +- .../PackageOwnershipVerificationTests.kt | 7 +- .../coretests}/contracts/TimeWindowTest.kt | 3 +- ...VerificationExceptionSerialisationTests.kt | 10 +- .../coretests}/crypto/CompositeKeyTests.kt | 3 +- .../crypto/PartialMerkleTreeTest.kt | 33 ++-- .../corda/coretests}/crypto/SignedDataTest.kt | 5 +- .../crypto/TransactionSignatureTest.kt | 3 +- .../crypto/X509NameConstraintsTest.kt | 3 +- .../corda/coretests}/flows/AttachmentTests.kt | 7 +- .../flows/CollectSignaturesFlowTests.kt | 8 +- .../flows/ContractUpgradeFlowRPCTest.kt | 5 +- .../flows/ContractUpgradeFlowTest.kt | 7 +- .../coretests}/flows/FastThreadLocalTest.kt | 2 +- .../coretests}/flows/FinalityFlowTests.kt | 6 +- .../coretests}/flows/ReceiveAllFlowTests.kt | 8 +- .../flows/ReceiveFinalityFlowTest.kt | 3 +- .../flows/ReferencedStatesFlowTests.kt | 3 +- .../flows/TestNoSecurityDataVendingFlow.kt | 4 +- .../corda/coretests/flows}/WithContracts.kt | 2 +- .../corda/coretests/flows}/WithFinality.kt | 4 +- .../net/corda/coretests/flows}/WithMockNet.kt | 2 +- .../indentity}/PartyAndCertificateTest.kt | 5 +- .../corda/coretests/indentity}/PartyTest.kt | 5 +- .../coretests}/internal/CertRoleTests.kt | 3 +- .../NetworkParametersResolutionTest.kt | 4 +- .../internal/ResolveTransactionsFlowTest.kt | 6 +- .../internal/TopologicalSortTest.kt | 3 +- .../coretests}/node/NetworkParametersTest.kt | 4 +- .../corda/coretests}/node/NodeInfoTests.kt | 3 +- .../corda/coretests}/node/VaultUpdateTests.kt | 4 +- ...ppedSchemasCrossReferenceDetectionTests.kt | 12 +- .../AttachmentSerializationTest.kt | 4 +- .../CommandsSerializationTests.kt | 4 +- .../NotaryExceptionSerializationTest.kt | 4 +- .../TransactionSerializationTests.kt | 10 +- ...ttachmentsClassLoaderSerializationTests.kt | 2 +- .../AttachmentsClassLoaderTests.kt | 2 +- .../CompatibleTransactionTests.kt | 49 ++--- .../LedgerTransactionQueryTests.kt | 5 +- .../transactions/ReferenceInputStateTests.kt | 14 +- .../transactions/TransactionBuilderTest.kt | 3 +- .../TransactionEncumbranceTests.kt | 7 +- .../transactions/TransactionTests.kt | 12 +- .../coretests}/utilities/KotlinUtilsTest.kt | 3 +- .../coretests}/utilities/NonEmptySetTest.kt | 3 +- .../utilities/ProgressTrackerTest.kt | 7 +- .../contracts/DummyContractBackdoor.kt | 0 .../src/test/resources/isolated.jar | Bin .../coretests}/transactions/isolated-4.0.jar | Bin .../coretests}/transactions/old-isolated.jar | Bin core/build.gradle | 71 +------ .../net/corda/core/internal/CordaUtils.kt | 2 +- core/src/test/README.md | 12 ++ .../core/concurrent/ConcurrencyUtilsTest.kt | 3 +- .../concurrent/CordaFutureImplTest.kt | 9 +- .../internal/internalAccessTestHelpers.kt | 42 ++++ finance/contracts/build.gradle | 1 + finance/workflows/build.gradle | 1 + node/build.gradle | 1 + .../FlowFrameworkPersistenceTests.kt | 2 +- .../statemachine/FlowFrameworkTests.kt | 1 + .../FlowFrameworkTripartyTests.kt | 2 +- .../vault/VaultSoftLockManagerTest.kt | 1 + settings.gradle | 1 + .../corda/testing}/flows/FlowTestsUtils.kt | 33 +--- 82 files changed, 654 insertions(+), 253 deletions(-) create mode 100644 core-tests/build.gradle rename {core/src/smoke-test/kotlin/net/corda/core => core-tests/src/smoke-test/kotlin/net/corda/coretests}/NodeVersioningTest.kt (99%) rename {core/src/smoke-test/kotlin/net/corda/core => core-tests/src/smoke-test/kotlin/net/corda/coretests}/cordapp/CordappSmokeTest.kt (97%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/contracts/AmountParsingTest.java (81%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/flows/FlowsInJavaTest.java (98%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/flows/SerializationApiInJavaTest.java (97%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/BadSchemaJavaV1.java (86%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/BadSchemaNoGetterJavaV1.java (83%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/GoodSchemaJavaV1.java (79%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/PoliteSchemaJavaV1.java (86%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/TestJavaSchemaFamily.java (51%) rename {core/src/test/java/net/corda/core => core-tests/src/test/java/net/corda/coretests}/schemas/TrickySchemaJavaV1.java (87%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/AmountTests.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/ConstraintsPropagationTests.kt (95%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/ContractHierarchyTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/ContractsDSLTests.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/PackageOwnershipVerificationTests.kt (94%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/TimeWindowTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/contracts/TransactionVerificationExceptionSerialisationTests.kt (94%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/crypto/CompositeKeyTests.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/crypto/PartialMerkleTreeTest.kt (92%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/crypto/SignedDataTest.kt (89%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/crypto/TransactionSignatureTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/crypto/X509NameConstraintsTest.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/AttachmentTests.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/CollectSignaturesFlowTests.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/ContractUpgradeFlowRPCTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/ContractUpgradeFlowTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/FastThreadLocalTest.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/FinalityFlowTests.kt (96%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/ReceiveAllFlowTests.kt (95%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/ReceiveFinalityFlowTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/ReferencedStatesFlowTests.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/flows/TestNoSecurityDataVendingFlow.kt (87%) rename {core/src/test/kotlin/net/corda/core/flows/mixins => core-tests/src/test/kotlin/net/corda/coretests/flows}/WithContracts.kt (99%) rename {core/src/test/kotlin/net/corda/core/flows/mixins => core-tests/src/test/kotlin/net/corda/coretests/flows}/WithFinality.kt (94%) rename {core/src/test/kotlin/net/corda/core/flows/mixins => core-tests/src/test/kotlin/net/corda/coretests/flows}/WithMockNet.kt (98%) rename {core/src/test/kotlin/net/corda/core/identity => core-tests/src/test/kotlin/net/corda/coretests/indentity}/PartyAndCertificateTest.kt (93%) rename {core/src/test/kotlin/net/corda/core/identity => core-tests/src/test/kotlin/net/corda/coretests/indentity}/PartyTest.kt (82%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/internal/CertRoleTests.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/internal/NetworkParametersResolutionTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/internal/ResolveTransactionsFlowTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/internal/TopologicalSortTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/node/NetworkParametersTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/node/NodeInfoTests.kt (95%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/node/VaultUpdateTests.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/schemas/MappedSchemasCrossReferenceDetectionTests.kt (89%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/serialization/AttachmentSerializationTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/serialization/CommandsSerializationTests.kt (81%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/serialization/NotaryExceptionSerializationTest.kt (89%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/serialization/TransactionSerializationTests.kt (92%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/AttachmentsClassLoaderSerializationTests.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/AttachmentsClassLoaderTests.kt (99%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/CompatibleTransactionTests.kt (92%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/LedgerTransactionQueryTests.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/ReferenceInputStateTests.kt (94%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/TransactionBuilderTest.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/TransactionEncumbranceTests.kt (98%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/transactions/TransactionTests.kt (96%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/utilities/KotlinUtilsTest.kt (97%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/utilities/NonEmptySetTest.kt (96%) rename {core/src/test/kotlin/net/corda/core => core-tests/src/test/kotlin/net/corda/coretests}/utilities/ProgressTrackerTest.kt (98%) rename {core => core-tests}/src/test/kotlin/net/corda/isolated/contracts/DummyContractBackdoor.kt (100%) rename {core => core-tests}/src/test/resources/isolated.jar (100%) rename {core/src/test/resources/net/corda/core => core-tests/src/test/resources/net/corda/coretests}/transactions/isolated-4.0.jar (100%) rename {core/src/test/resources/net/corda/core => core-tests/src/test/resources/net/corda/coretests}/transactions/old-isolated.jar (100%) create mode 100644 core/src/test/README.md create mode 100644 core/src/test/kotlin/net/corda/core/internal/internalAccessTestHelpers.kt rename {core/src/test/kotlin/net/corda/core => testing/node-driver/src/main/kotlin/net/corda/testing}/flows/FlowTestsUtils.kt (83%) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index ab8839639e..3628d6937c 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -55,6 +55,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -175,6 +353,8 @@ + + diff --git a/core-tests/build.gradle b/core-tests/build.gradle new file mode 100644 index 0000000000..52cf606abe --- /dev/null +++ b/core-tests/build.gradle @@ -0,0 +1,158 @@ +apply plugin: 'kotlin' +apply plugin: 'kotlin-jpa' +apply plugin: 'net.corda.plugins.quasar-utils' +apply plugin: 'net.corda.plugins.publish-utils' +apply plugin: 'net.corda.plugins.api-scanner' + +description 'Corda core tests' + +configurations { + integrationTestCompile.extendsFrom testCompile + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly + + smokeTestCompile.extendsFrom compile + smokeTestRuntimeOnly.extendsFrom runtimeOnly +} + +sourceSets { + integrationTest { + kotlin { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir file('src/integration-test/kotlin') + } + java { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir file('src/integration-test/java') + } + } + smokeTest { + kotlin { + // We must NOT have any Node code on the classpath, so do NOT + // include the test or integrationTest dependencies here. + srcDir file('src/smoke-test/kotlin') + } + java { + srcDir file('src/smoke-test/java') + } + } +} + +processSmokeTestResources { + // Bring in the fully built corda.jar for use by NodeFactory in the smoke tests + from(project(':node:capsule').tasks['buildCordaJAR']) { + rename 'corda-(.*)', 'corda.jar' + } +} + +dependencies { + + testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" + testImplementation "junit:junit:$junit_version" + testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}" + + testCompile "commons-fileupload:commons-fileupload:$fileupload_version" + testCompile project(":core") + testCompile project(path: ':core', configuration: 'testArtifacts') + + // Guava: Google test library (collections test suite) + testCompile "com.google.guava:guava-testlib:$guava_version" + + // Bring in the MockNode infrastructure for writing protocol unit tests. + testCompile project(":node-driver") + + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + + // Hamkrest, for fluent, composable matchers + testCompile "com.natpryce:hamkrest:$hamkrest_version" + + // SLF4J: commons-logging bindings for a SLF4J back end + compile "org.slf4j:jcl-over-slf4j:$slf4j_version" + compile "org.slf4j:slf4j-api:$slf4j_version" + + // AssertJ: for fluent assertions for testing + testCompile "org.assertj:assertj-core:${assertj_version}" + + // Guava: Google utilities library. + testCompile "com.google.guava:guava:$guava_version" + + // Smoke tests do NOT have any Node code on the classpath! + smokeTestImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" + smokeTestImplementation "junit:junit:$junit_version" + + smokeTestRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}" + smokeTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}" + smokeTestRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}" + + smokeTestCompile project(':smoke-test-utils') + smokeTestCompile "org.assertj:assertj-core:${assertj_version}" + +} + +configurations { + testArtifacts.extendsFrom testRuntimeClasspath +} + +tasks.withType(Test) { + // fork a new test process for every test class + forkEvery = 10 +} + +task testJar(type: Jar) { + classifier "tests" + from sourceSets.test.output +} + +task integrationTest(type: Test) { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath +} + +task smokeTestJar(type: Jar) { + classifier 'smokeTests' + from sourceSets.smokeTest.output +} + +task smokeTest(type: Test) { + dependsOn smokeTestJar + testClassesDirs = sourceSets.smokeTest.output.classesDirs + classpath = sourceSets.smokeTest.runtimeClasspath +} + +// quasar exclusions upon agent code instrumentation at run-time +quasar { + excludePackages.addAll( + "antlr**", + "com.codahale**", + "com.fasterxml.**", + "com.github.benmanes.caffeine.**", + "com.google.**", + "com.lmax.**", + "com.zaxxer.**", + "net.bytebuddy**", + "io.github.classgraph**", + "io.netty*", + "liquibase**", + "net.i2p.crypto.**", + "nonapi.io.github.classgraph.**", + "org.apiguardian.**", + "org.bouncycastle**", + "org.codehaus.**", + "org.h2**", + "org.hibernate**", + "org.jboss.**", + "org.objenesis**", + "org.w3c.**", + "org.xml**", + "org.yaml**", + "rx**") +} + +artifacts { + testArtifacts testJar +} diff --git a/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt b/core-tests/src/smoke-test/kotlin/net/corda/coretests/NodeVersioningTest.kt similarity index 99% rename from core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt rename to core-tests/src/smoke-test/kotlin/net/corda/coretests/NodeVersioningTest.kt index 9cca6d959a..0cc4064413 100644 --- a/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt +++ b/core-tests/src/smoke-test/kotlin/net/corda/coretests/NodeVersioningTest.kt @@ -1,4 +1,4 @@ -package net.corda.core +package net.corda.coretests import co.paralleluniverse.fibers.Suspendable import net.corda.core.flows.FlowLogic diff --git a/core/src/smoke-test/kotlin/net/corda/core/cordapp/CordappSmokeTest.kt b/core-tests/src/smoke-test/kotlin/net/corda/coretests/cordapp/CordappSmokeTest.kt similarity index 97% rename from core/src/smoke-test/kotlin/net/corda/core/cordapp/CordappSmokeTest.kt rename to core-tests/src/smoke-test/kotlin/net/corda/coretests/cordapp/CordappSmokeTest.kt index 6e9cf72bff..ce9566aaec 100644 --- a/core/src/smoke-test/kotlin/net/corda/core/cordapp/CordappSmokeTest.kt +++ b/core-tests/src/smoke-test/kotlin/net/corda/coretests/cordapp/CordappSmokeTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.cordapp +package net.corda.coretests.cordapp import co.paralleluniverse.fibers.Suspendable import net.corda.core.crypto.Crypto.generateKeyPair @@ -94,7 +94,7 @@ class CordappSmokeTest { factory.create(aliceConfig).use { alice -> alice.connect(superUser).use { connectionToAlice -> val aliceIdentity = connectionToAlice.proxy.nodeInfo().legalIdentitiesAndCerts.first().party - val future = connectionToAlice.proxy.startFlow(::GatherContextsFlow, aliceIdentity).returnValue + val future = connectionToAlice.proxy.startFlow(CordappSmokeTest::GatherContextsFlow, aliceIdentity).returnValue val (sessionInitContext, sessionConfirmContext) = future.getOrThrow() val selfCordappName = selfCordapp.fileName.toString().removeSuffix(".jar") assertThat(sessionInitContext.appName).isEqualTo(selfCordappName) diff --git a/core/src/test/java/net/corda/core/contracts/AmountParsingTest.java b/core-tests/src/test/java/net/corda/coretests/contracts/AmountParsingTest.java similarity index 81% rename from core/src/test/java/net/corda/core/contracts/AmountParsingTest.java rename to core-tests/src/test/java/net/corda/coretests/contracts/AmountParsingTest.java index 1b23374ce2..359f23c15c 100644 --- a/core/src/test/java/net/corda/core/contracts/AmountParsingTest.java +++ b/core-tests/src/test/java/net/corda/coretests/contracts/AmountParsingTest.java @@ -1,5 +1,6 @@ -package net.corda.core.contracts; +package net.corda.coretests.contracts; +import net.corda.core.contracts.Amount; import org.junit.Test; import static net.corda.finance.Currencies.POUNDS; diff --git a/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java b/core-tests/src/test/java/net/corda/coretests/flows/FlowsInJavaTest.java similarity index 98% rename from core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java rename to core-tests/src/test/java/net/corda/coretests/flows/FlowsInJavaTest.java index 6dce0bb36a..a2aa12a970 100644 --- a/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java +++ b/core-tests/src/test/java/net/corda/coretests/flows/FlowsInJavaTest.java @@ -1,7 +1,8 @@ -package net.corda.core.flows; +package net.corda.coretests.flows; import co.paralleluniverse.fibers.Suspendable; import com.google.common.primitives.Primitives; +import net.corda.core.flows.*; import net.corda.core.identity.Party; import net.corda.testing.core.TestConstants; import net.corda.testing.node.MockNetwork; diff --git a/core/src/test/java/net/corda/core/flows/SerializationApiInJavaTest.java b/core-tests/src/test/java/net/corda/coretests/flows/SerializationApiInJavaTest.java similarity index 97% rename from core/src/test/java/net/corda/core/flows/SerializationApiInJavaTest.java rename to core-tests/src/test/java/net/corda/coretests/flows/SerializationApiInJavaTest.java index 9f48a7ba0a..b02f530e1a 100644 --- a/core/src/test/java/net/corda/core/flows/SerializationApiInJavaTest.java +++ b/core-tests/src/test/java/net/corda/coretests/flows/SerializationApiInJavaTest.java @@ -1,4 +1,4 @@ -package net.corda.core.flows; +package net.corda.coretests.flows; import net.corda.core.serialization.SerializationDefaults; import net.corda.core.serialization.SerializationFactory; diff --git a/core/src/test/java/net/corda/core/schemas/BadSchemaJavaV1.java b/core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaJavaV1.java similarity index 86% rename from core/src/test/java/net/corda/core/schemas/BadSchemaJavaV1.java rename to core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaJavaV1.java index 63178184d9..92bb0c588e 100644 --- a/core/src/test/java/net/corda/core/schemas/BadSchemaJavaV1.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaJavaV1.java @@ -1,4 +1,7 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; + +import net.corda.core.schemas.MappedSchema; +import net.corda.core.schemas.PersistentState; import javax.persistence.*; import java.util.Arrays; diff --git a/core/src/test/java/net/corda/core/schemas/BadSchemaNoGetterJavaV1.java b/core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaNoGetterJavaV1.java similarity index 83% rename from core/src/test/java/net/corda/core/schemas/BadSchemaNoGetterJavaV1.java rename to core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaNoGetterJavaV1.java index 36534df566..bee292ee53 100644 --- a/core/src/test/java/net/corda/core/schemas/BadSchemaNoGetterJavaV1.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/BadSchemaNoGetterJavaV1.java @@ -1,4 +1,7 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; + +import net.corda.core.schemas.MappedSchema; +import net.corda.core.schemas.PersistentState; import javax.persistence.*; import java.util.Arrays; diff --git a/core/src/test/java/net/corda/core/schemas/GoodSchemaJavaV1.java b/core-tests/src/test/java/net/corda/coretests/schemas/GoodSchemaJavaV1.java similarity index 79% rename from core/src/test/java/net/corda/core/schemas/GoodSchemaJavaV1.java rename to core-tests/src/test/java/net/corda/coretests/schemas/GoodSchemaJavaV1.java index a7b507b2b0..e37db3b26e 100644 --- a/core/src/test/java/net/corda/core/schemas/GoodSchemaJavaV1.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/GoodSchemaJavaV1.java @@ -1,4 +1,7 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; + +import net.corda.core.schemas.MappedSchema; +import net.corda.core.schemas.PersistentState; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/core/src/test/java/net/corda/core/schemas/PoliteSchemaJavaV1.java b/core-tests/src/test/java/net/corda/coretests/schemas/PoliteSchemaJavaV1.java similarity index 86% rename from core/src/test/java/net/corda/core/schemas/PoliteSchemaJavaV1.java rename to core-tests/src/test/java/net/corda/coretests/schemas/PoliteSchemaJavaV1.java index e1bd6b1970..31327a3d5e 100644 --- a/core/src/test/java/net/corda/core/schemas/PoliteSchemaJavaV1.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/PoliteSchemaJavaV1.java @@ -1,4 +1,7 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; + +import net.corda.core.schemas.MappedSchema; +import net.corda.core.schemas.PersistentState; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/core/src/test/java/net/corda/core/schemas/TestJavaSchemaFamily.java b/core-tests/src/test/java/net/corda/coretests/schemas/TestJavaSchemaFamily.java similarity index 51% rename from core/src/test/java/net/corda/core/schemas/TestJavaSchemaFamily.java rename to core-tests/src/test/java/net/corda/coretests/schemas/TestJavaSchemaFamily.java index c2131097f3..20c7dfb60a 100644 --- a/core/src/test/java/net/corda/core/schemas/TestJavaSchemaFamily.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/TestJavaSchemaFamily.java @@ -1,4 +1,4 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; public class TestJavaSchemaFamily { } diff --git a/core/src/test/java/net/corda/core/schemas/TrickySchemaJavaV1.java b/core-tests/src/test/java/net/corda/coretests/schemas/TrickySchemaJavaV1.java similarity index 87% rename from core/src/test/java/net/corda/core/schemas/TrickySchemaJavaV1.java rename to core-tests/src/test/java/net/corda/coretests/schemas/TrickySchemaJavaV1.java index 1d3926440b..8a3e943d71 100644 --- a/core/src/test/java/net/corda/core/schemas/TrickySchemaJavaV1.java +++ b/core-tests/src/test/java/net/corda/coretests/schemas/TrickySchemaJavaV1.java @@ -1,4 +1,7 @@ -package net.corda.core.schemas; +package net.corda.coretests.schemas; + +import net.corda.core.schemas.MappedSchema; +import net.corda.core.schemas.PersistentState; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/core/src/test/kotlin/net/corda/core/contracts/AmountTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/contracts/AmountTests.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/contracts/AmountTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/contracts/AmountTests.kt index f35931bb9f..8025913133 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/AmountTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/contracts/AmountTests.kt @@ -1,6 +1,10 @@ -package net.corda.core.contracts +package net.corda.coretests.contracts +import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount.Companion.sumOrZero +import net.corda.core.contracts.AmountTransfer +import net.corda.core.contracts.SourceAndAmount +import net.corda.core.contracts.TokenizableAssetInfo import net.corda.finance.* import org.junit.Test import java.math.BigDecimal diff --git a/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ConstraintsPropagationTests.kt similarity index 95% rename from core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/contracts/ConstraintsPropagationTests.kt index 3496e66fe2..902df821c8 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ConstraintsPropagationTests.kt @@ -1,8 +1,9 @@ -package net.corda.core.contracts +package net.corda.coretests.contracts import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.whenever +import net.corda.core.contracts.* import net.corda.core.crypto.Crypto import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SecureHash.Companion.allOnesHash @@ -11,7 +12,6 @@ import net.corda.core.crypto.SignableData import net.corda.core.crypto.SignatureMetadata import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name -import net.corda.core.internal.AttachmentWithContext import net.corda.core.internal.canBeTransitionedFrom import net.corda.core.internal.inputStream import net.corda.core.internal.toPath @@ -33,7 +33,6 @@ import net.corda.testing.core.internal.JarSignatureTestUtils.generateKey import net.corda.testing.core.internal.SelfCleaningDir import net.corda.testing.internal.MockCordappProvider import net.corda.testing.node.MockServices -import net.corda.testing.node.internal.MockNetworkParametersStorage import net.corda.testing.node.ledger import org.junit.* import java.security.PublicKey @@ -56,7 +55,7 @@ class ConstraintsPropagationTests { val BOB = TestIdentity(CordaX500Name("BOB", "London", "GB")) val BOB_PARTY get() = BOB.party val BOB_PUBKEY get() = BOB.publicKey - const val noPropagationContractClassName = "net.corda.core.contracts.NoPropagationContract" + const val noPropagationContractClassName = "net.corda.coretests.contracts.NoPropagationContract" const val propagatingContractClassName = "net.corda.core.contracts.PropagationContract" private lateinit var keyStoreDir: SelfCleaningDir @@ -102,14 +101,14 @@ class ConstraintsPropagationTests { ledgerServices.ledger(DUMMY_NOTARY) { ledgerServices.recordTransaction(transaction { attachment(Cash.PROGRAM_ID, SecureHash.allOnesHash) - output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) + output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Issue()) verifies() }) transaction { attachment(Cash.PROGRAM_ID, SecureHash.allOnesHash) input("c1") - output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) + output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Move()) verifies() } @@ -162,7 +161,7 @@ class ConstraintsPropagationTests { ledgerServices.ledger(DUMMY_NOTARY) { transaction { attachment(Cash.PROGRAM_ID, SecureHash.zeroHash) - output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) + output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Issue()) verifies() } @@ -170,7 +169,7 @@ class ConstraintsPropagationTests { transaction { attachment(Cash.PROGRAM_ID, SecureHash.allOnesHash) input("c1") - output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) + output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(allOnesHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Move()) verifies() } @@ -183,7 +182,7 @@ class ConstraintsPropagationTests { ledgerServices.ledger(DUMMY_NOTARY) { ledgerServices.recordTransaction(transaction { attachment(Cash.PROGRAM_ID, SecureHash.zeroHash) - output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) + output(Cash.PROGRAM_ID, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), ALICE_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Issue()) verifies() }) @@ -223,7 +222,7 @@ class ConstraintsPropagationTests { transaction { attachment(Cash.PROGRAM_ID, SecureHash.zeroHash) input("c1") - output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) + output(Cash.PROGRAM_ID, "c2", DUMMY_NOTARY, null, HashAttachmentConstraint(zeroHash), Cash.State(1000.POUNDS `issued by` ALICE_PARTY.ref(1), BOB_PARTY)) command(ALICE_PUBKEY, Cash.Commands.Move()) verifies() } @@ -278,7 +277,7 @@ class ConstraintsPropagationTests { ledgerServices.ledger(DUMMY_NOTARY) { ledgerServices.recordTransaction(transaction { attachment(noPropagationContractClassName, SecureHash.zeroHash) - output(noPropagationContractClassName, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(SecureHash.zeroHash), NoPropagationContractState()) + output(noPropagationContractClassName, "c1", DUMMY_NOTARY, null, HashAttachmentConstraint(zeroHash), NoPropagationContractState()) command(ALICE_PUBKEY, NoPropagationContract.Create()) verifies() }) @@ -365,7 +364,10 @@ class ConstraintsPropagationTests { assertFalse(AlwaysAcceptAttachmentConstraint.canBeTransitionedFrom(HashAttachmentConstraint(SecureHash.randomSHA256()), attachment)) // Fail when encounter a AutomaticPlaceholderConstraint - assertFailsWith { HashAttachmentConstraint(SecureHash.randomSHA256()).canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment) } + assertFailsWith { + HashAttachmentConstraint(SecureHash.randomSHA256()) + .canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment) + } assertFailsWith { AutomaticPlaceholderConstraint.canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment) } } diff --git a/core/src/test/kotlin/net/corda/core/contracts/ContractHierarchyTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractHierarchyTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/contracts/ContractHierarchyTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractHierarchyTest.kt index c2e5aa6c1b..f8ea216011 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/ContractHierarchyTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractHierarchyTest.kt @@ -1,6 +1,7 @@ -package net.corda.core.contracts +package net.corda.coretests.contracts import co.paralleluniverse.fibers.Suspendable +import net.corda.core.contracts.* import net.corda.core.flows.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party diff --git a/core/src/test/kotlin/net/corda/core/contracts/ContractsDSLTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/contracts/ContractsDSLTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt index 294aebd427..bbf47ac034 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/ContractsDSLTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt @@ -1,5 +1,6 @@ -package net.corda.core.contracts +package net.corda.coretests.contracts +import net.corda.core.contracts.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -57,7 +58,7 @@ class RequireSingleCommandTests(private val testFunction: (Collection(SecureHash.sha256("1"), SecureHash.sha256("5"), SecureHash.sha256("0"), SecureHash.sha256("19"))) // First leaf. - assertEquals(0, pmt.leafIndex(SecureHash.sha256("0"))) + assertEquals(0, pmt.accessLeafIndex(SecureHash.sha256("0"))) // Second leaf. - assertEquals(1, pmt.leafIndex(SecureHash.sha256("1"))) + assertEquals(1, pmt.accessLeafIndex(SecureHash.sha256("1"))) // A random leaf. - assertEquals(5, pmt.leafIndex(SecureHash.sha256("5"))) + assertEquals(5, pmt.accessLeafIndex(SecureHash.sha256("5"))) // The last leaf. - assertEquals(19, pmt.leafIndex(SecureHash.sha256("19"))) + assertEquals(19, pmt.accessLeafIndex(SecureHash.sha256("19"))) // The provided hash is not in the tree. - assertFailsWith { pmt.leafIndex(SecureHash.sha256("10")) } + assertFailsWith { pmt.accessLeafIndex(SecureHash.sha256("10")) } // The provided hash is not in the tree (using a leaf that didn't exist in the original Merkle tree). - assertFailsWith { pmt.leafIndex(SecureHash.sha256("30")) } + assertFailsWith { pmt.accessLeafIndex(SecureHash.sha256("30")) } val pmtFirstElementOnly = PartialMerkleTree.build(merkleTree, listOf(SecureHash.sha256("0"))) - assertEquals(0, pmtFirstElementOnly.leafIndex(SecureHash.sha256("0"))) + assertEquals(0, pmtFirstElementOnly.accessLeafIndex(SecureHash.sha256("0"))) // The provided hash is not in the tree. - assertFailsWith { pmtFirstElementOnly.leafIndex(SecureHash.sha256("10")) } + assertFailsWith { pmtFirstElementOnly.accessLeafIndex(SecureHash.sha256("10")) } val pmtLastElementOnly = PartialMerkleTree.build(merkleTree, listOf(SecureHash.sha256("19"))) - assertEquals(19, pmtLastElementOnly.leafIndex(SecureHash.sha256("19"))) + assertEquals(19, pmtLastElementOnly.accessLeafIndex(SecureHash.sha256("19"))) // The provided hash is not in the tree. - assertFailsWith { pmtLastElementOnly.leafIndex(SecureHash.sha256("10")) } + assertFailsWith { pmtLastElementOnly.accessLeafIndex(SecureHash.sha256("10")) } val pmtOneElement = PartialMerkleTree.build(merkleTree, listOf(SecureHash.sha256("5"))) - assertEquals(5, pmtOneElement.leafIndex(SecureHash.sha256("5"))) + assertEquals(5, pmtOneElement.accessLeafIndex(SecureHash.sha256("5"))) // The provided hash is not in the tree. - assertFailsWith { pmtOneElement.leafIndex(SecureHash.sha256("10")) } + assertFailsWith { pmtOneElement.accessLeafIndex(SecureHash.sha256("10")) } val pmtAllIncluded = PartialMerkleTree.build(merkleTree, sampleLeaves) - for (i in 0..19) assertEquals(i, pmtAllIncluded.leafIndex(SecureHash.sha256(i.toString()))) + for (i in 0..19) assertEquals(i, pmtAllIncluded.accessLeafIndex(SecureHash.sha256(i.toString()))) // The provided hash is not in the tree (using a leaf that didn't exist in the original Merkle tree). - assertFailsWith { pmtAllIncluded.leafIndex(SecureHash.sha256("30")) } + assertFailsWith { pmtAllIncluded.accessLeafIndex(SecureHash.sha256("30")) } } @Test diff --git a/core/src/test/kotlin/net/corda/core/crypto/SignedDataTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/crypto/SignedDataTest.kt similarity index 89% rename from core/src/test/kotlin/net/corda/core/crypto/SignedDataTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/crypto/SignedDataTest.kt index b7310756d4..0d5e7fb361 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/SignedDataTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/crypto/SignedDataTest.kt @@ -1,5 +1,8 @@ -package net.corda.core.crypto +package net.corda.coretests.crypto +import net.corda.core.crypto.SignedData +import net.corda.core.crypto.generateKeyPair +import net.corda.core.crypto.sign import net.corda.core.serialization.SerializedBytes import net.corda.core.serialization.serialize import net.corda.testing.core.SerializationEnvironmentRule diff --git a/core/src/test/kotlin/net/corda/core/crypto/TransactionSignatureTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/crypto/TransactionSignatureTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/crypto/TransactionSignatureTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/crypto/TransactionSignatureTest.kt index 4958d58de6..e3a38ee443 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/TransactionSignatureTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/crypto/TransactionSignatureTest.kt @@ -1,5 +1,6 @@ -package net.corda.core.crypto +package net.corda.coretests.crypto +import net.corda.core.crypto.* import net.corda.testing.core.SerializationEnvironmentRule import org.junit.Rule import org.junit.Test diff --git a/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/crypto/X509NameConstraintsTest.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/crypto/X509NameConstraintsTest.kt index acb2f014b8..61bac911f2 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/crypto/X509NameConstraintsTest.kt @@ -1,5 +1,6 @@ -package net.corda.core.crypto +package net.corda.coretests.crypto +import net.corda.core.crypto.Crypto import net.corda.core.identity.CordaX500Name import net.corda.nodeapi.internal.crypto.CertificateType import net.corda.nodeapi.internal.crypto.X509KeyStore diff --git a/core/src/test/kotlin/net/corda/core/flows/AttachmentTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/AttachmentTests.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/flows/AttachmentTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/AttachmentTests.kt index 1e09bf261a..efd8dcb91d 100644 --- a/core/src/test/kotlin/net/corda/core/flows/AttachmentTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/AttachmentTests.kt @@ -1,11 +1,14 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable import com.natpryce.hamkrest.* 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 +import net.corda.core.flows.FlowLogic +import net.corda.core.flows.FlowSession +import net.corda.core.flows.InitiatedBy +import net.corda.core.flows.InitiatingFlow import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.internal.FetchAttachmentsFlow diff --git a/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/CollectSignaturesFlowTests.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/CollectSignaturesFlowTests.kt index 376b0ced1b..fa9ba22d64 100644 --- a/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/CollectSignaturesFlowTests.kt @@ -1,12 +1,16 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable import com.natpryce.hamkrest.assertion.assertThat import net.corda.core.contracts.Command import net.corda.core.contracts.StateAndContract import net.corda.core.contracts.requireThat -import net.corda.core.flows.mixins.WithContracts import net.corda.core.identity.* +import net.corda.core.flows.* +import net.corda.core.identity.CordaX500Name +import net.corda.core.identity.Party +import net.corda.core.identity.excludeHostNode +import net.corda.core.identity.groupAbstractPartyByWellKnownParty import net.corda.core.node.services.IdentityService import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder diff --git a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowRPCTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowRPCTest.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowRPCTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowRPCTest.kt index 56c16f5652..4af71df2d1 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowRPCTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowRPCTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.flows +package net.corda.coretests.flows import com.natpryce.hamkrest.and import com.natpryce.hamkrest.anything @@ -8,8 +8,7 @@ import com.natpryce.hamkrest.isA import net.corda.core.CordaRuntimeException import net.corda.core.contracts.ContractState import net.corda.core.contracts.StateAndRef -import net.corda.core.flows.mixins.WithContracts -import net.corda.core.flows.mixins.WithFinality +import net.corda.core.flows.ContractUpgradeFlow import net.corda.core.messaging.CordaRPCOps import net.corda.core.transactions.ContractUpgradeLedgerTransaction import net.corda.core.transactions.SignedTransaction diff --git a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowTest.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowTest.kt index 94df3054e3..b391e5cce2 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/ContractUpgradeFlowTest.kt @@ -1,10 +1,9 @@ -package net.corda.core.flows +package net.corda.coretests.flows import com.natpryce.hamkrest.* 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 +import net.corda.core.flows.UnexpectedFlowEndException import net.corda.core.identity.AbstractParty import net.corda.core.internal.Emoji import net.corda.core.transactions.ContractUpgradeLedgerTransaction @@ -168,7 +167,7 @@ class ContractUpgradeFlowTest : WithContracts, WithFinality { override fun withNewOwner(newOwner: AbstractParty) = CommandAndState(Cash.Commands.Move(), copy(owners = listOf(newOwner))) } - override fun upgrade(state: Cash.State) = CashV2.State(state.amount.times(1000), listOf(state.owner)) + override fun upgrade(state: Cash.State) = State(state.amount.times(1000), listOf(state.owner)) override fun verify(tx: LedgerTransaction) {} } diff --git a/core/src/test/kotlin/net/corda/core/flows/FastThreadLocalTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/FastThreadLocalTest.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/flows/FastThreadLocalTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/FastThreadLocalTest.kt index 701f02cc75..a11b336081 100644 --- a/core/src/test/kotlin/net/corda/core/flows/FastThreadLocalTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/FastThreadLocalTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Fiber import co.paralleluniverse.fibers.FiberExecutorScheduler diff --git a/core/src/test/kotlin/net/corda/core/flows/FinalityFlowTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/FinalityFlowTests.kt similarity index 96% rename from core/src/test/kotlin/net/corda/core/flows/FinalityFlowTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/FinalityFlowTests.kt index dfcfcba4a8..5285e6b46c 100644 --- a/core/src/test/kotlin/net/corda/core/flows/FinalityFlowTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/FinalityFlowTests.kt @@ -1,9 +1,9 @@ -package net.corda.core.flows +package net.corda.coretests.flows import com.natpryce.hamkrest.and 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.flows.FinalityFlow +import net.corda.coretests.flows.WithFinality.FinalityInvoker import net.corda.core.identity.Party import net.corda.core.internal.cordapp.CordappResolver import net.corda.core.transactions.SignedTransaction diff --git a/core/src/test/kotlin/net/corda/core/flows/ReceiveAllFlowTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveAllFlowTests.kt similarity index 95% rename from core/src/test/kotlin/net/corda/core/flows/ReceiveAllFlowTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveAllFlowTests.kt index 48fccc8839..1f83302dd3 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ReceiveAllFlowTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveAllFlowTests.kt @@ -1,12 +1,16 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable import com.natpryce.hamkrest.assertion.assertThat -import net.corda.core.flows.mixins.WithMockNet +import net.corda.core.flows.FlowLogic +import net.corda.core.flows.InitiatingFlow import net.corda.core.identity.Party import net.corda.core.utilities.UntrustworthyData import net.corda.core.utilities.unwrap import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.from +import net.corda.testing.flows.receiveAll +import net.corda.testing.flows.registerCordappFlowFactory import net.corda.testing.internal.matchers.flow.willReturn import net.corda.testing.node.internal.InternalMockNetwork import net.corda.testing.node.internal.TestStartedNode diff --git a/core/src/test/kotlin/net/corda/core/flows/ReceiveFinalityFlowTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveFinalityFlowTest.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/flows/ReceiveFinalityFlowTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveFinalityFlowTest.kt index f3eeb05421..395ff5ad19 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ReceiveFinalityFlowTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReceiveFinalityFlowTest.kt @@ -1,7 +1,8 @@ -package net.corda.core.flows +package net.corda.coretests.flows import net.corda.core.contracts.FungibleAsset import net.corda.core.contracts.TransactionVerificationException +import net.corda.core.flows.StateMachineRunId import net.corda.core.node.services.queryBy import net.corda.core.toFuture import net.corda.core.utilities.OpaqueBytes diff --git a/core/src/test/kotlin/net/corda/core/flows/ReferencedStatesFlowTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReferencedStatesFlowTests.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/flows/ReferencedStatesFlowTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/ReferencedStatesFlowTests.kt index d85ed222b1..8c7b9bc1dd 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ReferencedStatesFlowTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/ReferencedStatesFlowTests.kt @@ -1,7 +1,8 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable import net.corda.core.contracts.* +import net.corda.core.flows.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.core.node.StatesToRecord diff --git a/core/src/test/kotlin/net/corda/core/flows/TestNoSecurityDataVendingFlow.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/TestNoSecurityDataVendingFlow.kt similarity index 87% rename from core/src/test/kotlin/net/corda/core/flows/TestNoSecurityDataVendingFlow.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/TestNoSecurityDataVendingFlow.kt index 94181067e8..c203e64d5b 100644 --- a/core/src/test/kotlin/net/corda/core/flows/TestNoSecurityDataVendingFlow.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/TestNoSecurityDataVendingFlow.kt @@ -1,6 +1,8 @@ -package net.corda.core.flows +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable +import net.corda.core.flows.DataVendingFlow +import net.corda.core.flows.FlowSession import net.corda.core.internal.FetchDataFlow import net.corda.core.internal.RetrieveAnyTransactionPayload import net.corda.core.utilities.UntrustworthyData diff --git a/core/src/test/kotlin/net/corda/core/flows/mixins/WithContracts.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithContracts.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/flows/mixins/WithContracts.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/WithContracts.kt index 7206b1ce76..4fe288449a 100644 --- a/core/src/test/kotlin/net/corda/core/flows/mixins/WithContracts.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithContracts.kt @@ -1,4 +1,4 @@ -package net.corda.core.flows.mixins +package net.corda.coretests.flows import net.corda.core.contracts.ContractState import net.corda.core.contracts.PartyAndReference diff --git a/core/src/test/kotlin/net/corda/core/flows/mixins/WithFinality.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithFinality.kt similarity index 94% rename from core/src/test/kotlin/net/corda/core/flows/mixins/WithFinality.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/WithFinality.kt index 45a2363151..5e1daa8a09 100644 --- a/core/src/test/kotlin/net/corda/core/flows/mixins/WithFinality.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithFinality.kt @@ -1,4 +1,4 @@ -package net.corda.core.flows.mixins +package net.corda.coretests.flows import co.paralleluniverse.fibers.Suspendable import com.natpryce.hamkrest.MatchResult @@ -25,7 +25,7 @@ interface WithFinality : WithMockNet { } fun CordaRPCOps.finalise(stx: SignedTransaction, vararg recipients: Party): FlowHandle { - return startFlow(::FinalityInvoker, stx, recipients.toSet(), emptySet()).andRunNetwork() + return startFlow(WithFinality::FinalityInvoker, stx, recipients.toSet(), emptySet()).andRunNetwork() } //endregion diff --git a/core/src/test/kotlin/net/corda/core/flows/mixins/WithMockNet.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithMockNet.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/flows/mixins/WithMockNet.kt rename to core-tests/src/test/kotlin/net/corda/coretests/flows/WithMockNet.kt index 02c70ecc3f..2fa84b7486 100644 --- a/core/src/test/kotlin/net/corda/core/flows/mixins/WithMockNet.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/WithMockNet.kt @@ -1,4 +1,4 @@ -package net.corda.core.flows.mixins +package net.corda.coretests.flows import com.natpryce.hamkrest.* import net.corda.core.contracts.ContractState diff --git a/core/src/test/kotlin/net/corda/core/identity/PartyAndCertificateTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyAndCertificateTest.kt similarity index 93% rename from core/src/test/kotlin/net/corda/core/identity/PartyAndCertificateTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyAndCertificateTest.kt index f64b243de5..e00693f6cc 100644 --- a/core/src/test/kotlin/net/corda/core/identity/PartyAndCertificateTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyAndCertificateTest.kt @@ -1,8 +1,11 @@ -package net.corda.core.identity +package net.corda.coretests.indentity import com.google.common.jimfs.Configuration.unix import com.google.common.jimfs.Jimfs import net.corda.core.crypto.entropyToKeyPair +import net.corda.core.identity.CordaX500Name +import net.corda.core.identity.Party +import net.corda.core.identity.PartyAndCertificate import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize import net.corda.nodeapi.internal.crypto.X509KeyStore diff --git a/core/src/test/kotlin/net/corda/core/identity/PartyTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyTest.kt similarity index 82% rename from core/src/test/kotlin/net/corda/core/identity/PartyTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyTest.kt index 84d33b9e3c..73a1652535 100644 --- a/core/src/test/kotlin/net/corda/core/identity/PartyTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/indentity/PartyTest.kt @@ -1,6 +1,9 @@ -package net.corda.core.identity +package net.corda.coretests.indentity import net.corda.core.crypto.entropyToKeyPair +import net.corda.core.identity.AbstractParty +import net.corda.core.identity.AnonymousParty +import net.corda.core.identity.Party import net.corda.testing.core.ALICE_NAME import org.junit.Test import java.math.BigInteger diff --git a/core/src/test/kotlin/net/corda/core/internal/CertRoleTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/internal/CertRoleTests.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/internal/CertRoleTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/internal/CertRoleTests.kt index 49653648de..d2e9873913 100644 --- a/core/src/test/kotlin/net/corda/core/internal/CertRoleTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/internal/CertRoleTests.kt @@ -1,6 +1,7 @@ -package net.corda.core.internal +package net.corda.coretests.internal import net.corda.core.crypto.Crypto +import net.corda.core.internal.CertRole import net.corda.nodeapi.internal.crypto.CertificateType import net.corda.nodeapi.internal.crypto.X509Utilities import org.bouncycastle.asn1.ASN1Integer diff --git a/core/src/test/kotlin/net/corda/core/internal/NetworkParametersResolutionTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/internal/NetworkParametersResolutionTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/internal/NetworkParametersResolutionTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/internal/NetworkParametersResolutionTest.kt index 9ba69574bf..be15f8c450 100644 --- a/core/src/test/kotlin/net/corda/core/internal/NetworkParametersResolutionTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/internal/NetworkParametersResolutionTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.internal +package net.corda.coretests.internal import net.corda.core.contracts.TransactionVerificationException import net.corda.core.crypto.Crypto @@ -6,6 +6,8 @@ import net.corda.core.crypto.SignableData import net.corda.core.crypto.SignatureMetadata import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party +import net.corda.core.internal.NetworkParametersStorage +import net.corda.core.internal.createComponentGroups import net.corda.core.node.NetworkParameters import net.corda.core.node.NotaryInfo import net.corda.core.node.ServiceHub diff --git a/core/src/test/kotlin/net/corda/core/internal/ResolveTransactionsFlowTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/internal/ResolveTransactionsFlowTest.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/internal/ResolveTransactionsFlowTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/internal/ResolveTransactionsFlowTest.kt index 5319c332e9..48f5798983 100644 --- a/core/src/test/kotlin/net/corda/core/internal/ResolveTransactionsFlowTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/internal/ResolveTransactionsFlowTest.kt @@ -1,15 +1,19 @@ -package net.corda.core.internal +package net.corda.coretests.internal import co.paralleluniverse.fibers.Suspendable import net.corda.core.crypto.SecureHash import net.corda.core.flows.* import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party +import net.corda.core.internal.FetchDataFlow +import net.corda.core.internal.ResolveTransactionsFlow +import net.corda.core.internal.TESTDSL_UPLOADER import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.NonEmptySet import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.sequence import net.corda.core.utilities.unwrap +import net.corda.coretests.flows.TestNoSecurityDataVendingFlow import net.corda.testing.contracts.DummyContract import net.corda.testing.core.singleIdentity import net.corda.testing.node.MockNetwork diff --git a/core/src/test/kotlin/net/corda/core/internal/TopologicalSortTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/internal/TopologicalSortTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/internal/TopologicalSortTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/internal/TopologicalSortTest.kt index 556070f2c6..bb335449fa 100644 --- a/core/src/test/kotlin/net/corda/core/internal/TopologicalSortTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/internal/TopologicalSortTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.internal +package net.corda.coretests.internal import net.corda.client.mock.Generator import net.corda.core.contracts.* @@ -8,6 +8,7 @@ import net.corda.core.crypto.TransactionSignature import net.corda.core.crypto.sign import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party +import net.corda.core.internal.topologicalSort import net.corda.core.serialization.serialize import net.corda.core.transactions.CoreTransaction import net.corda.core.transactions.SignedTransaction diff --git a/core/src/test/kotlin/net/corda/core/node/NetworkParametersTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/node/NetworkParametersTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/node/NetworkParametersTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/node/NetworkParametersTest.kt index 939763db56..b74749d157 100644 --- a/core/src/test/kotlin/net/corda/core/node/NetworkParametersTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/node/NetworkParametersTest.kt @@ -1,9 +1,11 @@ -package net.corda.core.node +package net.corda.coretests.node import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.whenever import net.corda.core.crypto.generateKeyPair import net.corda.core.internal.getPackageOwnerOf +import net.corda.core.node.NetworkParameters +import net.corda.core.node.NotaryInfo import net.corda.core.node.services.AttachmentId import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.days diff --git a/core/src/test/kotlin/net/corda/core/node/NodeInfoTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/node/NodeInfoTests.kt similarity index 95% rename from core/src/test/kotlin/net/corda/core/node/NodeInfoTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/node/NodeInfoTests.kt index b79744466c..fd4c3a66d0 100644 --- a/core/src/test/kotlin/net/corda/core/node/NodeInfoTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/node/NodeInfoTests.kt @@ -1,5 +1,6 @@ -package net.corda.core.node +package net.corda.coretests.node +import net.corda.core.node.NodeInfo import net.corda.core.utilities.NetworkHostAndPort import net.corda.testing.core.TestIdentity import net.corda.testing.core.getTestPartyAndCertificate diff --git a/core/src/test/kotlin/net/corda/core/node/VaultUpdateTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/node/VaultUpdateTests.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/node/VaultUpdateTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/node/VaultUpdateTests.kt index d56bdfef57..ed0108c48a 100644 --- a/core/src/test/kotlin/net/corda/core/node/VaultUpdateTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/node/VaultUpdateTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.node +package net.corda.coretests.node import net.corda.core.contracts.* import net.corda.core.crypto.SecureHash @@ -14,7 +14,7 @@ import kotlin.test.assertFailsWith class VaultUpdateTests { private companion object { - const val DUMMY_PROGRAM_ID = "net.corda.core.node.VaultUpdateTests\$DummyContract" + const val DUMMY_PROGRAM_ID = "net.corda.coretests.node.VaultUpdateTests\$DummyContract" val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party val emptyUpdate = Vault.Update(emptySet(), emptySet(), type = Vault.UpdateType.GENERAL, references = emptySet()) } diff --git a/core/src/test/kotlin/net/corda/core/schemas/MappedSchemasCrossReferenceDetectionTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/schemas/MappedSchemasCrossReferenceDetectionTests.kt similarity index 89% rename from core/src/test/kotlin/net/corda/core/schemas/MappedSchemasCrossReferenceDetectionTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/schemas/MappedSchemasCrossReferenceDetectionTests.kt index e194d8c3dd..1d6b0ef145 100644 --- a/core/src/test/kotlin/net/corda/core/schemas/MappedSchemasCrossReferenceDetectionTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/schemas/MappedSchemasCrossReferenceDetectionTests.kt @@ -1,7 +1,9 @@ -package net.corda.core.schemas +package net.corda.coretests.schemas +import net.corda.core.schemas.MappedSchema import net.corda.core.schemas.MappedSchemaValidator.fieldsFromOtherMappedSchema import net.corda.core.schemas.MappedSchemaValidator.methodsFromOtherMappedSchema +import net.corda.core.schemas.PersistentState import net.corda.finance.schemas.CashSchema import org.assertj.core.api.Assertions.assertThat import org.junit.Test @@ -9,7 +11,7 @@ import javax.persistence.* class MappedSchemasCrossReferenceDetectionTests { - object GoodSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(State::class.java)) { + object GoodSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(GoodSchema.State::class.java)) { @Entity class State( @Column @@ -17,7 +19,7 @@ class MappedSchemasCrossReferenceDetectionTests { ) : PersistentState() } - object BadSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(State::class.java)) { + object BadSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(BadSchema.State::class.java)) { @Entity class State( @Column @@ -30,7 +32,7 @@ class MappedSchemasCrossReferenceDetectionTests { ) : PersistentState() } - object TrickySchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(State::class.java)) { + object TrickySchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(TrickySchema.State::class.java)) { @Entity class State( @Column @@ -41,7 +43,7 @@ class MappedSchemasCrossReferenceDetectionTests { ) : PersistentState() } - object PoliteSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(State::class.java)) { + object PoliteSchema : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(PoliteSchema.State::class.java)) { @Entity class State( @Column diff --git a/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/serialization/AttachmentSerializationTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/serialization/AttachmentSerializationTest.kt index 72619fb2de..d4f43f2156 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/serialization/AttachmentSerializationTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.serialization +package net.corda.coretests.serialization import co.paralleluniverse.fibers.Suspendable import net.corda.core.contracts.Attachment @@ -9,11 +9,13 @@ import net.corda.core.internal.FetchAttachmentsFlow import net.corda.core.internal.FetchDataFlow import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.unwrap +import net.corda.coretests.flows.TestNoSecurityDataVendingFlow import net.corda.node.services.persistence.NodeAttachmentService import net.corda.nodeapi.internal.persistence.currentDBSession import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.registerCordappFlowFactory import net.corda.testing.node.internal.InternalMockNetwork import net.corda.testing.node.internal.InternalMockNodeParameters import net.corda.testing.node.internal.TestStartedNode diff --git a/core/src/test/kotlin/net/corda/core/serialization/CommandsSerializationTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/serialization/CommandsSerializationTests.kt similarity index 81% rename from core/src/test/kotlin/net/corda/core/serialization/CommandsSerializationTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/serialization/CommandsSerializationTests.kt index 64c30bdf8c..7b236e14ca 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/CommandsSerializationTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/serialization/CommandsSerializationTests.kt @@ -1,5 +1,7 @@ -package net.corda.core.serialization +package net.corda.coretests.serialization +import net.corda.core.serialization.deserialize +import net.corda.core.serialization.serialize import net.corda.finance.contracts.CommercialPaper import net.corda.finance.contracts.asset.Cash import net.corda.testing.core.SerializationEnvironmentRule diff --git a/core/src/test/kotlin/net/corda/core/serialization/NotaryExceptionSerializationTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/serialization/NotaryExceptionSerializationTest.kt similarity index 89% rename from core/src/test/kotlin/net/corda/core/serialization/NotaryExceptionSerializationTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/serialization/NotaryExceptionSerializationTest.kt index c0a9a642f6..5bb7317ca1 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/NotaryExceptionSerializationTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/serialization/NotaryExceptionSerializationTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.serialization +package net.corda.coretests.serialization import net.corda.core.contracts.StateRef import net.corda.core.crypto.SecureHash @@ -6,6 +6,8 @@ import net.corda.core.crypto.sha256 import net.corda.core.flows.NotaryError import net.corda.core.flows.NotaryException import net.corda.core.flows.StateConsumptionDetails +import net.corda.core.serialization.deserialize +import net.corda.core.serialization.serialize import net.corda.testing.core.SerializationEnvironmentRule import org.junit.Rule import org.junit.Test diff --git a/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/serialization/TransactionSerializationTests.kt similarity index 92% rename from core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/serialization/TransactionSerializationTests.kt index 1b5ea3dc37..27caa404ab 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/serialization/TransactionSerializationTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.serialization +package net.corda.coretests.serialization import com.nhaarman.mockito_kotlin.mock import net.corda.core.contracts.* @@ -6,6 +6,8 @@ import net.corda.core.crypto.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.node.NotaryInfo +import net.corda.core.serialization.deserialize +import net.corda.core.serialization.serialize import net.corda.core.transactions.* import net.corda.core.utilities.seconds import net.corda.finance.POUNDS @@ -39,7 +41,7 @@ class TransactionSerializationTests { @Rule @JvmField val testSerialization = SerializationEnvironmentRule() - private val TEST_CASH_PROGRAM_ID = "net.corda.core.serialization.TransactionSerializationTests\$TestCash" + private val TEST_CASH_PROGRAM_ID = "net.corda.coretests.serialization.TransactionSerializationTests\$TestCash" class TestCash : Contract { override fun verify(tx: LedgerTransaction) { @@ -70,11 +72,11 @@ class TransactionSerializationTests { val outputState = TransactionState(TestCash.State(depositRef, 600.POUNDS, MEGA_CORP), TEST_CASH_PROGRAM_ID, DUMMY_NOTARY) val changeState = TransactionState(TestCash.State(depositRef, 400.POUNDS, MEGA_CORP), TEST_CASH_PROGRAM_ID, DUMMY_NOTARY) - val megaCorpServices = object : MockServices(listOf("net.corda.core.serialization"), MEGA_CORP.name, mock(), testNetworkParameters(notaries = listOf(NotaryInfo(DUMMY_NOTARY, true))), MEGA_CORP_KEY) { + val megaCorpServices = object : MockServices(listOf("net.corda.coretests.serialization"), MEGA_CORP.name, mock(), testNetworkParameters(notaries = listOf(NotaryInfo(DUMMY_NOTARY, true))), MEGA_CORP_KEY) { //override mock implementation with a real one override fun loadContractAttachment(stateRef: StateRef): Attachment = servicesForResolution.loadContractAttachment(stateRef) } - val notaryServices = MockServices(listOf("net.corda.core.serialization"), DUMMY_NOTARY.name, rigorousMock(), DUMMY_NOTARY_KEY) + val notaryServices = MockServices(listOf("net.corda.coretests.serialization"), DUMMY_NOTARY.name, rigorousMock(), DUMMY_NOTARY_KEY) lateinit var tx: TransactionBuilder @Before diff --git a/core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderSerializationTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderSerializationTests.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderSerializationTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderSerializationTests.kt index 007463d280..fc98d7a04d 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderSerializationTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderSerializationTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import net.corda.core.contracts.Contract import net.corda.core.crypto.SecureHash diff --git a/core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderTests.kt similarity index 99% rename from core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderTests.kt index 6f1924b2e3..2b8666a0ea 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/AttachmentsClassLoaderTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/AttachmentsClassLoaderTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import net.corda.core.contracts.Attachment import net.corda.core.contracts.Contract diff --git a/core/src/test/kotlin/net/corda/core/transactions/CompatibleTransactionTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/CompatibleTransactionTests.kt similarity index 92% rename from core/src/test/kotlin/net/corda/core/transactions/CompatibleTransactionTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/CompatibleTransactionTests.kt index 579e23d57b..4a26b8d4cc 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/CompatibleTransactionTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/CompatibleTransactionTests.kt @@ -1,12 +1,15 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import net.corda.core.contracts.* import net.corda.core.contracts.ComponentGroupEnum.* import net.corda.core.crypto.* import net.corda.core.internal.createComponentGroups +import net.corda.core.internal.accessAvailableComponentHashes +import net.corda.core.internal.accessGroupHashes +import net.corda.core.internal.accessGroupMerkleRoots import net.corda.core.serialization.serialize +import net.corda.core.transactions.* import net.corda.core.utilities.OpaqueBytes -import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyState import net.corda.testing.core.* @@ -14,6 +17,7 @@ import org.junit.Rule import org.junit.Test import java.time.Instant import java.util.function.Predicate +import kotlin.reflect.KVisibility import kotlin.test.* class CompatibleTransactionTests { @@ -77,7 +81,7 @@ class CompatibleTransactionTests { assertNotEquals(wireTransactionA, wireTransactionOtherPrivacySalt) // Full Merkle root is computed from the list of Merkle roots of each component group. - assertEquals(wireTransactionA.merkleTree.hash, MerkleTree.getMerkleTree(wireTransactionA.groupHashes).hash) + assertEquals(wireTransactionA.merkleTree.hash, MerkleTree.getMerkleTree(wireTransactionA.accessGroupHashes()).hash) // Trying to add an empty component group (not allowed), e.g. the empty attachmentGroup. val componentGroupsEmptyAttachment = listOf( @@ -107,12 +111,12 @@ class CompatibleTransactionTests { assertNotEquals(wireTransaction1ShuffledInputs, wireTransactionA) // Inputs group Merkle roots are not equal. - assertNotEquals(wireTransactionA.groupsMerkleRoots[INPUTS_GROUP.ordinal], wireTransaction1ShuffledInputs.groupsMerkleRoots[INPUTS_GROUP.ordinal]) + assertNotEquals(wireTransactionA.accessGroupMerkleRoots()[INPUTS_GROUP.ordinal], wireTransaction1ShuffledInputs.accessGroupMerkleRoots()[INPUTS_GROUP.ordinal]) // But outputs group Merkle leaf (and the rest) remained the same. - assertEquals(wireTransactionA.groupsMerkleRoots[OUTPUTS_GROUP.ordinal], wireTransaction1ShuffledInputs.groupsMerkleRoots[OUTPUTS_GROUP.ordinal]) - assertEquals(wireTransactionA.groupsMerkleRoots[NOTARY_GROUP.ordinal], wireTransaction1ShuffledInputs.groupsMerkleRoots[NOTARY_GROUP.ordinal]) - assertNull(wireTransactionA.groupsMerkleRoots[ATTACHMENTS_GROUP.ordinal]) - assertNull(wireTransaction1ShuffledInputs.groupsMerkleRoots[ATTACHMENTS_GROUP.ordinal]) + assertEquals(wireTransactionA.accessGroupMerkleRoots()[OUTPUTS_GROUP.ordinal], wireTransaction1ShuffledInputs.accessGroupMerkleRoots()[OUTPUTS_GROUP.ordinal]) + assertEquals(wireTransactionA.accessGroupMerkleRoots()[NOTARY_GROUP.ordinal], wireTransaction1ShuffledInputs.accessGroupMerkleRoots()[NOTARY_GROUP.ordinal]) + assertNull(wireTransactionA.accessGroupMerkleRoots()[ATTACHMENTS_GROUP.ordinal]) + assertNull(wireTransaction1ShuffledInputs.accessGroupMerkleRoots()[ATTACHMENTS_GROUP.ordinal]) // Group leaves (components) ordering does not affect the id. In this case, we added outputs group before inputs. val shuffledComponentGroupsA = listOf( @@ -414,7 +418,8 @@ class CompatibleTransactionTests { @Test fun `FilteredTransaction signer manipulation tests`() { // Required to call the private constructor. - val ftxConstructor = ::FilteredTransaction + val ftxConstructor = FilteredTransaction::class.constructors.first() + // 1st and 3rd commands require a signature from KEY_1. val twoCommandsforKey1 = listOf(dummyCommand(DUMMY_KEY_1.public, DUMMY_KEY_2.public), dummyCommand(DUMMY_KEY_2.public), dummyCommand(DUMMY_KEY_1.public)) @@ -448,7 +453,7 @@ class CompatibleTransactionTests { val key2CommandsFtx = wtx.buildFilteredTransaction(Predicate(::filterKEY2Commands)) // val commandDataComponents = key1CommandsFtx.filteredComponentGroups[0].components - val commandDataHashes = wtx.availableComponentHashes[ComponentGroupEnum.COMMANDS_GROUP.ordinal]!! + val commandDataHashes = wtx.accessAvailableComponentHashes()[ComponentGroupEnum.COMMANDS_GROUP.ordinal]!! val noLastCommandDataPMT = PartialMerkleTree.build( MerkleTree.getMerkleTree(commandDataHashes), commandDataHashes.subList(0, 1) @@ -456,14 +461,14 @@ class CompatibleTransactionTests { val noLastCommandDataComponents = key1CommandsFtx.filteredComponentGroups[0].components.subList(0, 1) val noLastCommandDataNonces = key1CommandsFtx.filteredComponentGroups[0].nonces.subList(0, 1) val noLastCommandDataGroup = FilteredComponentGroup( - ComponentGroupEnum.COMMANDS_GROUP.ordinal, + COMMANDS_GROUP.ordinal, noLastCommandDataComponents, noLastCommandDataNonces, noLastCommandDataPMT ) val signerComponents = key1CommandsFtx.filteredComponentGroups[1].components - val signerHashes = wtx.availableComponentHashes[ComponentGroupEnum.SIGNERS_GROUP.ordinal]!! + val signerHashes = wtx.accessAvailableComponentHashes()[ComponentGroupEnum.SIGNERS_GROUP.ordinal]!! val noLastSignerPMT = PartialMerkleTree.build( MerkleTree.getMerkleTree(signerHashes), signerHashes.subList(0, 2) @@ -471,13 +476,13 @@ class CompatibleTransactionTests { val noLastSignerComponents = key1CommandsFtx.filteredComponentGroups[1].components.subList(0, 2) val noLastSignerNonces = key1CommandsFtx.filteredComponentGroups[1].nonces.subList(0, 2) val noLastSignerGroup = FilteredComponentGroup( - ComponentGroupEnum.SIGNERS_GROUP.ordinal, + SIGNERS_GROUP.ordinal, noLastSignerComponents, noLastSignerNonces, noLastSignerPMT ) val noLastSignerGroupSamePartialTree = FilteredComponentGroup( - ComponentGroupEnum.SIGNERS_GROUP.ordinal, + SIGNERS_GROUP.ordinal, noLastSignerComponents, noLastSignerNonces, key1CommandsFtx.filteredComponentGroups[1].partialMerkleTree) // We don't update that, so we can catch the index mismatch. @@ -493,12 +498,12 @@ class CompatibleTransactionTests { // A command with no corresponding signer detected // because the pointer of CommandData (3rd leaf) cannot find a corresponding (3rd) signer. val updatedFilteredComponentsNoSignersKey1SamePMT = listOf(key1CommandsFtx.filteredComponentGroups[0], noLastSignerGroupSamePartialTree) - assertFails { ftxConstructor.invoke(key1CommandsFtx.id, updatedFilteredComponentsNoSignersKey1SamePMT, key1CommandsFtx.groupHashes) } + assertFails { ftxConstructor.call(key1CommandsFtx.id, updatedFilteredComponentsNoSignersKey1SamePMT, key1CommandsFtx.groupHashes) } // Remove both last signer (KEY1) and related command. // Update partial Merkle tree for signers. val updatedFilteredComponentsNoLastCommandAndSigners = listOf(noLastCommandDataGroup, noLastSignerGroup) - val ftxNoLastCommandAndSigners = ftxConstructor.invoke(key1CommandsFtx.id, updatedFilteredComponentsNoLastCommandAndSigners, key1CommandsFtx.groupHashes) + val ftxNoLastCommandAndSigners = ftxConstructor.call(key1CommandsFtx.id, updatedFilteredComponentsNoLastCommandAndSigners, key1CommandsFtx.groupHashes) // verify() will pass as the transaction is well-formed. ftxNoLastCommandAndSigners.verify() // checkCommandVisibility() will not pass, because checkAllComponentsVisible(ComponentGroupEnum.SIGNERS_GROUP) will fail. @@ -507,7 +512,7 @@ class CompatibleTransactionTests { // Remove last signer for which there is no pointer from a visible commandData. This is the case of Key2. // Do not change partial Merkle tree for signers. // This time the object can be constructed as there is no pointer mismatch. - val ftxNoLastSigner = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2SamePMT, key2CommandsFtx.groupHashes) + val ftxNoLastSigner = ftxConstructor.call(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2SamePMT, key2CommandsFtx.groupHashes) // verify() will fail as we didn't change the partial Merkle tree. assertFailsWith { ftxNoLastSigner.verify() } // checkCommandVisibility() will not pass. @@ -515,7 +520,7 @@ class CompatibleTransactionTests { // Remove last signer for which there is no pointer from a visible commandData. This is the case of Key2. // Update partial Merkle tree for signers. - val ftxNoLastSignerB = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2, key2CommandsFtx.groupHashes) + val ftxNoLastSignerB = ftxConstructor.call(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2, key2CommandsFtx.groupHashes) // verify() will pass, the transaction is well-formed. ftxNoLastSignerB.verify() // But, checkAllComponentsVisible() will not pass. @@ -524,7 +529,7 @@ class CompatibleTransactionTests { // Modify last signer (we have a pointer from commandData). // Update partial Merkle tree for signers. val alterSignerComponents = signerComponents.subList(0, 2) + signerComponents[1] // Third one is removed and the 2nd command is added twice. - val alterSignersHashes = wtx.availableComponentHashes[ComponentGroupEnum.SIGNERS_GROUP.ordinal]!!.subList(0, 2) + componentHash(key1CommandsFtx.filteredComponentGroups[1].nonces[2], alterSignerComponents[2]) + val alterSignersHashes = wtx.accessAvailableComponentHashes()[ComponentGroupEnum.SIGNERS_GROUP.ordinal]!!.subList(0, 2) + componentHash(key1CommandsFtx.filteredComponentGroups[1].nonces[2], alterSignerComponents[2]) val alterMTree = MerkleTree.getMerkleTree(alterSignersHashes) val alterSignerPMTK = PartialMerkleTree.build( alterMTree, @@ -532,7 +537,7 @@ class CompatibleTransactionTests { ) val alterSignerGroup = FilteredComponentGroup( - ComponentGroupEnum.SIGNERS_GROUP.ordinal, + SIGNERS_GROUP.ordinal, alterSignerComponents, key1CommandsFtx.filteredComponentGroups[1].nonces, alterSignerPMTK @@ -540,14 +545,14 @@ class CompatibleTransactionTests { val alterFilteredComponents = listOf(key1CommandsFtx.filteredComponentGroups[0], alterSignerGroup) // Do not update groupHashes. - val ftxAlterSigner = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes) + val ftxAlterSigner = ftxConstructor.call(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes) // Visible components in signers group cannot be verified against their partial Merkle tree. assertFailsWith { ftxAlterSigner.verify() } // Also, checkAllComponentsVisible() will not pass (groupHash matching will fail). assertFailsWith { ftxAlterSigner.checkCommandVisibility(DUMMY_KEY_1.public) } // Update groupHashes. - val ftxAlterSignerB = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes.subList(0, 6) + alterMTree.hash) + val ftxAlterSignerB = ftxConstructor.call(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes.subList(0, 6) + alterMTree.hash) // Visible components in signers group cannot be verified against their partial Merkle tree. assertFailsWith { ftxAlterSignerB.verify() } // Also, checkAllComponentsVisible() will not pass (top level Merkle tree cannot be verified against transaction's id). diff --git a/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/LedgerTransactionQueryTests.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/LedgerTransactionQueryTests.kt index d9bf2ae115..44e315872b 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/LedgerTransactionQueryTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock @@ -9,11 +9,12 @@ import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.NotaryInfo +import net.corda.core.transactions.LedgerTransaction +import net.corda.core.transactions.TransactionBuilder import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.contracts.DummyContract import net.corda.testing.core.* -import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import org.junit.Before import org.junit.Rule diff --git a/core/src/test/kotlin/net/corda/core/transactions/ReferenceInputStateTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/ReferenceInputStateTests.kt similarity index 94% rename from core/src/test/kotlin/net/corda/core/transactions/ReferenceInputStateTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/ReferenceInputStateTests.kt index d93cacdb66..a13f3fb172 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/ReferenceInputStateTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/ReferenceInputStateTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock @@ -10,6 +10,8 @@ import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.NotaryInfo +import net.corda.core.transactions.LedgerTransaction +import net.corda.core.transactions.TransactionBuilder import net.corda.finance.DOLLARS import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash @@ -18,16 +20,13 @@ import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.core.DUMMY_NOTARY_NAME import net.corda.testing.core.SerializationEnvironmentRule import net.corda.testing.core.TestIdentity -import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger -import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.* import org.junit.Rule import org.junit.Test -import kotlin.test.assertFailsWith -const val CONTRACT_ID = "net.corda.core.transactions.ReferenceStateTests\$ExampleContract" +const val CONTRACT_ID = "net.corda.coretests.transactions.ReferenceStateTests\$ExampleContract" class ReferenceStateTests { private companion object { @@ -47,7 +46,7 @@ class ReferenceStateTests { val defaultIssuer = ISSUER.ref(1) val bobCash = Cash.State(amount = 1000.DOLLARS `issued by` defaultIssuer, owner = BOB_PARTY) private val ledgerServices = MockServices( - cordappPackages = listOf("net.corda.core.transactions", "net.corda.finance.contracts.asset"), + cordappPackages = listOf("net.corda.coretests.transactions", "net.corda.finance.contracts.asset"), initialIdentity = ALICE, identityService = mock().also { doReturn(ALICE_PARTY).whenever(it).partyFromKey(ALICE_PUBKEY) @@ -203,7 +202,8 @@ class ReferenceStateTests { val state = ExampleState(ALICE_PARTY, "HELLO CORDA") val stateAndRef = StateAndRef(TransactionState(state, CONTRACT_ID, DUMMY_NOTARY, constraint = AlwaysAcceptAttachmentConstraint), StateRef(SecureHash.zeroHash, 0)) assertThatIllegalArgumentException().isThrownBy { - TransactionBuilder(notary = DUMMY_NOTARY).addInputState(stateAndRef).addReferenceState(stateAndRef.referenced()) + TransactionBuilder(notary = DUMMY_NOTARY) + .addInputState(stateAndRef).addReferenceState(stateAndRef.referenced()) }.withMessage("A StateRef cannot be both an input and a reference input in the same transaction.") } } \ No newline at end of file diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt index abadaedeb7..8239db61a5 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock @@ -15,6 +15,7 @@ import net.corda.core.node.ZoneVersionTooLowException import net.corda.core.node.services.AttachmentStorage import net.corda.core.node.services.NetworkParametersService import net.corda.core.serialization.serialize +import net.corda.core.transactions.TransactionBuilder import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyState diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionEncumbranceTests.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionEncumbranceTests.kt index fe1747d2bb..3fb91fb95a 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionEncumbranceTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock @@ -7,6 +7,8 @@ import net.corda.core.contracts.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.node.NotaryInfo +import net.corda.core.transactions.LedgerTransaction +import net.corda.core.transactions.TransactionBuilder import net.corda.finance.DOLLARS import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash @@ -15,7 +17,6 @@ import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.core.DUMMY_NOTARY_NAME import net.corda.testing.core.SerializationEnvironmentRule import net.corda.testing.core.TestIdentity -import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType @@ -25,7 +26,7 @@ import java.time.Instant import java.time.temporal.ChronoUnit import kotlin.test.assertFailsWith -const val TEST_TIMELOCK_ID = "net.corda.core.transactions.TransactionEncumbranceTests\$DummyTimeLock" +const val TEST_TIMELOCK_ID = "net.corda.coretests.transactions.TransactionEncumbranceTests\$DummyTimeLock" class TransactionEncumbranceTests { @Rule diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionTests.kt similarity index 96% rename from core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt rename to core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionTests.kt index 92889e2217..8dae611a06 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionTests.kt @@ -1,4 +1,4 @@ -package net.corda.core.transactions +package net.corda.coretests.transactions import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.whenever @@ -8,7 +8,10 @@ import net.corda.core.crypto.CompositeKey import net.corda.core.identity.Party import net.corda.core.internal.AbstractAttachment import net.corda.core.internal.TESTDSL_UPLOADER +import net.corda.core.internal.createLedgerTransaction import net.corda.core.node.NotaryInfo +import net.corda.core.transactions.SignedTransaction +import net.corda.core.transactions.WireTransaction import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.contracts.DummyContract import net.corda.testing.core.* @@ -17,7 +20,6 @@ import net.corda.testing.internal.fakeAttachment import net.corda.testing.internal.rigorousMock import org.junit.Rule import org.junit.Test -import java.io.InputStream import java.math.BigInteger import java.security.KeyPair import java.security.PublicKey @@ -129,7 +131,7 @@ class TransactionTests { val id = SecureHash.randomSHA256() val timeWindow: TimeWindow? = null val privacySalt = PrivacySalt() - val transaction = LedgerTransaction.create( + val transaction = createLedgerTransaction( inputs, outputs, commands, @@ -182,7 +184,7 @@ class TransactionTests { val timeWindow: TimeWindow? = null val privacySalt = PrivacySalt() - fun buildTransaction() = LedgerTransaction.create( + fun buildTransaction() = createLedgerTransaction( inputs, outputs, commands, @@ -193,7 +195,7 @@ class TransactionTests { privacySalt, testNetworkParameters(notaries = listOf(NotaryInfo(DUMMY_NOTARY, true))), emptyList(), - isAttachmentTrusted = {true} + isAttachmentTrusted = { true } ) assertFailsWith { buildTransaction().verify() } diff --git a/core/src/test/kotlin/net/corda/core/utilities/KotlinUtilsTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/utilities/KotlinUtilsTest.kt similarity index 97% rename from core/src/test/kotlin/net/corda/core/utilities/KotlinUtilsTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/utilities/KotlinUtilsTest.kt index debb6307f0..8f92f1d352 100644 --- a/core/src/test/kotlin/net/corda/core/utilities/KotlinUtilsTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/utilities/KotlinUtilsTest.kt @@ -1,10 +1,11 @@ -package net.corda.core.utilities +package net.corda.coretests.utilities import com.esotericsoftware.kryo.KryoException import net.corda.core.crypto.random63BitValue import net.corda.core.serialization.* import net.corda.core.serialization.internal.checkpointDeserialize import net.corda.core.serialization.internal.checkpointSerialize +import net.corda.core.utilities.transient import net.corda.node.serialization.kryo.KRYO_CHECKPOINT_CONTEXT import net.corda.serialization.internal.CheckpointSerializationContextImpl import net.corda.testing.core.SerializationEnvironmentRule diff --git a/core/src/test/kotlin/net/corda/core/utilities/NonEmptySetTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/utilities/NonEmptySetTest.kt similarity index 96% rename from core/src/test/kotlin/net/corda/core/utilities/NonEmptySetTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/utilities/NonEmptySetTest.kt index b404ded1fc..21a14e30fd 100644 --- a/core/src/test/kotlin/net/corda/core/utilities/NonEmptySetTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/utilities/NonEmptySetTest.kt @@ -1,4 +1,4 @@ -package net.corda.core.utilities +package net.corda.coretests.utilities import com.google.common.collect.testing.SetTestSuiteBuilder import com.google.common.collect.testing.TestIntegerSetGenerator @@ -7,6 +7,7 @@ import com.google.common.collect.testing.features.CollectionSize import junit.framework.TestSuite import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize +import net.corda.core.utilities.NonEmptySet import net.corda.testing.core.SerializationEnvironmentRule import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy diff --git a/core/src/test/kotlin/net/corda/core/utilities/ProgressTrackerTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/utilities/ProgressTrackerTest.kt similarity index 98% rename from core/src/test/kotlin/net/corda/core/utilities/ProgressTrackerTest.kt rename to core-tests/src/test/kotlin/net/corda/coretests/utilities/ProgressTrackerTest.kt index fa2569a3cb..e6147336f3 100644 --- a/core/src/test/kotlin/net/corda/core/utilities/ProgressTrackerTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/utilities/ProgressTrackerTest.kt @@ -1,9 +1,10 @@ -package net.corda.core.utilities +package net.corda.coretests.utilities import net.corda.core.serialization.internal.checkpointDeserialize import net.corda.core.serialization.internal.checkpointSerialize -import net.corda.core.utilities.ProgressTrackerTest.NonSingletonSteps.first -import net.corda.core.utilities.ProgressTrackerTest.NonSingletonSteps.first2 +import net.corda.core.utilities.ProgressTracker +import net.corda.coretests.utilities.ProgressTrackerTest.NonSingletonSteps.first +import net.corda.coretests.utilities.ProgressTrackerTest.NonSingletonSteps.first2 import net.corda.testing.core.internal.CheckpointSerializationEnvironmentRule import org.assertj.core.api.Assertions.assertThat import org.junit.Before diff --git a/core/src/test/kotlin/net/corda/isolated/contracts/DummyContractBackdoor.kt b/core-tests/src/test/kotlin/net/corda/isolated/contracts/DummyContractBackdoor.kt similarity index 100% rename from core/src/test/kotlin/net/corda/isolated/contracts/DummyContractBackdoor.kt rename to core-tests/src/test/kotlin/net/corda/isolated/contracts/DummyContractBackdoor.kt diff --git a/core/src/test/resources/isolated.jar b/core-tests/src/test/resources/isolated.jar similarity index 100% rename from core/src/test/resources/isolated.jar rename to core-tests/src/test/resources/isolated.jar diff --git a/core/src/test/resources/net/corda/core/transactions/isolated-4.0.jar b/core-tests/src/test/resources/net/corda/coretests/transactions/isolated-4.0.jar similarity index 100% rename from core/src/test/resources/net/corda/core/transactions/isolated-4.0.jar rename to core-tests/src/test/resources/net/corda/coretests/transactions/isolated-4.0.jar diff --git a/core/src/test/resources/net/corda/core/transactions/old-isolated.jar b/core-tests/src/test/resources/net/corda/coretests/transactions/old-isolated.jar similarity index 100% rename from core/src/test/resources/net/corda/core/transactions/old-isolated.jar rename to core-tests/src/test/resources/net/corda/coretests/transactions/old-isolated.jar diff --git a/core/build.gradle b/core/build.gradle index 4d2b75ab34..f4cf4a642e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -17,42 +17,6 @@ configurations { smokeTestRuntimeOnly.extendsFrom runtimeOnly } -sourceSets { - integrationTest { - kotlin { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - srcDir file('src/integration-test/kotlin') - } - java { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - srcDir file('src/integration-test/java') - } - } - smokeTest { - kotlin { - // We must NOT have any Node code on the classpath, so do NOT - // include the test or integrationTest dependencies here. - compileClasspath += main.output - runtimeClasspath += main.output - srcDir file('src/smoke-test/kotlin') - } - java { - compileClasspath += main.output - runtimeClasspath += main.output - srcDir file('src/smoke-test/java') - } - } -} - -processSmokeTestResources { - // Bring in the fully built corda.jar for use by NodeFactory in the smoke tests - from(project(':node:capsule').tasks['buildCordaJAR']) { - rename 'corda-(.*)', 'corda.jar' - } -} - dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" @@ -66,9 +30,6 @@ dependencies { // Guava: Google test library (collections test suite) testCompile "com.google.guava:guava-testlib:$guava_version" - // Bring in the MockNode infrastructure for writing protocol unit tests. - testCompile project(":node-driver") - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" @@ -92,17 +53,6 @@ dependencies { // For caches rather than guava compile "com.github.ben-manes.caffeine:caffeine:$caffeine_version" - // Smoke tests do NOT have any Node code on the classpath! - smokeTestImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" - smokeTestImplementation "junit:junit:$junit_version" - - smokeTestRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}" - smokeTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}" - smokeTestRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}" - - smokeTestCompile project(':smoke-test-utils') - smokeTestCompile "org.assertj:assertj-core:${assertj_version}" - // RxJava: observable streams of events. compile "io.reactivex:rxjava:$rxjava_version" @@ -122,6 +72,11 @@ dependencies { compile "org.hibernate:hibernate-core:$hibernate_version" compile group: "io.github.classgraph", name: "classgraph", version: class_graph_version + + testCompile "com.nhaarman:mockito-kotlin:$mockito_kotlin_version" + testCompile "org.mockito:mockito-core:$mockito_version" + testCompile "org.assertj:assertj-core:$assertj_version" + testCompile "com.natpryce:hamkrest:$hamkrest_version" } // TODO Consider moving it to quasar-utils in the future (introduced with PR-1388) @@ -150,22 +105,6 @@ task testJar(type: Jar) { from sourceSets.test.output } -task integrationTest(type: Test) { - testClassesDirs = sourceSets.integrationTest.output.classesDirs - classpath = sourceSets.integrationTest.runtimeClasspath -} - -task smokeTestJar(type: Jar) { - classifier 'smokeTests' - from sourceSets.smokeTest.output -} - -task smokeTest(type: Test) { - dependsOn smokeTestJar - testClassesDirs = sourceSets.smokeTest.output.classesDirs - classpath = sourceSets.smokeTest.runtimeClasspath -} - // quasar exclusions upon agent code instrumentation at run-time quasar { excludePackages.addAll( diff --git a/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt b/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt index e802ecdb06..8fa5acdd93 100644 --- a/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt +++ b/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt @@ -100,7 +100,7 @@ object RetrieveAnyTransactionPayload : ArrayList() private fun owns(packageName: String, fullClassName: String): Boolean = fullClassName.startsWith("$packageName.", ignoreCase = true) /** Returns the public key of the package owner of the [contractClassName], or null if not owned. */ -internal fun NetworkParameters.getPackageOwnerOf(contractClassName: ContractClassName): PublicKey? { +fun NetworkParameters.getPackageOwnerOf(contractClassName: ContractClassName): PublicKey? { return packageOwnership.entries.singleOrNull { owns(it.key, contractClassName) }?.value } diff --git a/core/src/test/README.md b/core/src/test/README.md new file mode 100644 index 0000000000..7eb94e5eab --- /dev/null +++ b/core/src/test/README.md @@ -0,0 +1,12 @@ +# Adding tests to the Core module + +**TL;DR**: Any tests that do not require further dependencies should be added to this module, anything that +requires additional Corda dependencies needs to go into `core-tests`. + +The Corda core module defines a lot of types and helpers that can only be exercised, and therefore tested, in +the context of a node. However, as everything else depends on the core module, we cannot pull the node into +this module. Therefore, any tests that require further Corda dependencies need to be defined in the module + `core-tests`, which has the full set of dependencies including `node-driver`. + + + \ No newline at end of file diff --git a/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt b/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt index 78f1586d8a..d9c3ba33d7 100644 --- a/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt +++ b/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt @@ -3,7 +3,6 @@ package net.corda.core.concurrent import com.nhaarman.mockito_kotlin.* import net.corda.core.internal.concurrent.openFuture import net.corda.core.utilities.getOrThrow -import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Test import org.slf4j.Logger @@ -17,7 +16,7 @@ class ConcurrencyUtilsTest { private val f1 = openFuture() private val f2 = openFuture() private var invocations = 0 - private val log = rigorousMock().also { + private val log = mock().also { doNothing().whenever(it).error(any(), any()) } diff --git a/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt b/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt index d04fae86bb..0ca6be9afb 100644 --- a/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt +++ b/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt @@ -4,7 +4,6 @@ import com.nhaarman.mockito_kotlin.* import net.corda.core.concurrent.CordaFuture import net.corda.core.internal.join import net.corda.core.utilities.getOrThrow -import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions import org.junit.Test import org.slf4j.Logger @@ -32,7 +31,7 @@ class CordaFutureTest { fun `if a listener fails its throwable is logged`() { val f = CordaFutureImpl() val x = Exception() - val log = rigorousMock() + val log = mock() val flag = AtomicBoolean() f.thenImpl(log) { throw x } f.thenImpl(log) { flag.set(true) } // Must not be affected by failure of previous listener. @@ -58,7 +57,7 @@ class CordaFutureTest { Assertions.assertThatThrownBy { g.getOrThrow() }.isSameAs(x) } run { - val block = rigorousMock<(Any?) -> Any?>() + val block = mock<(Any?) -> Any?>() val f = CordaFutureImpl() val g = f.map(block) val x = Exception() @@ -91,7 +90,7 @@ class CordaFutureTest { Assertions.assertThatThrownBy { g.getOrThrow() }.isSameAs(x) } run { - val block = rigorousMock<(Any?) -> CordaFuture<*>>() + val block = mock<(Any?) -> CordaFuture<*>>() val f = CordaFutureImpl() val g = f.flatMap(block) val x = Exception() @@ -103,7 +102,7 @@ class CordaFutureTest { @Test fun `andForget works`() { - val log = rigorousMock() + val log = mock() doNothing().whenever(log).error(any(), any()) val throwable = Exception("Boom") val executor = Executors.newSingleThreadExecutor() diff --git a/core/src/test/kotlin/net/corda/core/internal/internalAccessTestHelpers.kt b/core/src/test/kotlin/net/corda/core/internal/internalAccessTestHelpers.kt new file mode 100644 index 0000000000..a0523a22d0 --- /dev/null +++ b/core/src/test/kotlin/net/corda/core/internal/internalAccessTestHelpers.kt @@ -0,0 +1,42 @@ +package net.corda.core.internal + +import net.corda.core.contracts.* +import net.corda.core.crypto.MerkleTree +import net.corda.core.crypto.PartialMerkleTree +import net.corda.core.crypto.SecureHash +import net.corda.core.identity.Party +import net.corda.core.internal.SerializedStateAndRef +import net.corda.core.node.NetworkParameters +import net.corda.core.transactions.ComponentGroup +import net.corda.core.transactions.LedgerTransaction +import net.corda.core.transactions.WireTransaction + +/** + * A set of functions in core:test that allows testing of core internal classes in the core-tests project. + */ + +fun WireTransaction.accessGroupHashes() = this.groupHashes +fun WireTransaction.accessGroupMerkleRoots() = this.groupsMerkleRoots +fun WireTransaction.accessAvailableComponentHashes() = this.availableComponentHashes + +fun createLedgerTransaction( + inputs: List>, + outputs: List>, + commands: List>, + attachments: List, + id: SecureHash, + notary: Party?, + timeWindow: TimeWindow?, + privacySalt: PrivacySalt, + networkParameters: NetworkParameters, + references: List>, + componentGroups: List? = null, + serializedInputs: List? = null, + serializedReferences: List? = null, + isAttachmentTrusted: (Attachment) -> Boolean +): LedgerTransaction = LedgerTransaction.create(inputs, outputs, commands, attachments, id, notary, timeWindow, privacySalt, networkParameters, references, componentGroups, serializedInputs, serializedReferences, isAttachmentTrusted) + +fun createContractCreationError(txId: SecureHash, contractClass: String, cause: Throwable) = TransactionVerificationException.ContractCreationError(txId, contractClass, cause) +fun createContractRejection(txId: SecureHash, contract: Contract, cause: Throwable) = TransactionVerificationException.ContractRejection(txId, contract, cause) + +fun PartialMerkleTree.accessLeafIndex(id: SecureHash) = this.leafIndex(id) \ No newline at end of file diff --git a/finance/contracts/build.gradle b/finance/contracts/build.gradle index 1db0572bbf..8b4e4a9351 100644 --- a/finance/contracts/build.gradle +++ b/finance/contracts/build.gradle @@ -14,6 +14,7 @@ dependencies { testCompile project(':test-utils') testCompile project(path: ':core', configuration: 'testArtifacts') + testCompile project(':node-driver') testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" testImplementation "junit:junit:$junit_version" diff --git a/finance/workflows/build.gradle b/finance/workflows/build.gradle index c2126546f7..20e8a388b9 100644 --- a/finance/workflows/build.gradle +++ b/finance/workflows/build.gradle @@ -39,6 +39,7 @@ dependencies { testCompile project(':test-utils') testCompile project(path: ':core', configuration: 'testArtifacts') + testCompile project(':node-driver') testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}" testImplementation "junit:junit:$junit_version" diff --git a/node/build.gradle b/node/build.gradle index e3af275dce..0865791032 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -137,6 +137,7 @@ dependencies { // Unit testing helpers. testCompile "org.assertj:assertj-core:${assertj_version}" + testCompile project(':node-driver') testCompile project(':test-utils') testCompile project(':client:jfx') testCompile project(':finance:contracts') diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkPersistenceTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkPersistenceTests.kt index dc960b59af..10e4c0b7ae 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkPersistenceTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkPersistenceTests.kt @@ -2,7 +2,6 @@ package net.corda.node.services.statemachine import net.corda.core.crypto.random63BitValue import net.corda.core.flows.FlowLogic -import net.corda.core.flows.registerCordappFlowFactory import net.corda.core.identity.Party import net.corda.core.utilities.getOrThrow import net.corda.node.services.persistence.checkpoints @@ -10,6 +9,7 @@ import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME import net.corda.testing.core.CHARLIE_NAME import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.registerCordappFlowFactory import net.corda.testing.internal.LogHelper import net.corda.testing.node.InMemoryMessagingNetwork import net.corda.testing.node.internal.* diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt index 1ee5f74030..700410cdd2 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt @@ -33,6 +33,7 @@ import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME import net.corda.testing.core.dummyCommand import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.registerCordappFlowFactory import net.corda.testing.internal.LogHelper import net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTripartyTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTripartyTests.kt index 4f731c889b..0accb9481d 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTripartyTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTripartyTests.kt @@ -1,7 +1,6 @@ package net.corda.node.services.statemachine import net.corda.core.flows.UnexpectedFlowEndException -import net.corda.core.flows.registerCordappFlowFactory import net.corda.core.identity.Party import net.corda.core.internal.concurrent.map import net.corda.core.utilities.getOrThrow @@ -9,6 +8,7 @@ import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME import net.corda.testing.core.CHARLIE_NAME import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.registerCordappFlowFactory import net.corda.testing.internal.LogHelper import net.corda.testing.node.InMemoryMessagingNetwork import net.corda.testing.node.internal.* diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt index 2db01f2c3c..3078c4a3c5 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt @@ -23,6 +23,7 @@ import net.corda.nodeapi.internal.cordapp.CordappLoader import net.corda.node.services.api.VaultServiceInternal import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.core.singleIdentity +import net.corda.testing.flows.registerCoreFlowFactory import net.corda.testing.internal.rigorousMock import net.corda.testing.node.internal.InternalMockNetwork import net.corda.testing.node.internal.enclosedCordapp diff --git a/settings.gradle b/settings.gradle index 1083201428..73c4d3915a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,6 +15,7 @@ include 'finance:contracts' include 'finance:workflows' include 'isolated' include 'core' +include 'core-tests' include 'docs' include 'node-api' include 'node' diff --git a/core/src/test/kotlin/net/corda/core/flows/FlowTestsUtils.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/flows/FlowTestsUtils.kt similarity index 83% rename from core/src/test/kotlin/net/corda/core/flows/FlowTestsUtils.kt rename to testing/node-driver/src/main/kotlin/net/corda/testing/flows/FlowTestsUtils.kt index ea3b44a98b..78dd3a7035 100644 --- a/core/src/test/kotlin/net/corda/core/flows/FlowTestsUtils.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/flows/FlowTestsUtils.kt @@ -1,7 +1,9 @@ -package net.corda.core.flows +package net.corda.testing.flows import co.paralleluniverse.fibers.Suspendable import net.corda.core.concurrent.CordaFuture +import net.corda.core.flows.FlowLogic +import net.corda.core.flows.FlowSession import net.corda.core.toFuture import net.corda.core.utilities.UntrustworthyData import net.corda.core.utilities.unwrap @@ -10,33 +12,6 @@ import net.corda.testing.node.internal.TestStartedNode import rx.Observable import kotlin.reflect.KClass -/** - * Allows to simplify writing flows that simply rend a message back to an initiating flow. - */ -class Answer(session: FlowSession, override val answer: R, closure: (result: R) -> Unit = {}) : SimpleAnswer(session, closure) - -/** - * Allows to simplify writing flows that simply rend a message back to an initiating flow. - */ -abstract class SimpleAnswer(private val session: FlowSession, private val closure: (result: R) -> Unit = {}) : FlowLogic() { - @Suspendable - override fun call() { - val tmp = answer - closure(tmp) - session.send(tmp) - } - - protected abstract val answer: R -} - -/** - * A flow that does not do anything when triggered. - */ -class NoAnswer(private val closure: () -> Unit = {}) : FlowLogic() { - @Suspendable - override fun call() = closure() -} - /** * Extracts data from a [Map[FlowSession, UntrustworthyData]] without performing checks and casting to [R]. */ @@ -118,6 +93,6 @@ inline fun > TestStartedNode.registerCordappFlowFactory fun > TestStartedNode.registerCoreFlowFactory(initiatingFlowClass: Class>, initiatedFlowClass: Class, - flowFactory: (FlowSession) -> T , track: Boolean): Observable { + flowFactory: (FlowSession) -> T, track: Boolean): Observable { return this.internals.registerInitiatedFlowFactory(initiatingFlowClass, initiatedFlowClass, InitiatedFlowFactory.Core(flowFactory), track) } \ No newline at end of file