Merge remote-tracking branch 'corda/master' into christians_os_merge_20171031

This commit is contained in:
Christian Sailer 2017-11-02 14:50:49 +00:00
parent 3e61d13ffe
commit 0f2a98af91
18 changed files with 53 additions and 83 deletions

View File

@ -21,7 +21,7 @@ import kotlin.test.*
class PartialMerkleTreeTest { class PartialMerkleTreeTest {
@Rule @Rule
@JvmField @JvmField
private val testSerialization = SerializationEnvironmentRule() val testSerialization = SerializationEnvironmentRule()
private val nodes = "abcdef" private val nodes = "abcdef"
private val hashed = nodes.map { node -> private val hashed = nodes.map { node ->
withTestSerialization { withTestSerialization {

View File

@ -17,16 +17,6 @@ import java.util.*
import net.corda.nodeapi.internal.serialization.carpenter.Field as CarpenterField import net.corda.nodeapi.internal.serialization.carpenter.Field as CarpenterField
import net.corda.nodeapi.internal.serialization.carpenter.Schema as CarpenterSchema import net.corda.nodeapi.internal.serialization.carpenter.Schema as CarpenterSchema
/**
* R3 AMQP assigned enterprise number
*
* see [here](https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers)
*
* Repeated here for brevity:
* 50530 - R3 - Mike Hearn - mike&r3.com
*/
const val DESCRIPTOR_TOP_32BITS: Long = 0xc5620000
const val DESCRIPTOR_DOMAIN: String = "net.corda" const val DESCRIPTOR_DOMAIN: String = "net.corda"
// "corda" + majorVersionByte + minorVersionMSB + minorVersionLSB // "corda" + majorVersionByte + minorVersionMSB + minorVersionLSB

View File

@ -79,7 +79,6 @@ class EvolvabilityTests {
// Original version of the class as it was serialised // Original version of the class as it was serialised
// data class C(val a: Int) // data class C(val a: Int)
// File(URI("$localPath/$resource")).writeBytes( SerializationOutput(sf).serialize(C(A)) // File(URI("$localPath/$resource")).writeBytes( SerializationOutput(sf).serialize(C(A))
.bytes)
data class C(val a: Int, val b: Int?) data class C(val a: Int, val b: Int?)

View File

@ -566,7 +566,7 @@ abstract class AbstractNode(config: NodeConfiguration,
protected abstract fun myAddresses(): List<NetworkHostAndPort> protected abstract fun myAddresses(): List<NetworkHostAndPort>
open protected fun checkNetworkMapIsInitialized() { open protected fun checkNetworkMapIsInitialized() {
if (!services.networkMapCache.loadDBSuccess || configuration.noNetworkMapServiceMode) { if (!services.networkMapCache.loadDBSuccess ) {
// TODO: There should be a consistent approach to configuration error exceptions. // TODO: There should be a consistent approach to configuration error exceptions.
throw NetworkMapCacheEmptyException() throw NetworkMapCacheEmptyException()
} }

View File

@ -5,21 +5,21 @@ import com.jcraft.jsch.JSchException
import net.corda.core.internal.Emoji import net.corda.core.internal.Emoji
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.node.VersionInfo import net.corda.node.VersionInfo
import net.corda.node.services.config.FullNodeConfiguration import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.config.RelayConfiguration import net.corda.node.services.config.RelayConfiguration
import net.corda.nodeapi.internal.ServiceInfo import net.corda.nodeapi.internal.ServiceInfo
import org.fusesource.jansi.Ansi import org.fusesource.jansi.Ansi
import org.fusesource.jansi.AnsiConsole import org.fusesource.jansi.AnsiConsole
import java.io.IOException import java.io.IOException
class EnterpriseNode(configuration: FullNodeConfiguration, class EnterpriseNode(configuration: NodeConfiguration,
versionInfo: VersionInfo) : Node(configuration, versionInfo) { versionInfo: VersionInfo) : Node(configuration, versionInfo) {
companion object { companion object {
private val logger by lazy { loggerFor<EnterpriseNode>() } private val logger by lazy { loggerFor<EnterpriseNode>() }
} }
class Startup(args: Array<String>) : NodeStartup(args) { class Startup(args: Array<String>) : NodeStartup(args) {
override fun preNetworkRegistration(conf: FullNodeConfiguration) { override fun preNetworkRegistration(conf: NodeConfiguration) {
super.preNetworkRegistration(conf) super.preNetworkRegistration(conf)
conf.relay?.let { connectToRelay(it, conf.p2pAddress.port) } conf.relay?.let { connectToRelay(it, conf.p2pAddress.port) }
} }
@ -66,7 +66,7 @@ D""".trimStart()
return tips[(Math.random() * tips.size).toInt()] return tips[(Math.random() * tips.size).toInt()]
} }
override fun createNode(conf: FullNodeConfiguration, versionInfo: VersionInfo) = EnterpriseNode(conf, versionInfo) override fun createNode(conf: NodeConfiguration, versionInfo: VersionInfo) = EnterpriseNode(conf, versionInfo)
private fun connectToRelay(config: RelayConfiguration, localBrokerPort: Int) { private fun connectToRelay(config: RelayConfiguration, localBrokerPort: Int) {
with(config) { with(config) {

View File

@ -174,7 +174,7 @@ open class Node(override val configuration: NodeConfiguration,
private fun getAdvertisedAddress(): NetworkHostAndPort { private fun getAdvertisedAddress(): NetworkHostAndPort {
return with(configuration) { return with(configuration) {
if (relay != null) { if (relay != null) {
NetworkHostAndPort(relay.relayHost, relay.remoteInboundPort) NetworkHostAndPort(relay!!.relayHost, relay!!.remoteInboundPort)
} else { } else {
val useHost = if (detectPublicIp) { val useHost = if (detectPublicIp) {
tryDetectIfNotPublicHost(p2pAddress.host) ?: p2pAddress.host tryDetectIfNotPublicHost(p2pAddress.host) ?: p2pAddress.host

View File

@ -40,6 +40,7 @@ interface NodeConfiguration : NodeSSLConfiguration {
// TODO Move into DevModeOptions // TODO Move into DevModeOptions
val useTestClock: Boolean get() = false val useTestClock: Boolean get() = false
val detectPublicIp: Boolean get() = true val detectPublicIp: Boolean get() = true
val relay: RelayConfiguration?
} }
data class NotaryConfig(val validating: Boolean, data class NotaryConfig(val validating: Boolean,
@ -94,7 +95,7 @@ data class NodeConfigurationImpl(
override val useHTTPS: Boolean, override val useHTTPS: Boolean,
override val p2pAddress: NetworkHostAndPort, override val p2pAddress: NetworkHostAndPort,
override val rpcAddress: NetworkHostAndPort?, override val rpcAddress: NetworkHostAndPort?,
val relay: RelayConfiguration?, override val relay: RelayConfiguration?,
// TODO This field is slightly redundant as p2pAddress is sufficient to hold the address of the node's MQ broker. // TODO This field is slightly redundant as p2pAddress is sufficient to hold the address of the node's MQ broker.
// Instead this should be a Boolean indicating whether that broker is an internal one started by the node or an external one // Instead this should be a Boolean indicating whether that broker is an internal one started by the node or an external one
override val messagingServerAddress: NetworkHostAndPort?, override val messagingServerAddress: NetworkHostAndPort?,

View File

@ -13,7 +13,6 @@ import net.corda.core.utilities.debug
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.core.utilities.MAX_HASH_HEX_SIZE import net.corda.core.utilities.MAX_HASH_HEX_SIZE
import net.corda.node.utilities.AppendOnlyPersistentMap import net.corda.node.utilities.AppendOnlyPersistentMap
import net.corda.node.utilities.MAX_HASH_HEX_SIZE
import net.corda.node.utilities.NODE_DATABASE_PREFIX import net.corda.node.utilities.NODE_DATABASE_PREFIX
import org.bouncycastle.cert.X509CertificateHolder import org.bouncycastle.cert.X509CertificateHolder
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream

View File

@ -7,7 +7,6 @@ import net.corda.core.node.services.KeyManagementService
import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.utilities.MAX_HASH_HEX_SIZE import net.corda.core.utilities.MAX_HASH_HEX_SIZE
import net.corda.node.utilities.AppendOnlyPersistentMap import net.corda.node.utilities.AppendOnlyPersistentMap
import net.corda.node.utilities.MAX_HASH_HEX_SIZE
import net.corda.node.utilities.NODE_DATABASE_PREFIX import net.corda.node.utilities.NODE_DATABASE_PREFIX
import org.bouncycastle.operator.ContentSigner import org.bouncycastle.operator.ContentSigner
import java.security.KeyPair import java.security.KeyPair

View File

@ -20,14 +20,6 @@ import java.util.concurrent.CopyOnWriteArrayList
*/ */
const val NODE_DATABASE_PREFIX = "node_" const val NODE_DATABASE_PREFIX = "node_"
/**
* The maximum supported field-size for hash HEX-encoded outputs (e.g. database fields).
* This value is enough to support hash functions with outputs up to 512 bits (e.g. SHA3-512), in which
* case 128 HEX characters are required.
* 130 was selected instead of 128, to allow for 2 extra characters that will be used as hash-scheme identifiers.
*/
internal const val MAX_HASH_HEX_SIZE = 130
//HikariDataSource implements Closeable which allows CordaPersistence to be Closeable //HikariDataSource implements Closeable which allows CordaPersistence to be Closeable
class CordaPersistence(var dataSource: HikariDataSource, private val schemaService: SchemaService, class CordaPersistence(var dataSource: HikariDataSource, private val schemaService: SchemaService,
private val createIdentityService: () -> IdentityService, databaseProperties: Properties) : Closeable { private val createIdentityService: () -> IdentityService, databaseProperties: Properties) : Closeable {

View File

@ -51,5 +51,6 @@ class NodeConfigurationImplTest {
notary = null, notary = null,
certificateChainCheckPolicies = emptyList(), certificateChainCheckPolicies = emptyList(),
devMode = true, devMode = true,
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0))) activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)),
relay = null)
} }

View File

@ -216,8 +216,7 @@ class CommercialPaperTestsGeneric {
// @Test // @Test
@Ignore @Ignore
fun `issue move and then redeem`() { fun `issue move and then redeem`() = withTestSerialization{
initialiseTestSerialization()
val aliceDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY)) val aliceDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY))
val databaseAlice = aliceDatabaseAndServices.first val databaseAlice = aliceDatabaseAndServices.first
aliceServices = aliceDatabaseAndServices.second aliceServices = aliceDatabaseAndServices.second
@ -297,6 +296,5 @@ class CommercialPaperTestsGeneric {
validRedemption.toLedgerTransaction(aliceServices).verify() validRedemption.toLedgerTransaction(aliceServices).verify()
// soft lock not released after success either!!! (as transaction not recorded) // soft lock not released after success either!!! (as transaction not recorded)
} }
resetTestSerialization()
} }
} }

View File

@ -80,7 +80,7 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
} }
class CashTests : TestDependencyInjectionBase() { class CashTests {
private val defaultRef = OpaqueBytes(ByteArray(1, { 1 })) private val defaultRef = OpaqueBytes(ByteArray(1, { 1 }))
private val defaultIssuer = MEGA_CORP.ref(defaultRef) private val defaultIssuer = MEGA_CORP.ref(defaultRef)
private val inState = Cash.State( private val inState = Cash.State(
@ -102,7 +102,7 @@ class CashTests : TestDependencyInjectionBase() {
private lateinit var vaultStatesUnconsumed: List<StateAndRef<Cash.State>> private lateinit var vaultStatesUnconsumed: List<StateAndRef<Cash.State>>
@Before @Before
fun setUp() { fun setUp() = withTestSerialization {
LogHelper.setLevel(NodeVaultService::class) LogHelper.setLevel(NodeVaultService::class)
megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP_KEY) megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP_KEY)
val databaseAndServices = makeTestDatabaseAndMockServices(cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), keys = listOf(MINI_CORP_KEY, MEGA_CORP_KEY, OUR_KEY)) val databaseAndServices = makeTestDatabaseAndMockServices(cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), keys = listOf(MINI_CORP_KEY, MEGA_CORP_KEY, OUR_KEY))
@ -123,7 +123,6 @@ class CashTests : TestDependencyInjectionBase() {
database.transaction { database.transaction {
vaultStatesUnconsumed = miniCorpServices.vaultService.queryBy<Cash.State>().states vaultStatesUnconsumed = miniCorpServices.vaultService.queryBy<Cash.State>().states
} }
resetTestSerialization()
} }
@After @After
@ -205,8 +204,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateIssueRaw() { fun generateIssueRaw() = withTestSerialization {
initialiseTestSerialization()
// Test generation works. // Test generation works.
val tx: WireTransaction = TransactionBuilder(notary = null).apply { val tx: WireTransaction = TransactionBuilder(notary = null).apply {
Cash().generateIssue(this, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY) Cash().generateIssue(this, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY)
@ -221,8 +219,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateIssueFromAmount() { fun generateIssueFromAmount() = withTestSerialization {
initialiseTestSerialization()
// Test issuance from an issued amount // Test issuance from an issued amount
val amount = 100.DOLLARS `issued by` MINI_CORP.ref(12, 34) val amount = 100.DOLLARS `issued by` MINI_CORP.ref(12, 34)
val tx: WireTransaction = TransactionBuilder(notary = null).apply { val tx: WireTransaction = TransactionBuilder(notary = null).apply {
@ -290,8 +287,7 @@ class CashTests : TestDependencyInjectionBase() {
* cash inputs. * cash inputs.
*/ */
@Test(expected = IllegalStateException::class) @Test(expected = IllegalStateException::class)
fun `reject issuance with inputs`() { fun `reject issuance with inputs`() = withTestSerialization {
initialiseTestSerialization()
// Issue some cash // Issue some cash
var ptx = TransactionBuilder(DUMMY_NOTARY) var ptx = TransactionBuilder(DUMMY_NOTARY)
@ -302,6 +298,7 @@ class CashTests : TestDependencyInjectionBase() {
ptx = TransactionBuilder(DUMMY_NOTARY) ptx = TransactionBuilder(DUMMY_NOTARY)
ptx.addInputState(tx.tx.outRef<Cash.State>(0)) ptx.addInputState(tx.tx.outRef<Cash.State>(0))
Cash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY) Cash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY)
Unit
} }
@Test @Test
@ -566,8 +563,7 @@ class CashTests : TestDependencyInjectionBase() {
* Try exiting an amount which matches a single state. * Try exiting an amount which matches a single state.
*/ */
@Test @Test
fun generateSimpleExit() { fun generateSimpleExit() = withTestSerialization {
initialiseTestSerialization()
val wtx = makeExit(miniCorpServices, 100.DOLLARS, MEGA_CORP, 1) val wtx = makeExit(miniCorpServices, 100.DOLLARS, MEGA_CORP, 1)
assertEquals(WALLET[0].ref, wtx.inputs[0]) assertEquals(WALLET[0].ref, wtx.inputs[0])
assertEquals(0, wtx.outputs.size) assertEquals(0, wtx.outputs.size)
@ -582,8 +578,7 @@ class CashTests : TestDependencyInjectionBase() {
* Try exiting an amount smaller than the smallest available input state, and confirm change is generated correctly. * Try exiting an amount smaller than the smallest available input state, and confirm change is generated correctly.
*/ */
@Test @Test
fun generatePartialExit() { fun generatePartialExit() = withTestSerialization {
initialiseTestSerialization()
val wtx = makeExit(miniCorpServices, 50.DOLLARS, MEGA_CORP, 1) val wtx = makeExit(miniCorpServices, 50.DOLLARS, MEGA_CORP, 1)
val actualInput = wtx.inputs.single() val actualInput = wtx.inputs.single()
// Filter the available inputs and confirm exactly one has been used // Filter the available inputs and confirm exactly one has been used
@ -600,53 +595,52 @@ class CashTests : TestDependencyInjectionBase() {
* Try exiting a currency we don't have. * Try exiting a currency we don't have.
*/ */
@Test @Test
fun generateAbsentExit() { fun generateAbsentExit() = withTestSerialization {
initialiseTestSerialization()
assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, MEGA_CORP, 1) } assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, MEGA_CORP, 1) }
Unit
} }
/** /**
* Try exiting with a reference mis-match. * Try exiting with a reference mis-match.
*/ */
@Test @Test
fun generateInvalidReferenceExit() { fun generateInvalidReferenceExit() = withTestSerialization {
initialiseTestSerialization()
assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, MEGA_CORP, 2) } assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, MEGA_CORP, 2) }
Unit
} }
/** /**
* Try exiting an amount greater than the maximum available. * Try exiting an amount greater than the maximum available.
*/ */
@Test @Test
fun generateInsufficientExit() { fun generateInsufficientExit() = withTestSerialization {
initialiseTestSerialization()
assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 1000.DOLLARS, MEGA_CORP, 1) } assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 1000.DOLLARS, MEGA_CORP, 1) }
Unit
} }
/** /**
* Try exiting for an owner with no states * Try exiting for an owner with no states
*/ */
@Test @Test
fun generateOwnerWithNoStatesExit() { fun generateOwnerWithNoStatesExit() = withTestSerialization {
initialiseTestSerialization()
assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, CHARLIE, 1) } assertFailsWith<InsufficientBalanceException> { makeExit(miniCorpServices, 100.POUNDS, CHARLIE, 1) }
Unit
} }
/** /**
* Try exiting when vault is empty * Try exiting when vault is empty
*/ */
@Test @Test
fun generateExitWithEmptyVault() { fun generateExitWithEmptyVault() = withTestSerialization {
initialiseTestSerialization()
assertFailsWith<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
val tx = TransactionBuilder(DUMMY_NOTARY) val tx = TransactionBuilder(DUMMY_NOTARY)
Cash().generateExit(tx, Amount(100, Issued(CHARLIE.ref(1), GBP)), emptyList(), OUR_IDENTITY_1) Cash().generateExit(tx, Amount(100, Issued(CHARLIE.ref(1), GBP)), emptyList(), OUR_IDENTITY_1)
} }
Unit
} }
@Test @Test
fun generateSimpleDirectSpend() { fun generateSimpleDirectSpend() = withTestSerialization {
initialiseTestSerialization()
val wtx = val wtx =
database.transaction { database.transaction {
makeSpend(100.DOLLARS, THEIR_IDENTITY_1) makeSpend(100.DOLLARS, THEIR_IDENTITY_1)
@ -660,8 +654,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateSimpleSpendWithParties() { fun generateSimpleSpendWithParties() = withTestSerialization {
initialiseTestSerialization()
database.transaction { database.transaction {
val tx = TransactionBuilder(DUMMY_NOTARY) val tx = TransactionBuilder(DUMMY_NOTARY)
@ -672,8 +665,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateSimpleSpendWithChange() { fun generateSimpleSpendWithChange() = withTestSerialization {
initialiseTestSerialization()
val wtx = val wtx =
database.transaction { database.transaction {
makeSpend(10.DOLLARS, THEIR_IDENTITY_1) makeSpend(10.DOLLARS, THEIR_IDENTITY_1)
@ -698,8 +690,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateSpendWithTwoInputs() { fun generateSpendWithTwoInputs() = withTestSerialization {
initialiseTestSerialization()
val wtx = val wtx =
database.transaction { database.transaction {
makeSpend(500.DOLLARS, THEIR_IDENTITY_1) makeSpend(500.DOLLARS, THEIR_IDENTITY_1)
@ -715,8 +706,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateSpendMixedDeposits() { fun generateSpendMixedDeposits() = withTestSerialization {
initialiseTestSerialization()
val wtx = val wtx =
database.transaction { database.transaction {
val wtx = makeSpend(580.DOLLARS, THEIR_IDENTITY_1) val wtx = makeSpend(580.DOLLARS, THEIR_IDENTITY_1)
@ -737,8 +727,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun generateSpendInsufficientBalance() { fun generateSpendInsufficientBalance() = withTestSerialization {
initialiseTestSerialization()
database.transaction { database.transaction {
val e: InsufficientBalanceException = assertFailsWith("balance") { val e: InsufficientBalanceException = assertFailsWith("balance") {
@ -750,6 +739,7 @@ class CashTests : TestDependencyInjectionBase() {
makeSpend(81.SWISS_FRANCS, THEIR_IDENTITY_1) makeSpend(81.SWISS_FRANCS, THEIR_IDENTITY_1)
} }
} }
Unit
} }
/** /**
@ -876,8 +866,7 @@ class CashTests : TestDependencyInjectionBase() {
} }
@Test @Test
fun multiSpend() { fun multiSpend() = withTestSerialization {
initialiseTestSerialization()
val tx = TransactionBuilder(DUMMY_NOTARY) val tx = TransactionBuilder(DUMMY_NOTARY)
database.transaction { database.transaction {
val payments = listOf( val payments = listOf(

View File

@ -37,7 +37,7 @@ fun <A> springDriver(
driverDirectory: Path = defaultParameters.driverDirectory, driverDirectory: Path = defaultParameters.driverDirectory,
portAllocation: PortAllocation = defaultParameters.portAllocation, portAllocation: PortAllocation = defaultParameters.portAllocation,
debugPortAllocation: PortAllocation = defaultParameters.debugPortAllocation, debugPortAllocation: PortAllocation = defaultParameters.debugPortAllocation,
systemProperties: Map<String, String> = defaultParameters.systemProperties, systemProperties: Map<String, String> = defaultParameters.extraSystemProperties,
useTestClock: Boolean = defaultParameters.useTestClock, useTestClock: Boolean = defaultParameters.useTestClock,
initialiseSerialization: Boolean = defaultParameters.initialiseSerialization, initialiseSerialization: Boolean = defaultParameters.initialiseSerialization,
startNodesInProcess: Boolean = defaultParameters.startNodesInProcess, startNodesInProcess: Boolean = defaultParameters.startNodesInProcess,

View File

@ -12,6 +12,7 @@ import net.corda.node.services.statemachine.StateMachineManager
import net.corda.testing.DUMMY_NOTARY import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_REGULATOR import net.corda.testing.DUMMY_REGULATOR
import net.corda.testing.node.* import net.corda.testing.node.*
import net.corda.testing.node.MockNetwork.MockNode
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
import rx.Observable import rx.Observable
import rx.subjects.PublishSubject import rx.subjects.PublishSubject
@ -24,7 +25,7 @@ import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletableFuture.allOf import java.util.concurrent.CompletableFuture.allOf
import java.util.concurrent.Future import java.util.concurrent.Future
internal val MockNode.place get() = configuration.myLegalName.locality.let { CityDatabase[it] }!! internal val MockNetwork.MockNode.place get() = configuration.myLegalName.locality.let { CityDatabase[it] }!!
/** /**
* Base class for network simulations that are based on the unit test / mock environment. * Base class for network simulations that are based on the unit test / mock environment.
@ -49,11 +50,11 @@ 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> { object RatesOracleFactory : MockNetwork.Factory<MockNetwork.MockNode> {
// TODO: Make a more realistic legal name // TODO: Make a more realistic legal name
val RATES_SERVICE_NAME = CordaX500Name(organisation = "Rates Service Provider", locality = "Madrid", country = "ES") val RATES_SERVICE_NAME = CordaX500Name(organisation = "Rates Service Provider", locality = "Madrid", country = "ES")
override fun create(args: MockNodeArgs): MockNode { override fun create(args: MockNodeArgs): MockNetwork.MockNode {
return object : MockNode(args) { return object : MockNode(args) {
override fun start() = super.start().apply { override fun start() = super.start().apply {
registerInitiatedFlow(NodeInterestRates.FixQueryHandler::class.java) registerInitiatedFlow(NodeInterestRates.FixQueryHandler::class.java)

View File

@ -225,7 +225,7 @@ fun <A> rpcDriver(
driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()), driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()),
portAllocation: PortAllocation = globalPortAllocation, portAllocation: PortAllocation = globalPortAllocation,
debugPortAllocation: PortAllocation = globalDebugPortAllocation, debugPortAllocation: PortAllocation = globalDebugPortAllocation,
extraSystemProperties: Map<String, String> = emptyMap(), systemProperties: Map<String, String> = emptyMap(),
useTestClock: Boolean = false, useTestClock: Boolean = false,
initialiseSerialization: Boolean = true, initialiseSerialization: Boolean = true,
startNodesInProcess: Boolean = false, startNodesInProcess: Boolean = false,
@ -236,7 +236,7 @@ fun <A> rpcDriver(
DriverDSL( DriverDSL(
portAllocation = portAllocation, portAllocation = portAllocation,
debugPortAllocation = debugPortAllocation, debugPortAllocation = debugPortAllocation,
extraSystemProperties = extraSystemProperties, extraSystemProperties = systemProperties,
driverDirectory = driverDirectory.toAbsolutePath(), driverDirectory = driverDirectory.toAbsolutePath(),
useTestClock = useTestClock, useTestClock = useTestClock,
isDebug = isDebug, isDebug = isDebug,

View File

@ -315,7 +315,7 @@ data class NodeParameters(
* and may be specified in [DriverDSL.startNode]. * and may be specified in [DriverDSL.startNode].
* @param portAllocation The port allocation strategy to use for the messaging and the web server addresses. Defaults to incremental. * @param portAllocation The port allocation strategy to use for the messaging and the web server addresses. Defaults to incremental.
* @param debugPortAllocation The port allocation strategy to use for jvm debugging. Defaults to incremental. * @param debugPortAllocation The port allocation strategy to use for jvm debugging. Defaults to incremental.
* @param extraSystemProperties A Map of extra system properties which will be given to each new node. Defaults to empty. * @param systemProperties A Map of extra system properties which will be given to each new node. Defaults to empty.
* @param useTestClock If true the test clock will be used in Node. * @param useTestClock If true the test clock will be used in Node.
* @param startNodesInProcess Provides the default behaviour of whether new nodes should start inside this process or * @param startNodesInProcess Provides the default behaviour of whether new nodes should start inside this process or
* not. Note that this may be overridden in [DriverDSLExposedInterface.startNode]. * not. Note that this may be overridden in [DriverDSLExposedInterface.startNode].
@ -434,7 +434,7 @@ fun <DI : DriverDSLExposedInterface, D : DriverDSLInternalInterface, A> genericD
driverDirectory: Path = defaultParameters.driverDirectory, driverDirectory: Path = defaultParameters.driverDirectory,
portAllocation: PortAllocation = defaultParameters.portAllocation, portAllocation: PortAllocation = defaultParameters.portAllocation,
debugPortAllocation: PortAllocation = defaultParameters.debugPortAllocation, debugPortAllocation: PortAllocation = defaultParameters.debugPortAllocation,
systemProperties: Map<String, String> = defaultParameters.systemProperties, systemProperties: Map<String, String> = defaultParameters.extraSystemProperties,
useTestClock: Boolean = defaultParameters.useTestClock, useTestClock: Boolean = defaultParameters.useTestClock,
initialiseSerialization: Boolean = defaultParameters.initialiseSerialization, initialiseSerialization: Boolean = defaultParameters.initialiseSerialization,
startNodesInProcess: Boolean = defaultParameters.startNodesInProcess, startNodesInProcess: Boolean = defaultParameters.startNodesInProcess,
@ -448,7 +448,7 @@ fun <DI : DriverDSLExposedInterface, D : DriverDSLInternalInterface, A> genericD
DriverDSL( DriverDSL(
portAllocation = portAllocation, portAllocation = portAllocation,
debugPortAllocation = debugPortAllocation, debugPortAllocation = debugPortAllocation,
systemProperties = systemProperties, extraSystemProperties = systemProperties,
driverDirectory = driverDirectory.toAbsolutePath(), driverDirectory = driverDirectory.toAbsolutePath(),
useTestClock = useTestClock, useTestClock = useTestClock,
isDebug = isDebug, isDebug = isDebug,
@ -752,7 +752,7 @@ class DriverDSL(
"noNetworkMapServiceMode" to true "noNetworkMapServiceMode" to true
) + customOverrides ) + customOverrides
) )
return startNodeInternal(name, config, webAddress, startInSameProcess, maximumHeapSize, logLevel) return startNodeInternal(config, webAddress, startInSameProcess, maximumHeapSize)
} }
override fun startNotaryNode(providedName: CordaX500Name, override fun startNotaryNode(providedName: CordaX500Name,
@ -779,7 +779,7 @@ class DriverDSL(
"noNetworkMapServiceMode" to true "noNetworkMapServiceMode" to true
) )
) )
startNodeInternal(name, config, webAddress, startInSameProcess, maximumHeapSize) startNodeInternal(config, webAddress, startInSameProcess, maximumHeapSize)
} }
} }
@ -925,7 +925,7 @@ class DriverDSL(
countObservables.remove(nodeConfiguration.myLegalName) countObservables.remove(nodeConfiguration.myLegalName)
} }
if (startInProcess ?: startNodesInProcess) { if (startInProcess ?: startNodesInProcess) {
val nodeAndThreadFuture = startInProcessNode(executorService, nodeConfiguration, enhancedConfig, cordappPackages) val nodeAndThreadFuture = startInProcessNode(executorService, nodeConfiguration, config, cordappPackages)
shutdownManager.registerShutdown( shutdownManager.registerShutdown(
nodeAndThreadFuture.map { (node, thread) -> nodeAndThreadFuture.map { (node, thread) ->
{ {
@ -943,7 +943,7 @@ class DriverDSL(
} }
} else { } else {
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
val processFuture = startOutOfProcessNode(executorService, nodeConfiguration, enhancedConfig, quasarJarPath, debugPort, systemProperties, cordappPackages, maximumHeapSize, logLevel) val processFuture = startOutOfProcessNode(executorService, nodeConfiguration, config, quasarJarPath, debugPort, systemProperties, cordappPackages, maximumHeapSize)
registerProcess(processFuture) registerProcess(processFuture)
return processFuture.flatMap { process -> return processFuture.flatMap { process ->
val processDeathFuture = poll(executorService, "process death") { val processDeathFuture = poll(executorService, "process death") {

View File

@ -39,6 +39,7 @@ import net.corda.node.utilities.AffinityExecutor
import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor
import net.corda.nodeapi.internal.ServiceInfo import net.corda.nodeapi.internal.ServiceInfo
import net.corda.testing.DUMMY_NOTARY import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.initialiseTestSerialization
import net.corda.testing.node.MockServices.Companion.MOCK_VERSION_INFO import net.corda.testing.node.MockServices.Companion.MOCK_VERSION_INFO
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
import net.corda.testing.testNodeConfiguration import net.corda.testing.testNodeConfiguration