mirror of
https://github.com/corda/corda.git
synced 2025-01-24 05:18:24 +00:00
CORDA-716 Retire MockNetwork.Factory (#1937)
This commit is contained in:
parent
6a5f8a2362
commit
6b2b663ab3
@ -14,7 +14,6 @@ import net.corda.testing.ALICE
|
|||||||
import net.corda.testing.ALICE_NAME
|
import net.corda.testing.ALICE_NAME
|
||||||
import net.corda.testing.BOB
|
import net.corda.testing.BOB
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNodeArgs
|
|
||||||
import net.corda.testing.node.MockNodeParameters
|
import net.corda.testing.node.MockNodeParameters
|
||||||
import net.corda.testing.singleIdentity
|
import net.corda.testing.singleIdentity
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
@ -109,13 +108,11 @@ class AttachmentTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `malicious response`() {
|
fun maliciousResponse() {
|
||||||
// Make a node that doesn't do sanity checking at load time.
|
// Make a node that doesn't do sanity checking at load time.
|
||||||
val aliceNode = mockNet.createNotaryNode(MockNodeParameters(legalName = ALICE.name), nodeFactory = object : MockNetwork.Factory<MockNetwork.MockNode> {
|
val aliceNode = mockNet.createNotaryNode(MockNodeParameters(legalName = ALICE.name), nodeFactory = { args ->
|
||||||
override fun create(args: MockNodeArgs): MockNetwork.MockNode {
|
object : MockNetwork.MockNode(args) {
|
||||||
return object : MockNetwork.MockNode(args) {
|
override fun start() = super.start().apply { attachments.checkAttachmentsOnLoad = false }
|
||||||
override fun start() = super.start().apply { attachments.checkAttachmentsOnLoad = false }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, validating = false)
|
}, validating = false)
|
||||||
val bobNode = mockNet.createNode(MockNodeParameters(legalName = BOB.name))
|
val bobNode = mockNet.createNode(MockNodeParameters(legalName = BOB.name))
|
||||||
|
@ -17,7 +17,6 @@ import net.corda.node.services.persistence.NodeAttachmentService
|
|||||||
import net.corda.node.utilities.currentDBSession
|
import net.corda.node.utilities.currentDBSession
|
||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNodeArgs
|
|
||||||
import net.corda.testing.node.MockNodeParameters
|
import net.corda.testing.node.MockNodeParameters
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@ -156,11 +155,9 @@ class AttachmentSerializationTest {
|
|||||||
|
|
||||||
private fun rebootClientAndGetAttachmentContent(checkAttachmentsOnLoad: Boolean = true): String {
|
private fun rebootClientAndGetAttachmentContent(checkAttachmentsOnLoad: Boolean = true): String {
|
||||||
client.dispose()
|
client.dispose()
|
||||||
client = mockNet.createNode(MockNodeParameters(client.internals.id), object : MockNetwork.Factory<MockNetwork.MockNode> {
|
client = mockNet.createNode(MockNodeParameters(client.internals.id), { args ->
|
||||||
override fun create(args: MockNodeArgs): MockNetwork.MockNode {
|
object : MockNetwork.MockNode(args) {
|
||||||
return object : MockNetwork.MockNode(args) {
|
override fun start() = super.start().apply { attachments.checkAttachmentsOnLoad = checkAttachmentsOnLoad }
|
||||||
override fun start() = super.start().apply { attachments.checkAttachmentsOnLoad = checkAttachmentsOnLoad }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return (client.smm.allStateMachines[0].stateMachine.resultFuture.apply { mockNet.runNetwork() }.getOrThrow() as ClientResult).attachmentContent
|
return (client.smm.allStateMachines[0].stateMachine.resultFuture.apply { mockNet.runNetwork() }.getOrThrow() as ClientResult).attachmentContent
|
||||||
|
@ -294,13 +294,11 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
|||||||
// of gets and puts.
|
// of gets and puts.
|
||||||
private fun makeNodeWithTracking(name: CordaX500Name): StartedNode<MockNetwork.MockNode> {
|
private fun makeNodeWithTracking(name: CordaX500Name): StartedNode<MockNetwork.MockNode> {
|
||||||
// Create a node in the mock network ...
|
// Create a node in the mock network ...
|
||||||
return mockNet.createNode(MockNodeParameters(legalName = name), nodeFactory = object : MockNetwork.Factory<MockNetwork.MockNode> {
|
return mockNet.createNode(MockNodeParameters(legalName = name), nodeFactory = { args ->
|
||||||
override fun create(args: MockNodeArgs): MockNetwork.MockNode {
|
object : MockNetwork.MockNode(args) {
|
||||||
return object : MockNetwork.MockNode(args) {
|
// That constructs a recording tx storage
|
||||||
// That constructs a recording tx storage
|
override fun makeTransactionStorage(): WritableTransactionStorage {
|
||||||
override fun makeTransactionStorage(): WritableTransactionStorage {
|
return RecordingTransactionStorage(database, super.makeTransactionStorage())
|
||||||
return RecordingTransactionStorage(database, super.makeTransactionStorage())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,6 @@ import net.corda.node.services.api.VaultServiceInternal
|
|||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.rigorousMock
|
import net.corda.testing.rigorousMock
|
||||||
import net.corda.testing.node.MockNodeArgs
|
|
||||||
import net.corda.testing.node.MockNodeParameters
|
import net.corda.testing.node.MockNodeParameters
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -80,15 +79,13 @@ class VaultSoftLockManagerTest {
|
|||||||
private val mockVault = rigorousMock<VaultServiceInternal>().also {
|
private val mockVault = rigorousMock<VaultServiceInternal>().also {
|
||||||
doNothing().whenever(it).softLockRelease(any(), anyOrNull())
|
doNothing().whenever(it).softLockRelease(any(), anyOrNull())
|
||||||
}
|
}
|
||||||
private val mockNet = MockNetwork(cordappPackages = listOf(ContractImpl::class.packageName), defaultFactory = object : MockNetwork.Factory<MockNetwork.MockNode> {
|
private val mockNet = MockNetwork(cordappPackages = listOf(ContractImpl::class.packageName), defaultFactory = { args ->
|
||||||
override fun create(args: MockNodeArgs): MockNetwork.MockNode {
|
object : MockNetwork.MockNode(args) {
|
||||||
return object : MockNetwork.MockNode(args) {
|
override fun makeVaultService(keyManagementService: KeyManagementService, stateLoader: StateLoader): VaultServiceInternal {
|
||||||
override fun makeVaultService(keyManagementService: KeyManagementService, stateLoader: StateLoader): VaultServiceInternal {
|
val realVault = super.makeVaultService(keyManagementService, stateLoader)
|
||||||
val realVault = super.makeVaultService(keyManagementService, stateLoader)
|
return object : VaultServiceInternal by realVault {
|
||||||
return object : VaultServiceInternal by realVault {
|
override fun softLockRelease(lockId: UUID, stateRefs: NonEmptySet<StateRef>?) {
|
||||||
override fun softLockRelease(lockId: UUID, stateRefs: NonEmptySet<StateRef>?) {
|
mockVault.softLockRelease(lockId, stateRefs) // No need to also call the real one for these tests.
|
||||||
mockVault.softLockRelease(lockId, stateRefs) // No need to also call the real one for these tests.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class IRSSimulation(networkSendManuallyPumped: Boolean, runAsync: Boolean, laten
|
|||||||
val irs = om.readValue<InterestRateSwap.State>(javaClass.classLoader.getResourceAsStream("net/corda/irs/web/simulation/trade.json")
|
val irs = om.readValue<InterestRateSwap.State>(javaClass.classLoader.getResourceAsStream("net/corda/irs/web/simulation/trade.json")
|
||||||
.reader()
|
.reader()
|
||||||
.readText()
|
.readText()
|
||||||
.replace("oracleXXX", RatesOracleFactory.RATES_SERVICE_NAME.toString()))
|
.replace("oracleXXX", RatesOracleNode.RATES_SERVICE_NAME.toString()))
|
||||||
irs.fixedLeg.fixedRatePayer = node1.info.chooseIdentity()
|
irs.fixedLeg.fixedRatePayer = node1.info.chooseIdentity()
|
||||||
irs.floatingLeg.floatingRatePayer = node2.info.chooseIdentity()
|
irs.floatingLeg.floatingRatePayer = node2.info.chooseIdentity()
|
||||||
|
|
||||||
|
@ -50,20 +50,18 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean,
|
|||||||
|
|
||||||
val bankLocations = listOf(Pair("London", "GB"), Pair("Frankfurt", "DE"), Pair("Rome", "IT"))
|
val bankLocations = listOf(Pair("London", "GB"), Pair("Frankfurt", "DE"), Pair("Rome", "IT"))
|
||||||
|
|
||||||
object RatesOracleFactory : MockNetwork.Factory<MockNode> {
|
class RatesOracleNode(args: MockNodeArgs) : MockNode(args) {
|
||||||
// TODO: Make a more realistic legal name
|
companion object {
|
||||||
val RATES_SERVICE_NAME = CordaX500Name(organisation = "Rates Service Provider", locality = "Madrid", country = "ES")
|
// TODO: Make a more realistic legal name
|
||||||
|
val RATES_SERVICE_NAME = CordaX500Name(organisation = "Rates Service Provider", locality = "Madrid", country = "ES")
|
||||||
|
}
|
||||||
|
|
||||||
override fun create(args: MockNodeArgs): MockNode {
|
override fun start() = super.start().apply {
|
||||||
return object : MockNode(args) {
|
registerInitiatedFlow(NodeInterestRates.FixQueryHandler::class.java)
|
||||||
override fun start() = super.start().apply {
|
registerInitiatedFlow(NodeInterestRates.FixSignHandler::class.java)
|
||||||
registerInitiatedFlow(NodeInterestRates.FixQueryHandler::class.java)
|
javaClass.classLoader.getResourceAsStream("net/corda/irs/simulation/example.rates.txt").use {
|
||||||
registerInitiatedFlow(NodeInterestRates.FixSignHandler::class.java)
|
database.transaction {
|
||||||
javaClass.classLoader.getResourceAsStream("net/corda/irs/simulation/example.rates.txt").use {
|
findTokenizableService(NodeInterestRates.Oracle::class.java)!!.uploadFixes(it.reader().readText())
|
||||||
database.transaction {
|
|
||||||
findTokenizableService(NodeInterestRates.Oracle::class.java)!!.uploadFixes(it.reader().readText())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +76,7 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean,
|
|||||||
// So we just fire a message at a node that doesn't know how to handle it, and it'll ignore it.
|
// So we just fire a message at a node that doesn't know how to handle it, and it'll ignore it.
|
||||||
// But that's fine for visualisation purposes.
|
// But that's fine for visualisation purposes.
|
||||||
val regulators = listOf(mockNet.createUnstartedNode(defaultParams.copy(legalName = DUMMY_REGULATOR.name)))
|
val regulators = listOf(mockNet.createUnstartedNode(defaultParams.copy(legalName = DUMMY_REGULATOR.name)))
|
||||||
val ratesOracle = mockNet.createUnstartedNode(defaultParams.copy(legalName = RatesOracleFactory.RATES_SERVICE_NAME), RatesOracleFactory)
|
val ratesOracle = mockNet.createUnstartedNode(defaultParams.copy(legalName = RatesOracleNode.RATES_SERVICE_NAME), ::RatesOracleNode)
|
||||||
// All nodes must be in one of these two lists for the purposes of the visualiser tool.
|
// All nodes must be in one of these two lists for the purposes of the visualiser tool.
|
||||||
val serviceProviders: List<MockNode> = listOf(notary.internals, ratesOracle)
|
val serviceProviders: List<MockNode> = listOf(notary.internals, ratesOracle)
|
||||||
val banks: List<MockNode> = bankLocations.mapIndexed { i, (city, country) ->
|
val banks: List<MockNode> = bankLocations.mapIndexed { i, (city, country) ->
|
||||||
|
@ -63,13 +63,13 @@ data class MockNetworkParameters(
|
|||||||
val networkSendManuallyPumped: Boolean = false,
|
val networkSendManuallyPumped: Boolean = false,
|
||||||
val threadPerNode: Boolean = false,
|
val threadPerNode: Boolean = false,
|
||||||
val servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random(),
|
val servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random(),
|
||||||
val defaultFactory: MockNetwork.Factory<*> = MockNetwork.DefaultFactory,
|
val defaultFactory: (MockNodeArgs) -> MockNetwork.MockNode = MockNetwork::MockNode,
|
||||||
val initialiseSerialization: Boolean = true,
|
val initialiseSerialization: Boolean = true,
|
||||||
val cordappPackages: List<String> = emptyList()) {
|
val cordappPackages: List<String> = emptyList()) {
|
||||||
fun setNetworkSendManuallyPumped(networkSendManuallyPumped: Boolean) = copy(networkSendManuallyPumped = networkSendManuallyPumped)
|
fun setNetworkSendManuallyPumped(networkSendManuallyPumped: Boolean) = copy(networkSendManuallyPumped = networkSendManuallyPumped)
|
||||||
fun setThreadPerNode(threadPerNode: Boolean) = copy(threadPerNode = threadPerNode)
|
fun setThreadPerNode(threadPerNode: Boolean) = copy(threadPerNode = threadPerNode)
|
||||||
fun setServicePeerAllocationStrategy(servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy) = copy(servicePeerAllocationStrategy = servicePeerAllocationStrategy)
|
fun setServicePeerAllocationStrategy(servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy) = copy(servicePeerAllocationStrategy = servicePeerAllocationStrategy)
|
||||||
fun setDefaultFactory(defaultFactory: MockNetwork.Factory<*>) = copy(defaultFactory = defaultFactory)
|
fun setDefaultFactory(defaultFactory: (MockNodeArgs) -> MockNetwork.MockNode) = copy(defaultFactory = defaultFactory)
|
||||||
fun setInitialiseSerialization(initialiseSerialization: Boolean) = copy(initialiseSerialization = initialiseSerialization)
|
fun setInitialiseSerialization(initialiseSerialization: Boolean) = copy(initialiseSerialization = initialiseSerialization)
|
||||||
fun setCordappPackages(cordappPackages: List<String>) = copy(cordappPackages = cordappPackages)
|
fun setCordappPackages(cordappPackages: List<String>) = copy(cordappPackages = cordappPackages)
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
|||||||
private val networkSendManuallyPumped: Boolean = defaultParameters.networkSendManuallyPumped,
|
private val networkSendManuallyPumped: Boolean = defaultParameters.networkSendManuallyPumped,
|
||||||
private val threadPerNode: Boolean = defaultParameters.threadPerNode,
|
private val threadPerNode: Boolean = defaultParameters.threadPerNode,
|
||||||
servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = defaultParameters.servicePeerAllocationStrategy,
|
servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy = defaultParameters.servicePeerAllocationStrategy,
|
||||||
private val defaultFactory: Factory<*> = defaultParameters.defaultFactory,
|
private val defaultFactory: (MockNodeArgs) -> MockNode = defaultParameters.defaultFactory,
|
||||||
initialiseSerialization: Boolean = defaultParameters.initialiseSerialization,
|
initialiseSerialization: Boolean = defaultParameters.initialiseSerialization,
|
||||||
private val cordappPackages: List<String> = defaultParameters.cordappPackages) : Closeable {
|
private val cordappPackages: List<String> = defaultParameters.cordappPackages) : Closeable {
|
||||||
/** Helper constructor for creating a [MockNetwork] with custom parameters from Java. */
|
/** Helper constructor for creating a [MockNetwork] with custom parameters from Java. */
|
||||||
@ -141,15 +141,6 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
|||||||
filesystem.getPath("/nodes").createDirectory()
|
filesystem.getPath("/nodes").createDirectory()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Allows customisation of how nodes are created. */
|
|
||||||
interface Factory<out N : MockNode> {
|
|
||||||
fun create(args: MockNodeArgs): N
|
|
||||||
}
|
|
||||||
|
|
||||||
object DefaultFactory : Factory<MockNode> {
|
|
||||||
override fun create(args: MockNodeArgs) = MockNode(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because this executor is shared, we need to be careful about nodes shutting it down.
|
* Because this executor is shared, we need to be careful about nodes shutting it down.
|
||||||
*/
|
*/
|
||||||
@ -286,19 +277,19 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createUnstartedNode(parameters: MockNodeParameters = MockNodeParameters()) = createUnstartedNode(parameters, defaultFactory)
|
fun createUnstartedNode(parameters: MockNodeParameters = MockNodeParameters()) = createUnstartedNode(parameters, defaultFactory)
|
||||||
fun <N : MockNode> createUnstartedNode(parameters: MockNodeParameters = MockNodeParameters(), nodeFactory: Factory<N>): N {
|
fun <N : MockNode> createUnstartedNode(parameters: MockNodeParameters = MockNodeParameters(), nodeFactory: (MockNodeArgs) -> N): N {
|
||||||
return createNodeImpl(parameters, nodeFactory, false)
|
return createNodeImpl(parameters, nodeFactory, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createNode(parameters: MockNodeParameters = MockNodeParameters()): StartedNode<MockNode> = createNode(parameters, defaultFactory)
|
fun createNode(parameters: MockNodeParameters = MockNodeParameters()): StartedNode<MockNode> = createNode(parameters, defaultFactory)
|
||||||
/** Like the other [createNode] but takes a [Factory] and propagates its [MockNode] subtype. */
|
/** Like the other [createNode] but takes a [nodeFactory] and propagates its [MockNode] subtype. */
|
||||||
fun <N : MockNode> createNode(parameters: MockNodeParameters = MockNodeParameters(), nodeFactory: Factory<N>): StartedNode<N> {
|
fun <N : MockNode> createNode(parameters: MockNodeParameters = MockNodeParameters(), nodeFactory: (MockNodeArgs) -> N): StartedNode<N> {
|
||||||
val node: StartedNode<N> = uncheckedCast(createNodeImpl(parameters, nodeFactory, true).started)!!
|
val node: StartedNode<N> = uncheckedCast(createNodeImpl(parameters, nodeFactory, true).started)!!
|
||||||
ensureAllNetworkMapCachesHaveAllNodeInfos()
|
ensureAllNetworkMapCachesHaveAllNodeInfos()
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <N : MockNode> createNodeImpl(parameters: MockNodeParameters, nodeFactory: Factory<N>, start: Boolean): N {
|
private fun <N : MockNode> createNodeImpl(parameters: MockNodeParameters, nodeFactory: (MockNodeArgs) -> N, start: Boolean): N {
|
||||||
val id = parameters.forcedID ?: nextNodeId++
|
val id = parameters.forcedID ?: nextNodeId++
|
||||||
val config = testNodeConfiguration(
|
val config = testNodeConfiguration(
|
||||||
baseDirectory = baseDirectory(id).createDirectories(),
|
baseDirectory = baseDirectory(id).createDirectories(),
|
||||||
@ -306,7 +297,7 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
|||||||
doReturn(makeTestDataSourceProperties("node_${id}_net_$networkId")).whenever(it).dataSourceProperties
|
doReturn(makeTestDataSourceProperties("node_${id}_net_$networkId")).whenever(it).dataSourceProperties
|
||||||
parameters.configOverrides(it)
|
parameters.configOverrides(it)
|
||||||
}
|
}
|
||||||
return nodeFactory.create(MockNodeArgs(config, this, id, parameters.notaryIdentity, parameters.entropyRoot)).apply {
|
return nodeFactory(MockNodeArgs(config, this, id, parameters.notaryIdentity, parameters.entropyRoot)).apply {
|
||||||
if (start) {
|
if (start) {
|
||||||
start()
|
start()
|
||||||
if (threadPerNode) nodeReadyFuture.getOrThrow() // XXX: What about manually-started nodes?
|
if (threadPerNode) nodeReadyFuture.getOrThrow() // XXX: What about manually-started nodes?
|
||||||
@ -347,7 +338,7 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
|||||||
|
|
||||||
fun <N : MockNode> createNotaryNode(parameters: MockNodeParameters = MockNodeParameters(legalName = DUMMY_NOTARY.name),
|
fun <N : MockNode> createNotaryNode(parameters: MockNodeParameters = MockNodeParameters(legalName = DUMMY_NOTARY.name),
|
||||||
validating: Boolean = true,
|
validating: Boolean = true,
|
||||||
nodeFactory: Factory<N>): StartedNode<N> {
|
nodeFactory: (MockNodeArgs) -> N): StartedNode<N> {
|
||||||
return createNode(parameters.copy(configOverrides = {
|
return createNode(parameters.copy(configOverrides = {
|
||||||
doReturn(NotaryConfig(validating)).whenever(it).notary
|
doReturn(NotaryConfig(validating)).whenever(it).notary
|
||||||
parameters.configOverrides(it)
|
parameters.configOverrides(it)
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package net.corda.testing.node;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class MockNodeFactoryInJavaTest {
|
||||||
|
private static class CustomNode extends MockNetwork.MockNode {
|
||||||
|
private CustomNode(@NotNull MockNodeArgs args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does not need to run, only compile.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private static void factoryIsEasyToPassInUsingJava() {
|
||||||
|
//noinspection Convert2MethodRef
|
||||||
|
new MockNetwork(new MockNetworkParameters().setDefaultFactory(args -> new CustomNode(args)));
|
||||||
|
new MockNetwork(new MockNetworkParameters().setDefaultFactory(CustomNode::new));
|
||||||
|
//noinspection Convert2MethodRef
|
||||||
|
new MockNetwork().createNode(new MockNodeParameters(), args -> new CustomNode(args));
|
||||||
|
new MockNetwork().createNode(new MockNodeParameters(), CustomNode::new);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user