From 8a3299fa2a7d4183b0c35673a416b932b0ec5fe4 Mon Sep 17 00:00:00 2001 From: Andrzej Cichocki Date: Thu, 4 Jan 2018 10:09:04 +0000 Subject: [PATCH] CORDA-716 Configure api scanner for test modules (#2259) --- .ci/api-current.txt | 3 +++ testing/node-driver/build.gradle | 1 + .../src/main/kotlin/net/corda/testing/driver/Driver.kt | 3 +++ .../src/main/kotlin/net/corda/testing/driver/DriverDSL.kt | 2 ++ .../kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt | 4 +++- .../src/main/kotlin/net/corda/testing/node/MockNode.kt | 2 ++ .../src/main/kotlin/net/corda/testing/node/NotarySpec.kt | 2 ++ testing/test-common/build.gradle | 1 + testing/test-utils/build.gradle | 1 + .../test-utils/src/main/kotlin/net/corda/testing/Expect.kt | 2 ++ .../main/kotlin/net/corda/testing/SerializationTestHelpers.kt | 2 ++ .../main/kotlin/net/corda/testing/contracts/DummyContract.kt | 2 ++ .../main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt | 4 ++++ .../src/main/kotlin/net/corda/testing/dsl/TestDSL.kt | 2 ++ .../kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt | 2 ++ 15 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.ci/api-current.txt b/.ci/api-current.txt index 896cdd2592..f3eee165fa 100644 --- a/.ci/api-current.txt +++ b/.ci/api-current.txt @@ -3522,6 +3522,9 @@ public static final class net.corda.client.jackson.StringToMethodCallParser$Unpa public (String) @org.jetbrains.annotations.NotNull public final String getMethodName() ## +public static interface net.corda.testing.node.InMemoryMessagingNetwork$LatencyCalculator + @org.jetbrains.annotations.NotNull public abstract java.time.Duration between(net.corda.core.messaging.SingleMessageRecipient, net.corda.core.messaging.SingleMessageRecipient) +## public final class net.corda.client.rpc.CordaRPCClient extends java.lang.Object public (net.corda.core.utilities.NetworkHostAndPort) public (net.corda.core.utilities.NetworkHostAndPort, net.corda.client.rpc.CordaRPCClientConfiguration) diff --git a/testing/node-driver/build.gradle b/testing/node-driver/build.gradle index 5663251bc2..90f551c4aa 100644 --- a/testing/node-driver/build.gradle +++ b/testing/node-driver/build.gradle @@ -2,6 +2,7 @@ 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' apply plugin: 'com.jfrog.artifactory' //noinspection GroovyAssignabilityCheck diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt index 577a00b479..11e95e450b 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -3,6 +3,7 @@ package net.corda.testing.driver import net.corda.client.rpc.CordaRPCClient +import net.corda.core.DoNotImplement import net.corda.core.concurrent.CordaFuture import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -30,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger */ data class NotaryHandle(val identity: Party, val validating: Boolean, val nodeHandles: CordaFuture>) +@DoNotImplement sealed class NodeHandle { abstract val nodeInfo: NodeInfo /** @@ -90,6 +92,7 @@ data class WebserverHandle( val process: Process ) +@DoNotImplement sealed class PortAllocation { abstract fun nextPort(): Int fun nextHostAndPort() = NetworkHostAndPort("localhost", nextPort()) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/DriverDSL.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/DriverDSL.kt index d8d3d1b49a..a4908d5f53 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/DriverDSL.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/DriverDSL.kt @@ -1,5 +1,6 @@ package net.corda.testing.driver +import net.corda.core.DoNotImplement import net.corda.core.concurrent.CordaFuture import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -10,6 +11,7 @@ import net.corda.nodeapi.internal.config.User import net.corda.testing.node.NotarySpec import java.nio.file.Path +@DoNotImplement interface DriverDSL { /** Returns a list of [NotaryHandle]s matching the list of [NotarySpec]s passed into [driver]. */ val notaryHandles: List diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt index 5d805a22b4..96b9a9d4c1 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt @@ -1,5 +1,6 @@ package net.corda.testing.node +import net.corda.core.DoNotImplement import net.corda.core.crypto.CompositeKey import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -120,7 +121,7 @@ class InMemoryMessagingNetwork internal constructor( } } - interface LatencyCalculator { + interface LatencyCalculator { // XXX: Used? fun between(sender: SingleMessageRecipient, receiver: SingleMessageRecipient): Duration } @@ -178,6 +179,7 @@ class InMemoryMessagingNetwork internal constructor( /** * Mock service loadbalancing */ + @DoNotImplement sealed class ServicePeerAllocationStrategy { abstract fun pickNext(service: ServiceHandle, pickFrom: List): A class Random(val random: SplittableRandom = SplittableRandom()) : ServicePeerAllocationStrategy() { diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt index fb4a7ec2e3..fabb3d999a 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -4,6 +4,7 @@ import com.google.common.jimfs.Configuration.unix import com.google.common.jimfs.Jimfs import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.whenever +import net.corda.core.DoNotImplement import net.corda.core.crypto.entropyToKeyPair import net.corda.core.crypto.random63BitValue import net.corda.core.identity.CordaX500Name @@ -490,6 +491,7 @@ fun StartedNode.setMessagingServiceSpy(messagingServiceSpy } private fun mockNodeConfiguration(): NodeConfiguration { + @DoNotImplement abstract class AbstractNodeConfiguration : NodeConfiguration return rigorousMock().also { doReturn("cordacadevpass").whenever(it).keyStorePassword diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/NotarySpec.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/NotarySpec.kt index b8988e50c7..b6533ebd98 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/NotarySpec.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/NotarySpec.kt @@ -1,5 +1,6 @@ package net.corda.testing.node +import net.corda.core.DoNotImplement import net.corda.core.identity.CordaX500Name import net.corda.node.services.config.VerifierType import net.corda.nodeapi.internal.config.User @@ -12,6 +13,7 @@ data class NotarySpec( val cluster: ClusterSpec? = null ) +@DoNotImplement sealed class ClusterSpec { abstract val clusterSize: Int diff --git a/testing/test-common/build.gradle b/testing/test-common/build.gradle index df37173fc1..e68a9dba67 100644 --- a/testing/test-common/build.gradle +++ b/testing/test-common/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'net.corda.plugins.publish-utils' +apply plugin: 'net.corda.plugins.api-scanner' apply plugin: 'com.jfrog.artifactory' dependencies { diff --git a/testing/test-utils/build.gradle b/testing/test-utils/build.gradle index c90b00304e..b67dcbcb2f 100644 --- a/testing/test-utils/build.gradle +++ b/testing/test-utils/build.gradle @@ -2,6 +2,7 @@ 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' apply plugin: 'com.jfrog.artifactory' description 'Testing utilities for Corda' diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/Expect.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/Expect.kt index 0db4754f4c..328a6fdbb3 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/Expect.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/Expect.kt @@ -1,6 +1,7 @@ package net.corda.testing import com.google.common.util.concurrent.SettableFuture +import net.corda.core.DoNotImplement import net.corda.core.internal.uncheckedCast import net.corda.core.utilities.getOrThrow import org.slf4j.Logger @@ -189,6 +190,7 @@ fun S.genericExpectEvents( finishFuture.getOrThrow() } +@DoNotImplement sealed class ExpectCompose { internal class Single(val expect: Expect) : ExpectCompose() internal class Sequential(val sequence: List>) : ExpectCompose() diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt index 8aa5a0cc61..b76f571bc3 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt @@ -2,6 +2,7 @@ package net.corda.testing import com.nhaarman.mockito_kotlin.* import net.corda.client.rpc.internal.KryoClientSerializationScheme +import net.corda.core.DoNotImplement import net.corda.core.internal.staticField import net.corda.core.serialization.internal.* import net.corda.node.serialization.KryoServerSerializationScheme @@ -62,6 +63,7 @@ class SerializationEnvironmentRule(private val inheritable: Boolean = false) : T } } +@DoNotImplement interface GlobalSerializationEnvironment : SerializationEnvironment { /** Unset this environment. */ fun unset() diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyContract.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyContract.kt index 28341e2e92..3355b1fdf0 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyContract.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyContract.kt @@ -1,5 +1,6 @@ package net.corda.testing.contracts +import net.corda.core.DoNotImplement import net.corda.core.contracts.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party @@ -12,6 +13,7 @@ data class DummyContract(val blank: Any? = null) : Contract { val PROGRAM_ID = "net.corda.testing.contracts.DummyContract" + @DoNotImplement // State is effectively a sealed class. interface State : ContractState { val magicNumber: Int } diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt index 869643d2aa..89e9ecb202 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt @@ -1,5 +1,6 @@ package net.corda.testing.dsl +import net.corda.core.DoNotImplement import net.corda.core.contracts.ContractState import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.TransactionState @@ -14,6 +15,7 @@ import java.io.InputStream * This interface defines output state lookup by label. It is split from the interpreter interfaces so that outputs may * be looked up both in ledger{..} and transaction{..} blocks. */ +@DoNotImplement interface OutputStateLookup { /** * Retrieves an output previously defined by [TransactionDSLInterpreter.output] with a label passed in. @@ -27,6 +29,7 @@ interface OutputStateLookup { /** * This interface asserts that the DSL at hand is capable of verifying its underlying construct(ledger/transaction). */ +@DoNotImplement interface Verifies { /** * Verifies the ledger/transaction, throws if the verification fails. @@ -83,6 +86,7 @@ interface Verifies { * * TODO (Kotlin 1.1): Use type synonyms to make the type params less unwieldy */ +@DoNotImplement interface LedgerDSLInterpreter : Verifies, OutputStateLookup { /** * Creates and adds a transaction to the ledger. diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt index bf48a07240..3a0e36e5f3 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt @@ -1,5 +1,6 @@ package net.corda.testing.dsl +import net.corda.core.DoNotImplement import net.corda.core.contracts.* import net.corda.core.cordapp.CordappProvider import net.corda.core.crypto.* @@ -50,6 +51,7 @@ import kotlin.collections.set * will have as the last line either an accept or a failure test. The name is deliberately long to help make sense of * the triggered diagnostic. */ +@DoNotImplement sealed class EnforceVerifyOrFail { internal object Token : EnforceVerifyOrFail() } diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt index b905e62462..61e7ea1c9a 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt @@ -1,5 +1,6 @@ package net.corda.testing.dsl +import net.corda.core.DoNotImplement import net.corda.core.contracts.* import net.corda.core.crypto.SecureHash import net.corda.core.identity.Party @@ -14,6 +15,7 @@ import java.time.Instant * @param The return type of [verifies]/[failsWith] and the like. It is generic so that we have control over whether * we want to enforce users to call these methods (see [EnforceVerifyOrFail]) or not. */ +@DoNotImplement interface TransactionDSLInterpreter : Verifies, OutputStateLookup { /** * A reference to the enclosing ledger{..}'s interpreter.