diff --git a/node/src/integration-test/java/net/corda/serialization/reproduction/GenericReturnFailureReproductionIntegrationTest.java b/node/src/integration-test/java/net/corda/serialization/reproduction/GenericReturnFailureReproductionIntegrationTest.java index f1f3af69c6..b015749f79 100644 --- a/node/src/integration-test/java/net/corda/serialization/reproduction/GenericReturnFailureReproductionIntegrationTest.java +++ b/node/src/integration-test/java/net/corda/serialization/reproduction/GenericReturnFailureReproductionIntegrationTest.java @@ -2,9 +2,6 @@ package net.corda.serialization.reproduction; import net.corda.client.rpc.CordaRPCClient; import net.corda.core.concurrent.CordaFuture; -import net.corda.core.flows.FlowLogic; -import net.corda.core.flows.StartableByRPC; -import net.corda.core.serialization.CordaSerializable; import net.corda.node.services.Permissions; import net.corda.testing.driver.Driver; import net.corda.testing.driver.DriverParameters; @@ -14,10 +11,7 @@ import net.corda.testing.node.User; import org.junit.Test; import java.util.Collections; -import java.util.List; import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; -import java.util.stream.IntStream; public class GenericReturnFailureReproductionIntegrationTest { @@ -36,33 +30,7 @@ public class GenericReturnFailureReproductionIntegrationTest { } - @StartableByRPC - public static class SuperSimpleGenericFlow extends FlowLogic> { - public SuperSimpleGenericFlow() { - } - - @Override - public GenericHolder call() { - return new GenericHolder<>(IntStream.of(100).mapToObj((i) -> "" + i).collect(Collectors.toList())); - } - } - - @CordaSerializable - public static class GenericHolder { - private final List items; - - public GenericHolder(List items) { - this.items = items; - } - - public List getItems() { - return items; - } - } - - private static Y getOrThrow(CordaFuture future) { - try { return future.get(); } catch (InterruptedException | ExecutionException e) { diff --git a/node/src/integration-test/java/net/corda/serialization/reproduction/SuperSimpleGenericFlow.java b/node/src/integration-test/java/net/corda/serialization/reproduction/SuperSimpleGenericFlow.java new file mode 100644 index 0000000000..28ec5464c9 --- /dev/null +++ b/node/src/integration-test/java/net/corda/serialization/reproduction/SuperSimpleGenericFlow.java @@ -0,0 +1,33 @@ +package net.corda.serialization.reproduction; + +import net.corda.core.flows.FlowLogic; +import net.corda.core.flows.StartableByRPC; +import net.corda.core.serialization.CordaSerializable; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@StartableByRPC +public class SuperSimpleGenericFlow extends FlowLogic> { + public SuperSimpleGenericFlow() { + } + + @Override + public GenericHolder call() { + return new GenericHolder<>(IntStream.of(100).mapToObj((i) -> "" + i).collect(Collectors.toList())); + } +} + +@CordaSerializable +class GenericHolder { + private final List items; + + GenericHolder(List items) { + this.items = items; + } + + public List getItems() { + return items; + } +} diff --git a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/HashLookupCommandTest.kt b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/HashLookupCommandTest.kt index e71a4bde3b..d1a912fcb6 100644 --- a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/HashLookupCommandTest.kt +++ b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/HashLookupCommandTest.kt @@ -81,17 +81,17 @@ class HashLookupCommandTest { private fun issueTransaction(node: NodeHandle): SecureHash { return node.rpc.startFlow(::DummyIssue).returnValue.get() } +} - @StartableByRPC - internal class DummyIssue : FlowLogic() { - @Suspendable - override fun call(): SecureHash { - val me = serviceHub.myInfo.legalIdentities.first().ref(0) - val fakeNotary = me.party - val builder = DummyContract.generateInitial(1, fakeNotary as Party, me) - val stx = serviceHub.signInitialTransaction(builder) - serviceHub.recordTransactions(stx) - return stx.id - } +@StartableByRPC +internal class DummyIssue : FlowLogic() { + @Suspendable + override fun call(): SecureHash { + val me = serviceHub.myInfo.legalIdentities.first().ref(0) + val fakeNotary = me.party + val builder = DummyContract.generateInitial(1, fakeNotary as Party, me) + val stx = serviceHub.signInitialTransaction(builder) + serviceHub.recordTransactions(stx) + return stx.id } -} \ No newline at end of file +} diff --git a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/InteractiveShellIntegrationTest.kt b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/InteractiveShellIntegrationTest.kt index f596598b52..ae2e458df0 100644 --- a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/InteractiveShellIntegrationTest.kt +++ b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/InteractiveShellIntegrationTest.kt @@ -148,7 +148,7 @@ class InteractiveShellIntegrationTest { @Ignore @Test fun `ssh runs flows via standalone shell`() { - val user = User("u", "p", setOf(Permissions.startFlow(), + val user = User("u", "p", setOf(Permissions.startFlow(), Permissions.invokeRpc(CordaRPCOps::registeredFlows), Permissions.invokeRpc(CordaRPCOps::nodeInfo))) driver(DriverParameters(notarySpecs = emptyList())) { @@ -191,7 +191,7 @@ class InteractiveShellIntegrationTest { @Ignore @Test fun `ssh run flows via standalone shell over ssl to node`() { - val user = User("mark", "dadada", setOf(Permissions.startFlow(), + val user = User("mark", "dadada", setOf(Permissions.startFlow(), Permissions.invokeRpc(CordaRPCOps::registeredFlows), Permissions.invokeRpc(CordaRPCOps::nodeInfo)/*all()*/)) @@ -245,33 +245,6 @@ class InteractiveShellIntegrationTest { } } - @Suppress("UNUSED") - @StartableByRPC - class NoOpFlow : FlowLogic() { - override val progressTracker = ProgressTracker() - override fun call() { - println("NO OP!") - } - } - - @Suppress("UNUSED") - @StartableByRPC - class NoOpFlowA : FlowLogic() { - override val progressTracker = ProgressTracker() - override fun call() { - println("NO OP! (A)") - } - } - - @Suppress("UNUSED") - @StartableByRPC - class BurbleFlow : FlowLogic() { - override val progressTracker = ProgressTracker() - override fun call() { - println("NO OP! (Burble)") - } - } - @Test fun `shell should start flow with fully qualified class name`() { val user = User("u", "p", setOf(all())) @@ -298,7 +271,7 @@ class InteractiveShellIntegrationTest { on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } } InteractiveShell.runFlowByNameFragment( - InteractiveShellIntegrationTest::class.qualifiedName + "\$NoOpFlow", + "NoOpFlow", "", output, node.rpc, ansiProgressRenderer) } assertThat(successful).isTrue() @@ -330,7 +303,7 @@ class InteractiveShellIntegrationTest { on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } } InteractiveShell.runFlowByNameFragment( - "InteractiveShellIntegrationTest\$NoOpFlowA", + "NoOpFlowA", "", output, node.rpc, ansiProgressRenderer) } assertThat(successful).isTrue() @@ -362,7 +335,7 @@ class InteractiveShellIntegrationTest { on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } } InteractiveShell.runFlowByNameFragment( - InteractiveShellIntegrationTest::class.qualifiedName + "\$NoOpFlo", + "NoOpFlo", "", output, node.rpc, ansiProgressRenderer) } assertThat(successful).isTrue() @@ -399,4 +372,31 @@ class InteractiveShellIntegrationTest { } assertThat(successful).isTrue() } +} + +@Suppress("UNUSED") +@StartableByRPC +class NoOpFlow : FlowLogic() { + override val progressTracker = ProgressTracker() + override fun call() { + println("NO OP!") + } +} + +@Suppress("UNUSED") +@StartableByRPC +class NoOpFlowA : FlowLogic() { + override val progressTracker = ProgressTracker() + override fun call() { + println("NO OP! (A)") + } +} + +@Suppress("UNUSED") +@StartableByRPC +class BurbleFlow : FlowLogic() { + override val progressTracker = ProgressTracker() + override fun call() { + println("NO OP! (Burble)") + } } \ No newline at end of file diff --git a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/SSHServerTest.kt b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/SSHServerTest.kt index 374d1bba13..b60a6b88c7 100644 --- a/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/SSHServerTest.kt +++ b/tools/shell/src/integration-test/kotlin/net/corda/tools/shell/SSHServerTest.kt @@ -150,32 +150,33 @@ class SSHServerTest { session.disconnect() // There are ANSI control characters involved, so we want to avoid direct byte to byte matching. - assertThat(linesWithDoneCount).hasSize(1) + assertThat(linesWithDoneCount).size().isGreaterThanOrEqualTo(1) } } - @StartableByRPC - @InitiatingFlow - class FlowICanRun : FlowLogic() { - - private val HELLO_STEP = ProgressTracker.Step("Hello") - - @Suspendable - override fun call(): String { - progressTracker?.currentStep = HELLO_STEP - return "bambam" - } - - override val progressTracker: ProgressTracker? = ProgressTracker(HELLO_STEP) - } - - @Suppress("unused") - @StartableByRPC - @InitiatingFlow - class FlowICannotRun(private val otherParty: Party) : FlowLogic() { - @Suspendable - override fun call(): String = initiateFlow(otherParty).receive().unwrap { it } - - override val progressTracker: ProgressTracker? = ProgressTracker() - } +} + +@StartableByRPC +@InitiatingFlow +class FlowICanRun : FlowLogic() { + + private val HELLO_STEP = ProgressTracker.Step("Hello") + + @Suspendable + override fun call(): String { + progressTracker?.currentStep = HELLO_STEP + return "bambam" + } + + override val progressTracker: ProgressTracker? = ProgressTracker(HELLO_STEP) +} + +@Suppress("unused") +@StartableByRPC +@InitiatingFlow +class FlowICannotRun(private val otherParty: Party) : FlowLogic() { + @Suspendable + override fun call(): String = initiateFlow(otherParty).receive().unwrap { it } + + override val progressTracker: ProgressTracker? = ProgressTracker() } diff --git a/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt b/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt index 4c103be41d..045e3add54 100644 --- a/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt +++ b/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt @@ -110,20 +110,6 @@ class InteractiveShellTest { """.trimIndent() } - @Suppress("UNUSED") - class FlowA(val a: String) : FlowLogic() { - constructor(b: Int?) : this(b.toString()) - constructor(b: Int?, c: String) : this(b.toString() + c) - constructor(amount: Amount) : this(amount.toString()) - constructor(pair: Pair, SecureHash.SHA256>) : this(pair.toString()) - constructor(party: Party) : this(party.name.toString()) - constructor(b: Int?, amount: Amount) : this("${(b ?: 0) + amount.quantity} ${amount.token}") - constructor(b: Array) : this(b.joinToString("+")) - constructor(amounts: Array>) : this(amounts.joinToString("++", transform = Amount::toString)) - - override val progressTracker = ProgressTracker() - override fun call() = a - } private val ids = InMemoryIdentityService(listOf(megaCorp.identity), DEV_ROOT_CA.certificate) @Suppress("DEPRECATION") @@ -148,7 +134,7 @@ class InteractiveShellTest { return objectMapper } - + @Test fun flowStartSimple() { check("a: Hi there", "Hi there") @@ -161,26 +147,26 @@ class InteractiveShellTest { @Test fun flowStartWithNestedTypes() = check( - input = "pair: { first: $100.12, second: df489807f81c8c8829e509e1bcb92e6692b9dd9d624b7456435cb2f51dc82587 }", - expected = "(100.12 USD, DF489807F81C8C8829E509E1BCB92E6692B9DD9D624B7456435CB2F51DC82587)" + input = "pair: { first: $100.12, second: df489807f81c8c8829e509e1bcb92e6692b9dd9d624b7456435cb2f51dc82587 }", + expected = "(100.12 USD, DF489807F81C8C8829E509E1BCB92E6692B9DD9D624B7456435CB2F51DC82587)" ) @Test fun flowStartWithArrayType() = check( - input = "b: [ One, Two, Three, Four ]", - expected = "One+Two+Three+Four" + input = "b: [ One, Two, Three, Four ]", + expected = "One+Two+Three+Four" ) @Test fun flowStartWithUserAmount() = check( - input = """b: 500, amount: { "quantity": 10001, "token":{ "label": "of value" } }""", - expected = "10501 of value" + input = """b: 500, amount: { "quantity": 10001, "token":{ "label": "of value" } }""", + expected = "10501 of value" ) @Test fun flowStartWithArrayOfNestedTypes() = check( - input = """amounts: [ { "quantity": 10, "token": { "label": "(1)" } }, { "quantity": 200, "token": { "label": "(2)" } } ]""", - expected = "10 (1)++200 (2)" + input = """amounts: [ { "quantity": 10, "token": { "label": "(1)" } }, { "quantity": 200, "token": { "label": "(2)" } } ]""", + expected = "10 (1)++200 (2)" ) @Test(expected = InteractiveShell.NoApplicableConstructor::class) @@ -198,11 +184,11 @@ class InteractiveShellTest { check("", expected = "") } val correct = setOf( - "[amounts: Amount[]]: missing parameter amounts", + "[amounts: Amount[]]: missing parameter amounts", "[amount: Amount]: missing parameter amount", "[pair: Pair, SecureHash.SHA256>]: missing parameter pair", "[party: Party]: missing parameter party", - "[b: Integer, amount: Amount]: missing parameter b", + "[b: Integer, amount: Amount]: missing parameter b", "[b: String[]]: missing parameter b", "[b: Integer, c: String]: missing parameter b", "[a: String]: missing parameter a", @@ -245,8 +231,24 @@ class InteractiveShellTest { verify(printWriter).println(NETWORK_MAP_JSON_PAYLOAD.replace("\n", System.lineSeparator())) } - @ToStringSerialize - data class UserValue(@JsonProperty("label") val label: String) { - override fun toString() = label - } -} \ No newline at end of file +} + +@ToStringSerialize +data class UserValue(@JsonProperty("label") val label: String) { + override fun toString() = label +} + +@Suppress("UNUSED") +class FlowA(val a: String) : FlowLogic() { + constructor(b: Int?) : this(b.toString()) + constructor(b: Int?, c: String) : this(b.toString() + c) + constructor(amount: Amount) : this(amount.toString()) + constructor(pair: Pair, SecureHash.SHA256>) : this(pair.toString()) + constructor(party: Party) : this(party.name.toString()) + constructor(b: Int?, amount: Amount) : this("${(b ?: 0) + amount.quantity} ${amount.token}") + constructor(b: Array) : this(b.joinToString("+")) + constructor(amounts: Array>) : this(amounts.joinToString("++", transform = Amount::toString)) + + override val progressTracker = ProgressTracker() + override fun call() = a +}