mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
No longer using deprecated MockNetwork c'tor (#4481)
This commit is contained in:
parent
5e16961fee
commit
9a484998bb
@ -1,11 +1,11 @@
|
||||
package net.corda.core.flows;
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import net.corda.core.identity.Party;
|
||||
import net.corda.testing.core.TestConstants;
|
||||
import net.corda.testing.node.MockNetwork;
|
||||
import net.corda.testing.node.MockNetworkParameters;
|
||||
import net.corda.testing.node.StartedMockNode;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -15,11 +15,14 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static net.corda.testing.core.TestUtils.singleIdentity;
|
||||
import static net.corda.testing.node.internal.TestCordappsUtilsKt.cordappsForPackages;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class FlowsInJavaTest {
|
||||
private final MockNetwork mockNet = new MockNetwork(ImmutableList.of("net.corda.core.flows"));
|
||||
private final MockNetwork mockNet = new MockNetwork(
|
||||
new MockNetworkParameters().withCordappsForAllNodes(cordappsForPackages("net.corda.core.flows"))
|
||||
);
|
||||
private StartedMockNode aliceNode;
|
||||
private StartedMockNode bobNode;
|
||||
private Party bob;
|
||||
|
@ -13,7 +13,9 @@ import net.corda.core.utilities.unwrap
|
||||
import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.StartedMockNode
|
||||
import net.corda.testing.node.internal.cordappsForPackages
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -36,11 +38,9 @@ class ResolveTransactionsFlowTest {
|
||||
private lateinit var miniCorp: Party
|
||||
private lateinit var notary: Party
|
||||
|
||||
private lateinit var rootTx: SignedTransaction
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts", "net.corda.core.internal"))
|
||||
mockNet = MockNetwork(MockNetworkParameters(cordappsForAllNodes = cordappsForPackages("net.corda.testing.contracts", javaClass.packageName)))
|
||||
notaryNode = mockNet.defaultNotaryNode
|
||||
megaCorpNode = mockNet.createPartyNode(CordaX500Name("MegaCorp", "London", "GB"))
|
||||
miniCorpNode = mockNet.createPartyNode(CordaX500Name("MiniCorp", "London", "GB"))
|
||||
|
@ -13,7 +13,7 @@ import org.junit.After
|
||||
import org.junit.Test
|
||||
|
||||
class CashConfigDataFlowTest {
|
||||
private val mockNet = MockNetwork(emptyList(), MockNetworkParameters(threadPerNode = true))
|
||||
private val mockNet = MockNetwork(MockNetworkParameters(threadPerNode = true))
|
||||
|
||||
@After
|
||||
fun cleanUp() = mockNet.stopNodes()
|
||||
|
@ -26,7 +26,7 @@ class FlowRegistrationTest {
|
||||
@Before
|
||||
fun setup() {
|
||||
// no cordapps scanned so it can be tested in isolation
|
||||
mockNetwork = MockNetwork(emptyList())
|
||||
mockNetwork = MockNetwork()
|
||||
initiator = mockNetwork.createNode(MockNodeParameters(legalName = CordaX500Name("initiator", "Reading", "GB")))
|
||||
responder = mockNetwork.createNode(MockNodeParameters(legalName = CordaX500Name("responder", "Reading", "GB")))
|
||||
mockNetwork.runNetwork()
|
||||
|
@ -5,12 +5,15 @@ import com.esotericsoftware.kryo.KryoException
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.internal.packageName
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
||||
import net.corda.testing.common.internal.testNetworkParameters
|
||||
import net.corda.testing.core.TestIdentity
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.MockServices
|
||||
import net.corda.testing.node.internal.cordappsForPackages
|
||||
import net.corda.testing.node.makeTestIdentityService
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@ -34,16 +37,15 @@ class ExposeJpaToFlowsTests {
|
||||
}
|
||||
|
||||
val myself = TestIdentity(CordaX500Name("Me", "London", "GB"))
|
||||
val cordapps = listOf("net.corda.node.services.persistence")
|
||||
lateinit var mockNet: MockNetwork
|
||||
lateinit var services: MockServices
|
||||
lateinit var database: CordaPersistence
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockNet = MockNetwork(cordapps)
|
||||
mockNet = MockNetwork(MockNetworkParameters(cordappsForAllNodes = cordappsForPackages(javaClass.packageName)))
|
||||
val (db, mockServices) = MockServices.makeTestDatabaseAndMockServices(
|
||||
cordappPackages = cordapps,
|
||||
cordappPackages = listOf(javaClass.packageName),
|
||||
identityService = makeTestIdentityService(myself.identity),
|
||||
initialIdentity = myself,
|
||||
networkParameters = testNetworkParameters(minimumPlatformVersion = 4)
|
||||
|
@ -10,7 +10,7 @@ class MockNetworkIntegrationTests {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
MockNetwork(emptyList()).run {
|
||||
MockNetwork().run {
|
||||
repeat(2) { createNode() }
|
||||
runNetwork()
|
||||
stopNodes()
|
||||
|
@ -282,10 +282,6 @@ inline fun <reified F : FlowLogic<*>> StartedMockNode.registerResponderFlow(
|
||||
* method. If you want messages to flow automatically, use automatic pumping with a thread per node but watch out
|
||||
* for code running parallel to your unit tests: you will need to use futures correctly to ensure race-free results.
|
||||
*
|
||||
* You can get a printout of every message sent by using code like:
|
||||
*
|
||||
* LogHelper.setLevel("+messages")
|
||||
*
|
||||
* By default a single notary node is automatically started, which forms part of the network parameters for all the nodes.
|
||||
* This node is available by calling [defaultNotaryNode].
|
||||
*
|
||||
@ -321,7 +317,9 @@ open class MockNetwork(
|
||||
@Deprecated("cordappPackages does not preserve the original CorDapp's versioning and metadata, which may lead to " +
|
||||
"misleading results in tests. Use MockNetworkParameters.cordappsForAllNodes instead.")
|
||||
@JvmOverloads
|
||||
constructor(cordappPackages: List<String>, parameters: MockNetworkParameters = MockNetworkParameters()) : this(cordappPackages, defaultParameters = parameters)
|
||||
constructor(cordappPackages: List<String>, parameters: MockNetworkParameters = MockNetworkParameters()) : this(
|
||||
cordappPackages, defaultParameters = parameters
|
||||
)
|
||||
|
||||
@JvmOverloads
|
||||
constructor(parameters: MockNetworkParameters = MockNetworkParameters()) : this(emptyList(), parameters)
|
||||
|
@ -1,18 +0,0 @@
|
||||
package net.corda.testing.node;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class MockNodeFactoryInJavaTest {
|
||||
/**
|
||||
* Does not need to run, only compile.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void factoryIsEasyToPassInUsingJava() {
|
||||
//noinspection Convert2MethodRef
|
||||
new MockNetwork(emptyList());
|
||||
new MockNetwork(emptyList(), new MockNetworkParameters().withThreadPerNode(true));
|
||||
//noinspection Convert2MethodRef
|
||||
new MockNetwork(emptyList()).createNode(new MockNodeParameters());
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import org.junit.rules.ExpectedException;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static net.corda.testing.node.internal.TestCordappsUtilsKt.cordappsForPackages;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.instanceOf;
|
||||
*/
|
||||
public class TestResponseFlowInIsolationInJava {
|
||||
|
||||
private final MockNetwork network = new MockNetwork(singletonList("com.template"));
|
||||
private final MockNetwork network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(cordappsForPackages("com.template")));
|
||||
private final StartedMockNode a = network.createNode();
|
||||
private final StartedMockNode b = network.createNode();
|
||||
|
||||
|
@ -16,7 +16,7 @@ class MockNetworkTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
mockNetwork = MockNetwork(cordappPackages = emptyList())
|
||||
mockNetwork = MockNetwork()
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -6,6 +6,7 @@ import net.corda.core.identity.Party
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.testing.internal.chooseIdentity
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.registerResponderFlow
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.After
|
||||
@ -22,7 +23,7 @@ import kotlin.test.assertFailsWith
|
||||
*/
|
||||
class TestResponseFlowInIsolation {
|
||||
|
||||
private val network: MockNetwork = MockNetwork(listOf("com.template"))
|
||||
private val network: MockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = cordappsForPackages("com.template")))
|
||||
private val a = network.createNode()
|
||||
private val b = network.createNode()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user