Backport merge fixes added to ENT (#4618)

Fix test and address code review comments.
This commit is contained in:
Tudor Malene 2019-01-29 13:45:04 +00:00 committed by GitHub
parent 8f3e527d98
commit 262a7ad1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 135 additions and 131 deletions

View File

@ -2,9 +2,6 @@ package net.corda.serialization.reproduction;
import net.corda.client.rpc.CordaRPCClient; import net.corda.client.rpc.CordaRPCClient;
import net.corda.core.concurrent.CordaFuture; 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.node.services.Permissions;
import net.corda.testing.driver.Driver; import net.corda.testing.driver.Driver;
import net.corda.testing.driver.DriverParameters; import net.corda.testing.driver.DriverParameters;
@ -14,10 +11,7 @@ import net.corda.testing.node.User;
import org.junit.Test; import org.junit.Test;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class GenericReturnFailureReproductionIntegrationTest { public class GenericReturnFailureReproductionIntegrationTest {
@ -36,33 +30,7 @@ public class GenericReturnFailureReproductionIntegrationTest {
} }
@StartableByRPC
public static class SuperSimpleGenericFlow extends FlowLogic<GenericHolder<String>> {
public SuperSimpleGenericFlow() {
}
@Override
public GenericHolder<String> call() {
return new GenericHolder<>(IntStream.of(100).mapToObj((i) -> "" + i).collect(Collectors.toList()));
}
}
@CordaSerializable
public static class GenericHolder<S> {
private final List<S> items;
public GenericHolder(List<S> items) {
this.items = items;
}
public List<S> getItems() {
return items;
}
}
private static <Y> Y getOrThrow(CordaFuture<Y> future) { private static <Y> Y getOrThrow(CordaFuture<Y> future) {
try { try {
return future.get(); return future.get();
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {

View File

@ -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<GenericHolder<String>> {
public SuperSimpleGenericFlow() {
}
@Override
public GenericHolder<String> call() {
return new GenericHolder<>(IntStream.of(100).mapToObj((i) -> "" + i).collect(Collectors.toList()));
}
}
@CordaSerializable
class GenericHolder<S> {
private final List<S> items;
GenericHolder(List<S> items) {
this.items = items;
}
public List<S> getItems() {
return items;
}
}

View File

@ -81,6 +81,7 @@ class HashLookupCommandTest {
private fun issueTransaction(node: NodeHandle): SecureHash { private fun issueTransaction(node: NodeHandle): SecureHash {
return node.rpc.startFlow(::DummyIssue).returnValue.get() return node.rpc.startFlow(::DummyIssue).returnValue.get()
} }
}
@StartableByRPC @StartableByRPC
internal class DummyIssue : FlowLogic<SecureHash>() { internal class DummyIssue : FlowLogic<SecureHash>() {
@ -94,4 +95,3 @@ class HashLookupCommandTest {
return stx.id return stx.id
} }
} }
}

View File

@ -148,7 +148,7 @@ class InteractiveShellIntegrationTest {
@Ignore @Ignore
@Test @Test
fun `ssh runs flows via standalone shell`() { fun `ssh runs flows via standalone shell`() {
val user = User("u", "p", setOf(Permissions.startFlow<SSHServerTest.FlowICanRun>(), val user = User("u", "p", setOf(Permissions.startFlow<FlowICanRun>(),
Permissions.invokeRpc(CordaRPCOps::registeredFlows), Permissions.invokeRpc(CordaRPCOps::registeredFlows),
Permissions.invokeRpc(CordaRPCOps::nodeInfo))) Permissions.invokeRpc(CordaRPCOps::nodeInfo)))
driver(DriverParameters(notarySpecs = emptyList())) { driver(DriverParameters(notarySpecs = emptyList())) {
@ -191,7 +191,7 @@ class InteractiveShellIntegrationTest {
@Ignore @Ignore
@Test @Test
fun `ssh run flows via standalone shell over ssl to node`() { fun `ssh run flows via standalone shell over ssl to node`() {
val user = User("mark", "dadada", setOf(Permissions.startFlow<SSHServerTest.FlowICanRun>(), val user = User("mark", "dadada", setOf(Permissions.startFlow<FlowICanRun>(),
Permissions.invokeRpc(CordaRPCOps::registeredFlows), Permissions.invokeRpc(CordaRPCOps::registeredFlows),
Permissions.invokeRpc(CordaRPCOps::nodeInfo)/*all()*/)) Permissions.invokeRpc(CordaRPCOps::nodeInfo)/*all()*/))
@ -245,33 +245,6 @@ class InteractiveShellIntegrationTest {
} }
} }
@Suppress("UNUSED")
@StartableByRPC
class NoOpFlow : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP!")
}
}
@Suppress("UNUSED")
@StartableByRPC
class NoOpFlowA : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP! (A)")
}
}
@Suppress("UNUSED")
@StartableByRPC
class BurbleFlow : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP! (Burble)")
}
}
@Test @Test
fun `shell should start flow with fully qualified class name`() { fun `shell should start flow with fully qualified class name`() {
val user = User("u", "p", setOf(all())) val user = User("u", "p", setOf(all()))
@ -298,7 +271,7 @@ class InteractiveShellIntegrationTest {
on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() }
} }
InteractiveShell.runFlowByNameFragment( InteractiveShell.runFlowByNameFragment(
InteractiveShellIntegrationTest::class.qualifiedName + "\$NoOpFlow", "NoOpFlow",
"", output, node.rpc, ansiProgressRenderer) "", output, node.rpc, ansiProgressRenderer)
} }
assertThat(successful).isTrue() assertThat(successful).isTrue()
@ -330,7 +303,7 @@ class InteractiveShellIntegrationTest {
on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() }
} }
InteractiveShell.runFlowByNameFragment( InteractiveShell.runFlowByNameFragment(
"InteractiveShellIntegrationTest\$NoOpFlowA", "NoOpFlowA",
"", output, node.rpc, ansiProgressRenderer) "", output, node.rpc, ansiProgressRenderer)
} }
assertThat(successful).isTrue() assertThat(successful).isTrue()
@ -362,7 +335,7 @@ class InteractiveShellIntegrationTest {
on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() } on { render(any(), any()) } doAnswer { InteractiveShell.latch.countDown() }
} }
InteractiveShell.runFlowByNameFragment( InteractiveShell.runFlowByNameFragment(
InteractiveShellIntegrationTest::class.qualifiedName + "\$NoOpFlo", "NoOpFlo",
"", output, node.rpc, ansiProgressRenderer) "", output, node.rpc, ansiProgressRenderer)
} }
assertThat(successful).isTrue() assertThat(successful).isTrue()
@ -400,3 +373,30 @@ class InteractiveShellIntegrationTest {
assertThat(successful).isTrue() assertThat(successful).isTrue()
} }
} }
@Suppress("UNUSED")
@StartableByRPC
class NoOpFlow : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP!")
}
}
@Suppress("UNUSED")
@StartableByRPC
class NoOpFlowA : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP! (A)")
}
}
@Suppress("UNUSED")
@StartableByRPC
class BurbleFlow : FlowLogic<Unit>() {
override val progressTracker = ProgressTracker()
override fun call() {
println("NO OP! (Burble)")
}
}

View File

@ -150,10 +150,12 @@ class SSHServerTest {
session.disconnect() session.disconnect()
// There are ANSI control characters involved, so we want to avoid direct byte to byte matching. // 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 @StartableByRPC
@InitiatingFlow @InitiatingFlow
class FlowICanRun : FlowLogic<String>() { class FlowICanRun : FlowLogic<String>() {
@ -178,4 +180,3 @@ class SSHServerTest {
override val progressTracker: ProgressTracker? = ProgressTracker() override val progressTracker: ProgressTracker? = ProgressTracker()
} }
}

View File

@ -110,20 +110,6 @@ class InteractiveShellTest {
""".trimIndent() """.trimIndent()
} }
@Suppress("UNUSED")
class FlowA(val a: String) : FlowLogic<String>() {
constructor(b: Int?) : this(b.toString())
constructor(b: Int?, c: String) : this(b.toString() + c)
constructor(amount: Amount<Currency>) : this(amount.toString())
constructor(pair: Pair<Amount<Currency>, SecureHash.SHA256>) : this(pair.toString())
constructor(party: Party) : this(party.name.toString())
constructor(b: Int?, amount: Amount<UserValue>) : this("${(b ?: 0) + amount.quantity} ${amount.token}")
constructor(b: Array<String>) : this(b.joinToString("+"))
constructor(amounts: Array<Amount<UserValue>>) : this(amounts.joinToString("++", transform = Amount<UserValue>::toString))
override val progressTracker = ProgressTracker()
override fun call() = a
}
private val ids = InMemoryIdentityService(listOf(megaCorp.identity), DEV_ROOT_CA.certificate) private val ids = InMemoryIdentityService(listOf(megaCorp.identity), DEV_ROOT_CA.certificate)
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
@ -198,11 +184,11 @@ class InteractiveShellTest {
check("", expected = "") check("", expected = "")
} }
val correct = setOf( val correct = setOf(
"[amounts: Amount<InteractiveShellTest.UserValue>[]]: missing parameter amounts", "[amounts: Amount<UserValue>[]]: missing parameter amounts",
"[amount: Amount<Currency>]: missing parameter amount", "[amount: Amount<Currency>]: missing parameter amount",
"[pair: Pair<Amount<Currency>, SecureHash.SHA256>]: missing parameter pair", "[pair: Pair<Amount<Currency>, SecureHash.SHA256>]: missing parameter pair",
"[party: Party]: missing parameter party", "[party: Party]: missing parameter party",
"[b: Integer, amount: Amount<InteractiveShellTest.UserValue>]: missing parameter b", "[b: Integer, amount: Amount<UserValue>]: missing parameter b",
"[b: String[]]: missing parameter b", "[b: String[]]: missing parameter b",
"[b: Integer, c: String]: missing parameter b", "[b: Integer, c: String]: missing parameter b",
"[a: String]: missing parameter a", "[a: String]: missing parameter a",
@ -245,8 +231,24 @@ class InteractiveShellTest {
verify(printWriter).println(NETWORK_MAP_JSON_PAYLOAD.replace("\n", System.lineSeparator())) verify(printWriter).println(NETWORK_MAP_JSON_PAYLOAD.replace("\n", System.lineSeparator()))
} }
}
@ToStringSerialize @ToStringSerialize
data class UserValue(@JsonProperty("label") val label: String) { data class UserValue(@JsonProperty("label") val label: String) {
override fun toString() = label override fun toString() = label
} }
@Suppress("UNUSED")
class FlowA(val a: String) : FlowLogic<String>() {
constructor(b: Int?) : this(b.toString())
constructor(b: Int?, c: String) : this(b.toString() + c)
constructor(amount: Amount<Currency>) : this(amount.toString())
constructor(pair: Pair<Amount<Currency>, SecureHash.SHA256>) : this(pair.toString())
constructor(party: Party) : this(party.name.toString())
constructor(b: Int?, amount: Amount<UserValue>) : this("${(b ?: 0) + amount.quantity} ${amount.token}")
constructor(b: Array<String>) : this(b.joinToString("+"))
constructor(amounts: Array<Amount<UserValue>>) : this(amounts.joinToString("++", transform = Amount<UserValue>::toString))
override val progressTracker = ProgressTracker()
override fun call() = a
} }