mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
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
This commit is contained in:
parent
8a6fc2964c
commit
687fa81894
180
.idea/compiler.xml
generated
180
.idea/compiler.xml
generated
@ -55,6 +55,184 @@
|
||||
<module name="corda-finance_integrationTest" target="1.8" />
|
||||
<module name="corda-isolated_main" target="1.8" />
|
||||
<module name="corda-isolated_test" target="1.8" />
|
||||
<module name="corda-project.buildSrc.main" target="1.8" />
|
||||
<module name="corda-project.buildSrc.test" target="1.8" />
|
||||
<module name="corda-project.client.jackson.main" target="1.8" />
|
||||
<module name="corda-project.client.jackson.test" target="1.8" />
|
||||
<module name="corda-project.client.jfx.integrationTest" target="1.8" />
|
||||
<module name="corda-project.client.jfx.main" target="1.8" />
|
||||
<module name="corda-project.client.jfx.test" target="1.8" />
|
||||
<module name="corda-project.client.main" target="1.8" />
|
||||
<module name="corda-project.client.mock.main" target="1.8" />
|
||||
<module name="corda-project.client.mock.test" target="1.8" />
|
||||
<module name="corda-project.client.rpc.integrationTest" target="1.8" />
|
||||
<module name="corda-project.client.rpc.main" target="1.8" />
|
||||
<module name="corda-project.client.rpc.smokeTest" target="1.8" />
|
||||
<module name="corda-project.client.rpc.test" target="1.8" />
|
||||
<module name="corda-project.client.test" target="1.8" />
|
||||
<module name="corda-project.common-configuration-parsing.main" target="1.8" />
|
||||
<module name="corda-project.common-configuration-parsing.test" target="1.8" />
|
||||
<module name="corda-project.common-logging.main" target="1.8" />
|
||||
<module name="corda-project.common-logging.test" target="1.8" />
|
||||
<module name="corda-project.common-validation.main" target="1.8" />
|
||||
<module name="corda-project.common-validation.test" target="1.8" />
|
||||
<module name="corda-project.confidential-identities.main" target="1.8" />
|
||||
<module name="corda-project.confidential-identities.test" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.main" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.test" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.data.main" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.data.test" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.main" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.test" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.verifier.main" target="1.8" />
|
||||
<module name="corda-project.core-deterministic.testing.verifier.test" target="1.8" />
|
||||
<module name="corda-project.core-tests.integrationTest" target="1.8" />
|
||||
<module name="corda-project.core-tests.main" target="1.8" />
|
||||
<module name="corda-project.core-tests.smokeTest" target="1.8" />
|
||||
<module name="corda-project.core-tests.test" target="1.8" />
|
||||
<module name="corda-project.core.integrationTest" target="1.8" />
|
||||
<module name="corda-project.core.main" target="1.8" />
|
||||
<module name="corda-project.core.smokeTest" target="1.8" />
|
||||
<module name="corda-project.core.test" target="1.8" />
|
||||
<module name="corda-project.docker.main" target="1.8" />
|
||||
<module name="corda-project.docker.test" target="1.8" />
|
||||
<module name="corda-project.docs.main" target="1.8" />
|
||||
<module name="corda-project.docs.test" target="1.8" />
|
||||
<module name="corda-project.example-code.integrationTest" target="1.8" />
|
||||
<module name="corda-project.example-code.main" target="1.8" />
|
||||
<module name="corda-project.example-code.test" target="1.8" />
|
||||
<module name="corda-project.experimental.avalanche.main" target="1.8" />
|
||||
<module name="corda-project.experimental.avalanche.test" target="1.8" />
|
||||
<module name="corda-project.experimental.corda-utils.integrationTest" target="1.8" />
|
||||
<module name="corda-project.experimental.corda-utils.main" target="1.8" />
|
||||
<module name="corda-project.experimental.corda-utils.test" target="1.8" />
|
||||
<module name="corda-project.experimental.main" target="1.8" />
|
||||
<module name="corda-project.experimental.netparams.main" target="1.8" />
|
||||
<module name="corda-project.experimental.netparams.test" target="1.8" />
|
||||
<module name="corda-project.experimental.nodeinfo.main" target="1.8" />
|
||||
<module name="corda-project.experimental.nodeinfo.test" target="1.8" />
|
||||
<module name="corda-project.experimental.quasar-hook.main" target="1.8" />
|
||||
<module name="corda-project.experimental.quasar-hook.test" target="1.8" />
|
||||
<module name="corda-project.experimental.test" target="1.8" />
|
||||
<module name="corda-project.finance.contracts.main" target="1.8" />
|
||||
<module name="corda-project.finance.contracts.test" target="1.8" />
|
||||
<module name="corda-project.finance.main" target="1.8" />
|
||||
<module name="corda-project.finance.test" target="1.8" />
|
||||
<module name="corda-project.finance.workflows.integrationTest" target="1.8" />
|
||||
<module name="corda-project.finance.workflows.main" target="1.8" />
|
||||
<module name="corda-project.finance.workflows.test" target="1.8" />
|
||||
<module name="corda-project.isolated.main" target="1.8" />
|
||||
<module name="corda-project.isolated.test" target="1.8" />
|
||||
<module name="corda-project.jdk8u-deterministic.main" target="1.8" />
|
||||
<module name="corda-project.jdk8u-deterministic.test" target="1.8" />
|
||||
<module name="corda-project.node-api.main" target="1.8" />
|
||||
<module name="corda-project.node-api.test" target="1.8" />
|
||||
<module name="corda-project.node-driver.integrationTest" target="1.8" />
|
||||
<module name="corda-project.node-driver.main" target="1.8" />
|
||||
<module name="corda-project.node-driver.test" target="1.8" />
|
||||
<module name="corda-project.node.capsule.main" target="1.8" />
|
||||
<module name="corda-project.node.capsule.test" target="1.8" />
|
||||
<module name="corda-project.node.integrationTest" target="1.8" />
|
||||
<module name="corda-project.node.main" target="1.8" />
|
||||
<module name="corda-project.node.test" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.contracts.main" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.contracts.test" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.integrationTest" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.workflows.main" target="1.8" />
|
||||
<module name="corda-project.samples.attachment-demo.workflows.test" target="1.8" />
|
||||
<module name="corda-project.samples.bank-of-corda-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.bank-of-corda-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.cordapp-configuration.main" target="1.8" />
|
||||
<module name="corda-project.samples.cordapp-configuration.test" target="1.8" />
|
||||
<module name="corda-project.samples.cordapp-configuration.workflows.main" target="1.8" />
|
||||
<module name="corda-project.samples.cordapp-configuration.workflows.test" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.contracts-irs.main" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.contracts-irs.test" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.integrationTest" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.main" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.test" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.workflows-irs.main" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.cordapp.workflows-irs.test" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.integrationTest" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.systemTest" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.web.main" target="1.8" />
|
||||
<module name="corda-project.samples.irs-demo.web.test" target="1.8" />
|
||||
<module name="corda-project.samples.main" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.contracts.main" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.contracts.test" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.main" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.test" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.workflows.main" target="1.8" />
|
||||
<module name="corda-project.samples.network-verifier.workflows.test" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.contracts.main" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.contracts.test" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.workflows.main" target="1.8" />
|
||||
<module name="corda-project.samples.notary-demo.workflows.test" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.contracts-states.main" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.contracts-states.test" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.flows.main" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.flows.test" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.integrationTest" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.simm-valuation-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.test" target="1.8" />
|
||||
<module name="corda-project.samples.trader-demo.integrationTest" target="1.8" />
|
||||
<module name="corda-project.samples.trader-demo.main" target="1.8" />
|
||||
<module name="corda-project.samples.trader-demo.test" target="1.8" />
|
||||
<module name="corda-project.samples.trader-demo.workflows-trader.main" target="1.8" />
|
||||
<module name="corda-project.samples.trader-demo.workflows-trader.test" target="1.8" />
|
||||
<module name="corda-project.serialization-deterministic.main" target="1.8" />
|
||||
<module name="corda-project.serialization-deterministic.test" target="1.8" />
|
||||
<module name="corda-project.serialization.main" target="1.8" />
|
||||
<module name="corda-project.serialization.test" target="1.8" />
|
||||
<module name="corda-project.smoke-test-utils.main" target="1.8" />
|
||||
<module name="corda-project.smoke-test-utils.test" target="1.8" />
|
||||
<module name="corda-project.test-cli.main" target="1.8" />
|
||||
<module name="corda-project.test-cli.test" target="1.8" />
|
||||
<module name="corda-project.test-common.main" target="1.8" />
|
||||
<module name="corda-project.test-common.test" target="1.8" />
|
||||
<module name="corda-project.test-db.main" target="1.8" />
|
||||
<module name="corda-project.test-db.test" target="1.8" />
|
||||
<module name="corda-project.test-utils.main" target="1.8" />
|
||||
<module name="corda-project.test-utils.test" target="1.8" />
|
||||
<module name="corda-project.tools.blobinspector.main" target="1.8" />
|
||||
<module name="corda-project.tools.blobinspector.test" target="1.8" />
|
||||
<module name="corda-project.tools.bootstrapper.main" target="1.8" />
|
||||
<module name="corda-project.tools.bootstrapper.test" target="1.8" />
|
||||
<module name="corda-project.tools.cliutils.main" target="1.8" />
|
||||
<module name="corda-project.tools.cliutils.test" target="1.8" />
|
||||
<module name="corda-project.tools.demobench.main" target="1.8" />
|
||||
<module name="corda-project.tools.demobench.test" target="1.8" />
|
||||
<module name="corda-project.tools.explorer.capsule.main" target="1.6" />
|
||||
<module name="corda-project.tools.explorer.capsule.test" target="1.6" />
|
||||
<module name="corda-project.tools.explorer.main" target="1.8" />
|
||||
<module name="corda-project.tools.explorer.test" target="1.8" />
|
||||
<module name="corda-project.tools.graphs.main" target="1.8" />
|
||||
<module name="corda-project.tools.graphs.test" target="1.8" />
|
||||
<module name="corda-project.tools.loadtest.main" target="1.8" />
|
||||
<module name="corda-project.tools.loadtest.test" target="1.8" />
|
||||
<module name="corda-project.tools.main" target="1.8" />
|
||||
<module name="corda-project.tools.network-bootstrapper.main" target="1.8" />
|
||||
<module name="corda-project.tools.network-bootstrapper.test" target="1.8" />
|
||||
<module name="corda-project.tools.shell-cli.main" target="1.8" />
|
||||
<module name="corda-project.tools.shell-cli.test" target="1.8" />
|
||||
<module name="corda-project.tools.shell.integrationTest" target="1.8" />
|
||||
<module name="corda-project.tools.shell.main" target="1.8" />
|
||||
<module name="corda-project.tools.shell.test" target="1.8" />
|
||||
<module name="corda-project.tools.test" target="1.8" />
|
||||
<module name="corda-project.tools.worldmap.main" target="1.8" />
|
||||
<module name="corda-project.tools.worldmap.test" target="1.8" />
|
||||
<module name="corda-project.webserver.integrationTest" target="1.8" />
|
||||
<module name="corda-project.webserver.main" target="1.8" />
|
||||
<module name="corda-project.webserver.test" target="1.8" />
|
||||
<module name="corda-project.webserver.webcapsule.main" target="1.6" />
|
||||
<module name="corda-project.webserver.webcapsule.test" target="1.6" />
|
||||
<module name="corda-project_buildSrc_main" target="1.8" />
|
||||
<module name="corda-project_buildSrc_test" target="1.8" />
|
||||
<module name="corda-project_canonicalizer_main" target="1.8" />
|
||||
@ -175,6 +353,8 @@
|
||||
<module name="net.corda-isolated_test" target="1.8" />
|
||||
<module name="net.corda-verifier_main" target="1.8" />
|
||||
<module name="net.corda-verifier_test" target="1.8" />
|
||||
<module name="net.corda.corda-project.main" target="1.8" />
|
||||
<module name="net.corda.corda-project.test" target="1.8" />
|
||||
<module name="net.corda_buildSrc_main" target="1.8" />
|
||||
<module name="net.corda_buildSrc_test" target="1.8" />
|
||||
<module name="net.corda_canonicalizer_main" target="1.8" />
|
||||
|
158
core-tests/build.gradle
Normal file
158
core-tests/build.gradle
Normal file
@ -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
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.corda.core
|
||||
package net.corda.coretests
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.core.flows.FlowLogic
|
@ -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)
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package net.corda.core.schemas;
|
||||
package net.corda.coretests.schemas;
|
||||
|
||||
public class TestJavaSchemaFamily {
|
||||
}
|
@ -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;
|
@ -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
|
@ -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<IllegalArgumentException> { HashAttachmentConstraint(SecureHash.randomSHA256()).canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment) }
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
HashAttachmentConstraint(SecureHash.randomSHA256())
|
||||
.canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment)
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException> { AutomaticPlaceholderConstraint.canBeTransitionedFrom(AutomaticPlaceholderConstraint, attachment) }
|
||||
}
|
||||
|
@ -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
|
@ -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<CommandWit
|
||||
val commands = listOf(invalidCommand)
|
||||
Assertions.assertThatThrownBy { testFunction(commands) }
|
||||
.isInstanceOf(IllegalStateException::class.java)
|
||||
.hasMessage("Required net.corda.core.contracts.TestCommands command")
|
||||
.hasMessage("Required net.corda.coretests.contracts.TestCommands command")
|
||||
}
|
||||
}
|
||||
|
@ -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.identity.AbstractParty
|
||||
@ -29,7 +30,7 @@ class PackageOwnershipVerificationTests {
|
||||
val BOB = TestIdentity(CordaX500Name("BOB", "London", "GB"))
|
||||
val BOB_PARTY get() = BOB.party
|
||||
val BOB_PUBKEY get() = BOB.publicKey
|
||||
const val DUMMY_CONTRACT = "net.corda.core.contracts.DummyContract"
|
||||
const val DUMMY_CONTRACT = "net.corda.coretests.contracts.DummyContract"
|
||||
val OWNER_KEY_PAIR = Crypto.generateKeyPair()
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ class PackageOwnershipVerificationTests {
|
||||
},
|
||||
networkParameters = testNetworkParameters(
|
||||
packageOwnership = mapOf(
|
||||
"net.corda.core.contracts" to OWNER_KEY_PAIR.public,
|
||||
"net.corda.coretests.contracts" to OWNER_KEY_PAIR.public,
|
||||
"net.corda.isolated.workflows" to BOB_PUBKEY
|
||||
),
|
||||
notaries = listOf(NotaryInfo(DUMMY_NOTARY, true))
|
@ -1,5 +1,6 @@
|
||||
package net.corda.core.contracts
|
||||
package net.corda.coretests.contracts
|
||||
|
||||
import net.corda.core.contracts.TimeWindow
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.internal.times
|
||||
import net.corda.core.utilities.millis
|
@ -1,6 +1,10 @@
|
||||
package net.corda.core.contracts
|
||||
package net.corda.coretests.contracts
|
||||
|
||||
import net.corda.core.contracts.Contract
|
||||
import net.corda.core.contracts.TransactionVerificationException
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.internal.createContractCreationError
|
||||
import net.corda.core.internal.createContractRejection
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.serialization.internal.AMQP_RPC_CLIENT_CONTEXT
|
||||
import net.corda.serialization.internal.AllWhitelist
|
||||
@ -48,7 +52,7 @@ class TransactionVerificationExceptionSerialisationTests {
|
||||
val contract = TestContract(12)
|
||||
val cause = Throwable("wibble")
|
||||
|
||||
val exception = TransactionVerificationException.ContractRejection(txid, contract, cause)
|
||||
val exception = createContractRejection(txid, contract, cause)
|
||||
val exception2 = DeserializationInput(factory).deserialize(
|
||||
SerializationOutput(factory).serialize(exception, context),
|
||||
context)
|
||||
@ -85,7 +89,7 @@ class TransactionVerificationExceptionSerialisationTests {
|
||||
@Test
|
||||
fun contractCreationErrorTest() {
|
||||
val cause = Throwable("wibble")
|
||||
val exception = TransactionVerificationException.ContractCreationError(txid, "Some contract class", cause)
|
||||
val exception = createContractCreationError(txid, "Some contract class", cause)
|
||||
val exception2 = DeserializationInput(factory).deserialize(
|
||||
SerializationOutput(factory).serialize(exception, context),
|
||||
context)
|
@ -1,5 +1,6 @@
|
||||
package net.corda.core.crypto
|
||||
package net.corda.coretests.crypto
|
||||
|
||||
import net.corda.core.crypto.*
|
||||
import net.corda.core.crypto.CompositeKey.NodeAndWeight
|
||||
import net.corda.core.internal.declaredField
|
||||
import net.corda.core.internal.div
|
@ -1,12 +1,14 @@
|
||||
package net.corda.core.crypto
|
||||
package net.corda.coretests.crypto
|
||||
|
||||
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.*
|
||||
import net.corda.core.crypto.SecureHash.Companion.zeroHash
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.accessLeafIndex
|
||||
import net.corda.core.node.NotaryInfo
|
||||
import net.corda.core.serialization.deserialize
|
||||
import net.corda.core.serialization.serialize
|
||||
@ -25,7 +27,6 @@ import net.corda.testing.dsl.TestLedgerDSLInterpreter
|
||||
import net.corda.testing.dsl.TestTransactionDSLInterpreter
|
||||
import net.corda.testing.internal.TEST_TX_TIME
|
||||
import net.corda.testing.internal.createWireTransaction
|
||||
import net.corda.testing.internal.rigorousMock
|
||||
import net.corda.testing.node.MockServices
|
||||
import net.corda.testing.node.ledger
|
||||
import org.junit.Before
|
||||
@ -306,37 +307,37 @@ class PartialMerkleTreeTest {
|
||||
|
||||
val pmt = PartialMerkleTree.build(merkleTree, listOf<SecureHash>(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<MerkleTreeException> { pmt.leafIndex(SecureHash.sha256("10")) }
|
||||
assertFailsWith<MerkleTreeException> { 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<MerkleTreeException> { pmt.leafIndex(SecureHash.sha256("30")) }
|
||||
assertFailsWith<MerkleTreeException> { pmt.accessLeafIndex(SecureHash.sha256("30")) }
|
||||
|
||||
val pmtFirstElementOnly = PartialMerkleTree.build(merkleTree, listOf<SecureHash>(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<MerkleTreeException> { pmtFirstElementOnly.leafIndex(SecureHash.sha256("10")) }
|
||||
assertFailsWith<MerkleTreeException> { pmtFirstElementOnly.accessLeafIndex(SecureHash.sha256("10")) }
|
||||
|
||||
val pmtLastElementOnly = PartialMerkleTree.build(merkleTree, listOf<SecureHash>(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<MerkleTreeException> { pmtLastElementOnly.leafIndex(SecureHash.sha256("10")) }
|
||||
assertFailsWith<MerkleTreeException> { pmtLastElementOnly.accessLeafIndex(SecureHash.sha256("10")) }
|
||||
|
||||
val pmtOneElement = PartialMerkleTree.build(merkleTree, listOf<SecureHash>(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<MerkleTreeException> { pmtOneElement.leafIndex(SecureHash.sha256("10")) }
|
||||
assertFailsWith<MerkleTreeException> { 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<MerkleTreeException> { pmtAllIncluded.leafIndex(SecureHash.sha256("30")) }
|
||||
assertFailsWith<MerkleTreeException> { pmtAllIncluded.accessLeafIndex(SecureHash.sha256("30")) }
|
||||
}
|
||||
|
||||
@Test
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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) {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.corda.core.flows
|
||||
package net.corda.coretests.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Fiber
|
||||
import co.paralleluniverse.fibers.FiberExecutorScheduler
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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<SignedTransaction> {
|
||||
return startFlow(::FinalityInvoker, stx, recipients.toSet(), emptySet()).andRunNetwork()
|
||||
return startFlow(WithFinality::FinalityInvoker, stx, recipients.toSet(), emptySet()).andRunNetwork()
|
||||
}
|
||||
//endregion
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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())
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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<FilteredTransactionVerificationException> { 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<FilteredTransactionVerificationException> { ftxAlterSigner.verify() }
|
||||
// Also, checkAllComponentsVisible() will not pass (groupHash matching will fail).
|
||||
assertFailsWith<ComponentVisibilityException> { 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<FilteredTransactionVerificationException> { ftxAlterSignerB.verify() }
|
||||
// Also, checkAllComponentsVisible() will not pass (top level Merkle tree cannot be verified against transaction's id).
|
@ -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
|
@ -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<IdentityServiceInternal>().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.")
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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<TransactionVerificationException.NotaryChangeInWrongTransactionType> { buildTransaction().verify() }
|
@ -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
|
@ -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
|
@ -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
|
@ -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(
|
||||
|
@ -100,7 +100,7 @@ object RetrieveAnyTransactionPayload : ArrayList<Any>()
|
||||
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
|
||||
}
|
||||
|
||||
|
12
core/src/test/README.md
Normal file
12
core/src/test/README.md
Normal file
@ -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`.
|
||||
|
||||
|
||||
|
@ -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<Int>()
|
||||
private val f2 = openFuture<Double>()
|
||||
private var invocations = 0
|
||||
private val log = rigorousMock<Logger>().also {
|
||||
private val log = mock<Logger>().also {
|
||||
doNothing().whenever(it).error(any(), any<Throwable>())
|
||||
}
|
||||
|
||||
|
@ -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<Int>()
|
||||
val x = Exception()
|
||||
val log = rigorousMock<Logger>()
|
||||
val log = mock<Logger>()
|
||||
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<Int>()
|
||||
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<Int>()
|
||||
val g = f.flatMap(block)
|
||||
val x = Exception()
|
||||
@ -103,7 +102,7 @@ class CordaFutureTest {
|
||||
|
||||
@Test
|
||||
fun `andForget works`() {
|
||||
val log = rigorousMock<Logger>()
|
||||
val log = mock<Logger>()
|
||||
doNothing().whenever(log).error(any(), any<Throwable>())
|
||||
val throwable = Exception("Boom")
|
||||
val executor = Executors.newSingleThreadExecutor()
|
||||
|
@ -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<StateAndRef<ContractState>>,
|
||||
outputs: List<TransactionState<ContractState>>,
|
||||
commands: List<CommandWithParties<CommandData>>,
|
||||
attachments: List<Attachment>,
|
||||
id: SecureHash,
|
||||
notary: Party?,
|
||||
timeWindow: TimeWindow?,
|
||||
privacySalt: PrivacySalt,
|
||||
networkParameters: NetworkParameters,
|
||||
references: List<StateAndRef<ContractState>>,
|
||||
componentGroups: List<ComponentGroup>? = null,
|
||||
serializedInputs: List<SerializedStateAndRef>? = null,
|
||||
serializedReferences: List<SerializedStateAndRef>? = 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)
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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')
|
||||
|
@ -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.*
|
||||
|
@ -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
|
||||
|
@ -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.*
|
||||
|
@ -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
|
||||
|
@ -15,6 +15,7 @@ include 'finance:contracts'
|
||||
include 'finance:workflows'
|
||||
include 'isolated'
|
||||
include 'core'
|
||||
include 'core-tests'
|
||||
include 'docs'
|
||||
include 'node-api'
|
||||
include 'node'
|
||||
|
@ -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<out R : Any>(session: FlowSession, override val answer: R, closure: (result: R) -> Unit = {}) : SimpleAnswer<R>(session, closure)
|
||||
|
||||
/**
|
||||
* Allows to simplify writing flows that simply rend a message back to an initiating flow.
|
||||
*/
|
||||
abstract class SimpleAnswer<out R : Any>(private val session: FlowSession, private val closure: (result: R) -> Unit = {}) : FlowLogic<Unit>() {
|
||||
@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<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() = closure()
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts data from a [Map[FlowSession, UntrustworthyData<Any>]] without performing checks and casting to [R].
|
||||
*/
|
||||
@ -118,6 +93,6 @@ inline fun <reified P : FlowLogic<*>> TestStartedNode.registerCordappFlowFactory
|
||||
|
||||
fun <T : FlowLogic<*>> TestStartedNode.registerCoreFlowFactory(initiatingFlowClass: Class<out FlowLogic<*>>,
|
||||
initiatedFlowClass: Class<T>,
|
||||
flowFactory: (FlowSession) -> T , track: Boolean): Observable<T> {
|
||||
flowFactory: (FlowSession) -> T, track: Boolean): Observable<T> {
|
||||
return this.internals.registerInitiatedFlowFactory(initiatingFlowClass, initiatedFlowClass, InitiatedFlowFactory.Core(flowFactory), track)
|
||||
}
|
Loading…
Reference in New Issue
Block a user