Removed unnecessary calls to MockNetwork.runNetwork (b/c there is no more P2P node registration) and removed redundant entries in cordappPackages

This commit is contained in:
Shams Asari 2017-11-06 21:28:20 +00:00
parent 4e1578c19a
commit a4be26a296
25 changed files with 12 additions and 75 deletions

View File

@ -1,7 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BankOfCordaDriverKt - Issue Web" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="--role ISSUE_CASH_WEB --quantity 100 --currency USD" />

View File

@ -1,7 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BankOfCordaDriverKt - Run Stack" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
<option name="MAIN_CLASS_NAME" value="net.corda.bank.BankOfCordaDriverKt" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="--role ISSUER" />

View File

@ -1,7 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Explorer - demo nodes" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />

View File

@ -1,7 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Explorer - demo nodes (simulation)" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<extension name="krasa.grepconsole.plugin.runConfiguration.GrepRunConfigurationExtension" selectedProfileId="0" />
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="-S" />

View File

@ -26,9 +26,6 @@ public class FlowsInJavaTest {
public void setUp() throws Exception {
aliceNode = mockNet.createPartyNode(TestConstants.getALICE().getName());
bobNode = mockNet.createPartyNode(TestConstants.getBOB().getName());
mockNet.runNetwork();
// Ensure registration was successful
aliceNode.getInternals().getNodeReadyFuture().get();
}
@After

View File

@ -54,8 +54,6 @@ class AttachmentTests {
val aliceNode = mockNet.createPartyNode(ALICE.name)
val bobNode = mockNet.createPartyNode(BOB.name)
// Ensure that registration was successful before progressing any further
mockNet.runNetwork()
val alice = aliceNode.info.singleIdentity()
aliceNode.internals.registerInitiatedFlow(FetchAttachmentsResponse::class.java)
@ -91,15 +89,11 @@ class AttachmentTests {
val aliceNode = mockNet.createPartyNode(ALICE.name)
val bobNode = mockNet.createPartyNode(BOB.name)
// Ensure that registration was successful before progressing any further
mockNet.runNetwork()
aliceNode.internals.registerInitiatedFlow(FetchAttachmentsResponse::class.java)
bobNode.internals.registerInitiatedFlow(FetchAttachmentsResponse::class.java)
// Get node one to fetch a non-existent attachment.
val hash = SecureHash.randomSHA256()
mockNet.runNetwork()
val alice = aliceNode.info.singleIdentity()
val bobFlow = bobNode.startAttachmentFlow(setOf(hash), alice)
mockNet.runNetwork()
@ -116,7 +110,6 @@ class AttachmentTests {
}
})
val bobNode = mockNet.createNode(MockNodeParameters(legalName = BOB.name))
mockNet.runNetwork()
val alice = aliceNode.services.myInfo.identityFromX500Name(ALICE_NAME)
aliceNode.internals.registerInitiatedFlow(FetchAttachmentsResponse::class.java)

View File

@ -23,10 +23,6 @@ import kotlin.reflect.KClass
import kotlin.test.assertFailsWith
class CollectSignaturesFlowTests {
companion object {
private val cordappPackages = listOf("net.corda.testing.contracts")
}
private lateinit var mockNet: MockNetwork
private lateinit var aliceNode: StartedNode<MockNetwork.MockNode>
private lateinit var bobNode: StartedNode<MockNetwork.MockNode>
@ -38,11 +34,10 @@ class CollectSignaturesFlowTests {
@Before
fun setup() {
mockNet = MockNetwork(cordappPackages = cordappPackages)
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
aliceNode = mockNet.createPartyNode(ALICE.name)
bobNode = mockNet.createPartyNode(BOB.name)
charlieNode = mockNet.createPartyNode(CHARLIE.name)
mockNet.runNetwork()
alice = aliceNode.info.singleIdentity()
bob = bobNode.info.singleIdentity()
charlie = charlieNode.info.singleIdentity()
@ -181,7 +176,7 @@ class CollectSignaturesFlowTests {
@Test
fun `fails when not signed by initiator`() {
val onePartyDummyContract = DummyContract.generateInitial(1337, notary, alice.ref(1))
val miniCorpServices = MockServices(cordappPackages, MINI_CORP_KEY)
val miniCorpServices = MockServices(listOf("net.corda.testing.contracts"), MINI_CORP_KEY)
val ptx = miniCorpServices.signInitialTransaction(onePartyDummyContract)
val flow = aliceNode.services.startFlow(CollectSignaturesFlow(ptx, emptySet()))
mockNet.runNetwork()

View File

@ -33,20 +33,16 @@ import kotlin.test.assertFailsWith
import kotlin.test.assertTrue
class ContractUpgradeFlowTest {
lateinit var mockNet: MockNetwork
lateinit var aliceNode: StartedNode<MockNetwork.MockNode>
lateinit var bobNode: StartedNode<MockNetwork.MockNode>
lateinit var notary: Party
private lateinit var mockNet: MockNetwork
private lateinit var aliceNode: StartedNode<MockNetwork.MockNode>
private lateinit var bobNode: StartedNode<MockNetwork.MockNode>
private lateinit var notary: Party
@Before
fun setup() {
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts.asset", "net.corda.core.flows"))
aliceNode = mockNet.createPartyNode(ALICE.name)
bobNode = mockNet.createPartyNode(BOB.name)
// Process registration
mockNet.runNetwork()
notary = mockNet.defaultNotaryIdentity
}

View File

@ -28,7 +28,6 @@ class FinalityFlowTests {
mockNet = MockNetwork(cordappPackages = listOf("net.corda.finance.contracts.asset"))
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
val bobNode = mockNet.createPartyNode(BOB_NAME)
mockNet.runNetwork()
aliceServices = aliceNode.services
bobServices = bobNode.services
alice = aliceNode.info.singleIdentity()

View File

@ -44,7 +44,6 @@ class ResolveTransactionsFlowTest {
miniCorpNode = mockNet.createPartyNode(MINI_CORP.name)
megaCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
miniCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
mockNet.runNetwork()
notary = notaryNode.services.getDefaultNotary()
megaCorp = megaCorpNode.info.chooseIdentity()
miniCorp = miniCorpNode.info.chooseIdentity()

View File

@ -69,7 +69,6 @@ class AttachmentSerializationTest {
server = mockNet.createNode()
client = mockNet.createNode()
client.internals.disableDBCloseOnStop() // Otherwise the in-memory database may disappear (taking the checkpoint with it) while we reboot the client.
mockNet.runNetwork()
}
@After

View File

@ -67,10 +67,7 @@ class TutorialMockNetwork {
mockNet = MockNetwork()
nodeA = mockNet.createPartyNode()
nodeB = mockNet.createPartyNode()
nodeB.registerInitiatedFlow(FlowB::class.java)
mockNet.runNetwork()
}
@After

View File

@ -2,13 +2,11 @@ package net.corda.docs
import net.corda.core.contracts.Amount
import net.corda.core.identity.Party
import net.corda.core.internal.packageName
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.finance.*
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
import net.corda.finance.schemas.CashSchemaV1
import net.corda.node.internal.StartedNode
import net.corda.testing.chooseIdentity
import net.corda.testing.getDefaultNotary
@ -27,13 +25,7 @@ class CustomVaultQueryTest {
@Before
fun setup() {
mockNet = MockNetwork(threadPerNode = true,
cordappPackages = listOf(
"net.corda.finance.contracts.asset",
CashSchemaV1::class.packageName,
"net.corda.docs"
)
)
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance", "net.corda.docs"))
nodeA = mockNet.createPartyNode()
nodeB = mockNet.createPartyNode()
nodeA.internals.registerInitiatedFlow(TopupIssuerFlow.TopupIssuer::class.java)

View File

@ -1,14 +1,12 @@
package net.corda.docs
import net.corda.core.identity.Party
import net.corda.core.internal.packageName
import net.corda.core.toFuture
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.finance.*
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
import net.corda.finance.schemas.CashSchemaV1
import net.corda.node.internal.StartedNode
import net.corda.testing.chooseIdentity
import net.corda.testing.getDefaultNotary
@ -26,7 +24,7 @@ class FxTransactionBuildTutorialTest {
@Before
fun setup() {
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance.contracts.asset", CashSchemaV1::class.packageName))
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance"))
nodeA = mockNet.createPartyNode()
nodeB = mockNet.createPartyNode()
nodeB.internals.registerInitiatedFlow(ForeignExchangeRemoteFlow::class.java)

View File

@ -33,8 +33,6 @@ class CashExitFlowTests {
cordappPackages = listOf("net.corda.finance.contracts.asset"))
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
mockNet.runNetwork()
notary = bankOfCordaNode.services.getDefaultNotary()
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
mockNet.runNetwork()

View File

@ -30,7 +30,6 @@ class CashIssueFlowTests {
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
notary = mockNet.defaultNotaryIdentity
mockNet.runNetwork()
}
@After

View File

@ -34,7 +34,6 @@ class CashPaymentFlowTests {
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
aliceNode = mockNet.createPartyNode(ALICE.name)
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
mockNet.runNetwork()
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture
future.getOrThrow()
}

View File

@ -68,9 +68,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
private val cordappPackages = listOf("net.corda.finance.contracts")
@JvmStatic
@Parameterized.Parameters(name = "Anonymous = {0}")
fun data(): Collection<Boolean> {
return listOf(true, false)
}
fun data(): Collection<Boolean> = listOf(true, false)
}
private lateinit var mockNet: MockNetwork
@ -419,7 +417,6 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
val bobNode = makeNodeWithTracking(BOB_NAME)
val bankNode = makeNodeWithTracking(BOC_NAME)
mockNet.runNetwork()
val notary = aliceNode.services.getDefaultNotary()
val alice: Party = aliceNode.info.singleIdentity()
val bank: Party = bankNode.info.singleIdentity()
@ -450,8 +447,6 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
insertFakeTransactions(alicesFakePaper, aliceNode, notaryNode, bankNode)
mockNet.runNetwork() // Clear network map registration messages
val aliceTxStream = aliceNode.services.validatedTransactions.track().updates
val aliceTxMappings = with(aliceNode) {
database.transaction { services.stateMachineRecordedTransactionMapping.track().updates }
@ -574,7 +569,6 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
val bobNode = mockNet.createPartyNode(BOB_NAME)
val bankNode = mockNet.createPartyNode(BOC_NAME)
mockNet.runNetwork()
val notary = aliceNode.services.getDefaultNotary()
val alice = aliceNode.info.singleIdentity()
val bob = bobNode.info.singleIdentity()
@ -591,8 +585,6 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
insertFakeTransactions(bobsBadCash, bobNode, notaryNode, bankNode)
insertFakeTransactions(alicesFakePaper, aliceNode, notaryNode, bankNode)
mockNet.runNetwork() // Clear network map registration messages
val (bobStateMachine, aliceResult) = runBuyerAndSeller(notary, aliceNode, bobNode, "alice's paper".outputStateAndRef())
mockNet.runNetwork()

View File

@ -44,7 +44,6 @@ class NotaryChangeTests {
clientNodeA = mockNet.createNode()
clientNodeB = mockNet.createNode()
oldNotaryNode = mockNet.notaryNodes[1]
mockNet.runNetwork() // Clear network map registration messages
newNotaryParty = clientNodeA.services.networkMapCache.getNotary(DUMMY_NOTARY.name)!!
oldNotaryParty = clientNodeA.services.networkMapCache.getNotary(oldNotaryName)!!
}

View File

@ -13,7 +13,7 @@ import java.math.BigInteger
import kotlin.test.assertEquals
class NetworkMapCacheTest {
val mockNet: MockNetwork = MockNetwork()
private val mockNet = MockNetwork()
@After
fun teardown() {
@ -24,7 +24,6 @@ class NetworkMapCacheTest {
fun `key collision`() {
val entropy = BigInteger.valueOf(24012017L)
val aliceNode = mockNet.createNode(MockNodeParameters(legalName = ALICE.name, entropyRoot = entropy))
mockNet.runNetwork()
// Node A currently knows only about itself, so this returns node A
assertEquals(aliceNode.services.networkMapCache.getNodesByLegalIdentityKey(aliceNode.info.chooseIdentity().owningKey).singleOrNull(), aliceNode.info)
@ -43,7 +42,6 @@ class NetworkMapCacheTest {
val bobCache: NetworkMapCache = bobNode.services.networkMapCache
val expected = aliceNode.info
mockNet.runNetwork()
val actual = bobNode.database.transaction { bobCache.getNodeByLegalIdentity(aliceNode.info.chooseIdentity()) }
assertEquals(expected, actual)
@ -57,7 +55,6 @@ class NetworkMapCacheTest {
val bobCache: NetworkMapCache = bobNode.services.networkMapCache
val expected = aliceNode.info.legalIdentities.single()
mockNet.runNetwork()
val actual = bobNode.database.transaction { bobCache.getPeerByLegalName(ALICE.name) }
assertEquals(expected, actual)
}
@ -69,7 +66,6 @@ class NetworkMapCacheTest {
val bobLegalIdentity = bobNode.info.chooseIdentity()
val alice = aliceNode.info.chooseIdentity()
val bobCache = bobNode.services.networkMapCache
mockNet.runNetwork()
bobNode.database.transaction {
assertThat(bobCache.getNodeByLegalIdentity(alice) != null)
bobCache.removeNode(aliceNode.info)

View File

@ -28,7 +28,6 @@ class NodeSchemaServiceTest {
fun `registering custom schemas for testing with MockNode`() {
val mockNet = MockNetwork(cordappPackages = listOf(DummyLinearStateSchemaV1::class.packageName))
val mockNode = mockNet.createNode()
mockNet.runNetwork()
val schemaService = mockNode.services.schemaService
assertTrue(schemaService.schemaOptions.containsKey(DummyLinearStateSchemaV1))

View File

@ -209,7 +209,6 @@ class FlowFrameworkTests {
@Test
fun `sending to multiple parties`() {
val charlieNode = mockNet.createNode(MockNodeParameters(legalName = CHARLIE_NAME))
mockNet.runNetwork()
val charlie = charlieNode.info.singleIdentity()
bobNode.registerFlowFactory(SendFlow::class) { InitiatedReceiveFlow(it).nonTerminating() }
charlieNode.registerFlowFactory(SendFlow::class) { InitiatedReceiveFlow(it).nonTerminating() }
@ -242,7 +241,6 @@ class FlowFrameworkTests {
@Test
fun `receiving from multiple parties`() {
val charlieNode = mockNet.createNode(MockNodeParameters(legalName = CHARLIE_NAME))
mockNet.runNetwork()
val charlie = charlieNode.info.singleIdentity()
val bobPayload = "Test 1"
val charliePayload = "Test 2"
@ -396,7 +394,6 @@ class FlowFrameworkTests {
@Test
fun `FlowException propagated in invocation chain`() {
val charlieNode = mockNet.createNode(MockNodeParameters(legalName = CHARLIE_NAME))
mockNet.runNetwork()
val charlie = charlieNode.info.singleIdentity()
charlieNode.registerFlowFactory(ReceiveFlow::class) { ExceptionFlow { MyFlowException("Chain") } }
@ -411,7 +408,6 @@ class FlowFrameworkTests {
@Test
fun `FlowException thrown and there is a 3rd unrelated party flow`() {
val charlieNode = mockNet.createNode(MockNodeParameters(legalName = CHARLIE_NAME))
mockNet.runNetwork()
val charlie = charlieNode.info.singleIdentity()
// Bob will send its payload and then block waiting for the receive from Alice. Meanwhile Alice will move
@ -662,7 +658,7 @@ class FlowFrameworkTests {
val newNode = mockNet.createNode(MockNodeParameters(id))
newNode.internals.acceptableLiveFiberCountOnStop = 1
manuallyCloseDB()
mockNet.runNetwork() // allow NetworkMapService messages to stabilise and thus start the state machine
mockNet.runNetwork()
newNode.getSingleFlow<P>().first
}

View File

@ -41,7 +41,6 @@ class NotaryServiceTests {
fun setup() {
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
aliceServices = mockNet.createNode(MockNodeParameters(legalName = ALICE_NAME)).services
mockNet.runNetwork() // Clear network map registration messages
notaryServices = mockNet.defaultNotaryNode.services //TODO get rid of that
notary = aliceServices.getDefaultNotary()
alice = aliceServices.myInfo.singleIdentity()

View File

@ -41,7 +41,6 @@ class ValidatingNotaryServiceTests {
fun setup() {
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
val aliceNode = mockNet.createNode(MockNodeParameters(legalName = ALICE_NAME))
mockNet.runNetwork() // Clear network map registration messages
notaryServices = mockNet.defaultNotaryNode.services
aliceServices = aliceNode.services
notary = mockNet.defaultNotaryIdentity

View File

@ -69,7 +69,7 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean,
val mockNet = MockNetwork(
networkSendManuallyPumped = networkSendManuallyPumped,
threadPerNode = runAsync,
cordappPackages = listOf("net.corda.irs.contract", "net.corda.finance.contract", "net.corda.irs"))
cordappPackages = listOf("net.corda.finance.contract", "net.corda.irs"))
// TODO: Regulatory nodes don't actually exist properly, this is a last minute demo request.
// 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.