mirror of
https://github.com/corda/corda.git
synced 2025-06-16 22:28:15 +00:00
Retire setCordappPackages. (#1860)
This commit is contained in:
@ -16,26 +16,14 @@ import net.corda.node.services.transactions.RaftValidatingNotaryService
|
||||
import net.corda.testing.*
|
||||
import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.node.NodeBasedTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
class RaftNotaryServiceTests : NodeBasedTest() {
|
||||
class RaftNotaryServiceTests : NodeBasedTest(listOf("net.corda.testing.contracts")) {
|
||||
private val notaryName = CordaX500Name(RaftValidatingNotaryService.id, "RAFT Notary Service", "London", "GB")
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `detect double spend`() {
|
||||
val (bankA) = listOf(
|
||||
|
@ -102,6 +102,7 @@ import net.corda.core.crypto.generateKeyPair as cryptoGenerateKeyPair
|
||||
abstract class AbstractNode(config: NodeConfiguration,
|
||||
val platformClock: Clock,
|
||||
protected val versionInfo: VersionInfo,
|
||||
protected val cordappLoader: CordappLoader,
|
||||
@VisibleForTesting val busyNodeLatch: ReusableLatch = ReusableLatch()) : SingletonSerializeAsToken() {
|
||||
open val configuration = config.apply {
|
||||
require(minimumPlatformVersion <= versionInfo.platformVersion) {
|
||||
@ -151,8 +152,6 @@ abstract class AbstractNode(config: NodeConfiguration,
|
||||
protected val runOnStop = ArrayList<() -> Any?>()
|
||||
protected lateinit var database: CordaPersistence
|
||||
lateinit var cordappProvider: CordappProviderImpl
|
||||
protected val cordappLoader by lazy { makeCordappLoader() }
|
||||
|
||||
protected val _nodeReadyFuture = openFuture<Unit>()
|
||||
/** Completes once the node has successfully registered with the network map service
|
||||
* or has loaded network map data from local database */
|
||||
@ -472,19 +471,6 @@ abstract class AbstractNode(config: NodeConfiguration,
|
||||
return tokenizableServices
|
||||
}
|
||||
|
||||
private fun makeCordappLoader(): CordappLoader {
|
||||
val scanPackages = System.getProperty("net.corda.node.cordapp.scan.packages")
|
||||
return if (CordappLoader.testPackages.isNotEmpty()) {
|
||||
check(configuration.devMode) { "Package scanning can only occur in dev mode" }
|
||||
CordappLoader.createDefaultWithTestPackages(configuration.baseDirectory, CordappLoader.testPackages)
|
||||
} else if (scanPackages != null) {
|
||||
check(configuration.devMode) { "Package scanning can only occur in dev mode" }
|
||||
CordappLoader.createDefaultWithTestPackages(configuration.baseDirectory, scanPackages.split(","))
|
||||
} else {
|
||||
CordappLoader.createDefault(configuration.baseDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun makeTransactionStorage(): WritableTransactionStorage = DBTransactionStorage()
|
||||
|
||||
private fun makeVaultObservers() {
|
||||
|
@ -15,6 +15,7 @@ import net.corda.core.node.ServiceHub
|
||||
import net.corda.core.serialization.SerializationDefaults
|
||||
import net.corda.core.utilities.*
|
||||
import net.corda.node.VersionInfo
|
||||
import net.corda.node.internal.cordapp.CordappLoader
|
||||
import net.corda.node.serialization.KryoServerSerializationScheme
|
||||
import net.corda.node.serialization.NodeClock
|
||||
import net.corda.node.services.RPCUserService
|
||||
@ -22,6 +23,7 @@ import net.corda.node.services.RPCUserServiceImpl
|
||||
import net.corda.node.services.api.NetworkMapCacheInternal
|
||||
import net.corda.node.services.api.SchemaService
|
||||
import net.corda.node.services.config.FullNodeConfiguration
|
||||
import net.corda.node.services.config.NodeConfiguration
|
||||
import net.corda.node.services.messaging.ArtemisMessagingServer
|
||||
import net.corda.node.services.messaging.ArtemisMessagingServer.Companion.ipDetectRequestProperty
|
||||
import net.corda.node.services.messaging.ArtemisMessagingServer.Companion.ipDetectResponseProperty
|
||||
@ -62,8 +64,9 @@ import kotlin.system.exitProcess
|
||||
*/
|
||||
open class Node(override val configuration: FullNodeConfiguration,
|
||||
versionInfo: VersionInfo,
|
||||
val initialiseSerialization: Boolean = true
|
||||
) : AbstractNode(configuration, createClock(configuration), versionInfo) {
|
||||
val initialiseSerialization: Boolean = true,
|
||||
cordappLoader: CordappLoader = makeCordappLoader(configuration)
|
||||
) : AbstractNode(configuration, createClock(configuration), versionInfo, cordappLoader) {
|
||||
companion object {
|
||||
private val logger = loggerFor<Node>()
|
||||
var renderBasicInfoToConsole = true
|
||||
@ -86,6 +89,13 @@ open class Node(override val configuration: FullNodeConfiguration,
|
||||
}
|
||||
|
||||
private val sameVmNodeCounter = AtomicInteger()
|
||||
val scanPackagesSystemProperty = "net.corda.node.cordapp.scan.packages"
|
||||
val scanPackagesSeparator = ","
|
||||
private fun makeCordappLoader(configuration: NodeConfiguration): CordappLoader {
|
||||
return System.getProperty(scanPackagesSystemProperty)?.let { scanPackages ->
|
||||
CordappLoader.createDefaultWithTestPackages(configuration, scanPackages.split(scanPackagesSeparator))
|
||||
} ?: CordappLoader.createDefault(configuration.baseDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
override val log: Logger get() = logger
|
||||
|
@ -14,6 +14,7 @@ import net.corda.core.serialization.SerializationWhitelist
|
||||
import net.corda.core.serialization.SerializeAsToken
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.node.internal.classloading.requireAnnotation
|
||||
import net.corda.node.services.config.NodeConfiguration
|
||||
import net.corda.nodeapi.internal.serialization.DefaultWhitelist
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
@ -64,14 +65,12 @@ class CordappLoader private constructor(private val cordappJarPaths: List<URL>)
|
||||
/**
|
||||
* Create a dev mode CordappLoader for test environments that creates and loads cordapps from the classpath
|
||||
* and plugins directory. This is intended mostly for use by the driver.
|
||||
*
|
||||
* @param baseDir See [createDefault.baseDir]
|
||||
* @param testPackages See [createWithTestPackages.testPackages]
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@JvmOverloads
|
||||
fun createDefaultWithTestPackages(baseDir: Path, testPackages: List<String> = CordappLoader.testPackages)
|
||||
= CordappLoader(getCordappsInDirectory(getPluginsPath(baseDir)) + testPackages.flatMap(this::createScanPackage))
|
||||
fun createDefaultWithTestPackages(configuration: NodeConfiguration, testPackages: List<String>): CordappLoader {
|
||||
check(configuration.devMode) { "Package scanning can only occur in dev mode" }
|
||||
return CordappLoader(getCordappsInDirectory(getPluginsPath(configuration.baseDirectory)) + testPackages.flatMap(this::createScanPackage))
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a dev mode CordappLoader for test environments that creates and loads cordapps from the classpath.
|
||||
@ -81,8 +80,7 @@ class CordappLoader private constructor(private val cordappJarPaths: List<URL>)
|
||||
* CorDapps.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@JvmOverloads
|
||||
fun createWithTestPackages(testPackages: List<String> = CordappLoader.testPackages)
|
||||
fun createWithTestPackages(testPackages: List<String>)
|
||||
= CordappLoader(testPackages.flatMap(this::createScanPackage))
|
||||
|
||||
/**
|
||||
@ -147,11 +145,6 @@ class CordappLoader private constructor(private val cordappJarPaths: List<URL>)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of test packages that will be scanned as CorDapps and compiled into CorDapp JARs for use in tests only.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
var testPackages: List<String> = emptyList()
|
||||
private val generatedCordapps = mutableMapOf<URL, URI>()
|
||||
|
||||
/** A list of the core RPC flows present in Corda */
|
||||
|
@ -43,15 +43,15 @@ public class VaultQueryJavaTests extends TestDependencyInjectionBase {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
setCordappPackages("net.corda.testing.contracts", "net.corda.finance.contracts.asset");
|
||||
List<String> cordappPackages = Arrays.asList("net.corda.testing.contracts", "net.corda.finance.contracts.asset");
|
||||
ArrayList<KeyPair> keys = new ArrayList<>();
|
||||
keys.add(getMEGA_CORP_KEY());
|
||||
keys.add(getDUMMY_NOTARY_KEY());
|
||||
Set<MappedSchema> requiredSchemas = Collections.singleton(CashSchemaV1.INSTANCE);
|
||||
IdentityService identitySvc = makeTestIdentityService();
|
||||
@SuppressWarnings("unchecked")
|
||||
Pair<CordaPersistence, MockServices> databaseAndServices = makeTestDatabaseAndMockServices(requiredSchemas, keys, () -> identitySvc, Collections.EMPTY_LIST);
|
||||
issuerServices = new MockServices(getDUMMY_CASH_ISSUER_KEY(), getBOC_KEY());
|
||||
Pair<CordaPersistence, MockServices> databaseAndServices = makeTestDatabaseAndMockServices(requiredSchemas, keys, () -> identitySvc, cordappPackages);
|
||||
issuerServices = new MockServices(cordappPackages, getDUMMY_CASH_ISSUER_KEY(), getBOC_KEY());
|
||||
database = databaseAndServices.getFirst();
|
||||
services = databaseAndServices.getSecond();
|
||||
vaultService = services.getVaultService();
|
||||
@ -60,7 +60,6 @@ public class VaultQueryJavaTests extends TestDependencyInjectionBase {
|
||||
@After
|
||||
public void cleanUp() throws IOException {
|
||||
database.close();
|
||||
unsetCordappPackages();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,9 +62,7 @@ class CordaRPCOpsImplTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.finance.contracts.asset")
|
||||
|
||||
mockNet = MockNetwork()
|
||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.finance.contracts.asset"))
|
||||
aliceNode = mockNet.createNode()
|
||||
notaryNode = mockNet.createNotaryNode(validating = false)
|
||||
rpc = CordaRPCOpsImpl(aliceNode.services, aliceNode.smm, aliceNode.database)
|
||||
@ -81,7 +79,6 @@ class CordaRPCOpsImplTest {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,7 +97,6 @@ class CordaRPCOpsImplTest {
|
||||
}
|
||||
|
||||
// Tell the monitoring service node to issue some cash
|
||||
val recipient = aliceNode.info.chooseIdentity()
|
||||
val result = rpc.startFlow(::CashIssueFlow, Amount(quantity, GBP), ref, notary)
|
||||
mockNet.runNetwork()
|
||||
|
||||
|
@ -15,8 +15,6 @@ import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.node.internal.cordapp.DummyRPCFlow
|
||||
import net.corda.testing.DUMMY_NOTARY
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.setCordappPackages
|
||||
import net.corda.testing.unsetCordappPackages
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -74,9 +72,7 @@ class TestCordaService2(val appServiceHub: AppServiceHub): SingletonSerializeAsT
|
||||
}
|
||||
|
||||
@CordaService
|
||||
class LegacyCordaService(val simpleServiceHub: ServiceHub): SingletonSerializeAsToken() {
|
||||
|
||||
}
|
||||
class LegacyCordaService(@Suppress("UNUSED_PARAMETER") simpleServiceHub: ServiceHub) : SingletonSerializeAsToken()
|
||||
|
||||
class CordaServiceTest {
|
||||
lateinit var mockNet: MockNetwork
|
||||
@ -85,8 +81,7 @@ class CordaServiceTest {
|
||||
|
||||
@Before
|
||||
fun start() {
|
||||
setCordappPackages("net.corda.node.internal","net.corda.finance")
|
||||
mockNet = MockNetwork(threadPerNode = true)
|
||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.node.internal","net.corda.finance"))
|
||||
notaryNode = mockNet.createNotaryNode(legalName = DUMMY_NOTARY.name, validating = true)
|
||||
nodeA = mockNet.createNode()
|
||||
mockNet.startNodes()
|
||||
@ -95,7 +90,6 @@ class CordaServiceTest {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,6 +45,7 @@ import net.corda.testing.*
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
import net.corda.testing.node.InMemoryMessagingNetwork
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockServices
|
||||
import net.corda.testing.node.pumpReceive
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.After
|
||||
@ -73,6 +74,7 @@ import kotlin.test.assertTrue
|
||||
@RunWith(Parameterized::class)
|
||||
class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
companion object {
|
||||
private val cordappPackages = listOf("net.corda.finance.contracts")
|
||||
@JvmStatic
|
||||
@Parameterized.Parameters
|
||||
fun data(): Collection<Boolean> {
|
||||
@ -84,7 +86,6 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
setCordappPackages("net.corda.finance.contracts")
|
||||
LogHelper.setLevel("platform.trade", "core.contract.TransactionGroup", "recordingmap")
|
||||
}
|
||||
|
||||
@ -92,7 +93,6 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
fun after() {
|
||||
mockNet.stopNodes()
|
||||
LogHelper.reset("platform.trade", "core.contract.TransactionGroup", "recordingmap")
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,9 +100,8 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
// We run this in parallel threads to help catch any race conditions that may exist. The other tests
|
||||
// we run in the unit test thread exclusively to speed things up, ensure deterministic results and
|
||||
// allow interruption half way through.
|
||||
mockNet = MockNetwork(false, true)
|
||||
|
||||
ledger(initialiseSerialization = false) {
|
||||
mockNet = MockNetwork(false, true, cordappPackages = cordappPackages)
|
||||
ledger(MockServices(cordappPackages), initialiseSerialization = false) {
|
||||
val notaryNode = mockNet.createNotaryNode()
|
||||
val aliceNode = mockNet.createPartyNode(ALICE.name)
|
||||
val bobNode = mockNet.createPartyNode(BOB.name)
|
||||
@ -149,9 +148,8 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Test(expected = InsufficientBalanceException::class)
|
||||
fun `trade cash for commercial paper fails using soft locking`() {
|
||||
mockNet = MockNetwork(false, true)
|
||||
|
||||
ledger(initialiseSerialization = false) {
|
||||
mockNet = MockNetwork(false, true, cordappPackages = cordappPackages)
|
||||
ledger(MockServices(cordappPackages), initialiseSerialization = false) {
|
||||
val notaryNode = mockNet.createNotaryNode()
|
||||
val aliceNode = mockNet.createPartyNode(ALICE.name)
|
||||
val bobNode = mockNet.createPartyNode(BOB.name)
|
||||
@ -204,8 +202,8 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Test
|
||||
fun `shutdown and restore`() {
|
||||
mockNet = MockNetwork(false)
|
||||
ledger(initialiseSerialization = false) {
|
||||
mockNet = MockNetwork(false, cordappPackages = cordappPackages)
|
||||
ledger(MockServices(cordappPackages), initialiseSerialization = false) {
|
||||
val notaryNode = mockNet.createNotaryNode()
|
||||
val aliceNode = mockNet.createPartyNode(ALICE.name)
|
||||
var bobNode = mockNet.createPartyNode(BOB.name)
|
||||
@ -222,8 +220,6 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
bobNode.internals.disableDBCloseOnStop()
|
||||
|
||||
val bobAddr = bobNode.network.myAddress as InMemoryMessagingNetwork.PeerHandle
|
||||
val networkMapAddress = notaryNode.network.myAddress
|
||||
|
||||
mockNet.runNetwork() // Clear network map registration messages
|
||||
val notary = aliceNode.services.getDefaultNotary()
|
||||
|
||||
@ -331,8 +327,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Test
|
||||
fun `check dependencies of sale asset are resolved`() {
|
||||
mockNet = MockNetwork(false)
|
||||
|
||||
mockNet = MockNetwork(false, cordappPackages = cordappPackages)
|
||||
val notaryNode = mockNet.createNotaryNode()
|
||||
val aliceNode = makeNodeWithTracking(ALICE.name)
|
||||
val bobNode = makeNodeWithTracking(BOB.name)
|
||||
@ -436,8 +431,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Test
|
||||
fun `track works`() {
|
||||
mockNet = MockNetwork(false)
|
||||
|
||||
mockNet = MockNetwork(false, cordappPackages = cordappPackages)
|
||||
val notaryNode = mockNet.createNotaryNode()
|
||||
val aliceNode = makeNodeWithTracking(ALICE.name)
|
||||
val bobNode = makeNodeWithTracking(BOB.name)
|
||||
@ -517,16 +511,16 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) {
|
||||
|
||||
@Test
|
||||
fun `dependency with error on buyer side`() {
|
||||
mockNet = MockNetwork(false)
|
||||
ledger(initialiseSerialization = false) {
|
||||
mockNet = MockNetwork(false, cordappPackages = cordappPackages)
|
||||
ledger(MockServices(cordappPackages), initialiseSerialization = false) {
|
||||
runWithError(true, false, "at least one cash input")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `dependency with error on seller side`() {
|
||||
mockNet = MockNetwork(false)
|
||||
ledger(initialiseSerialization = false) {
|
||||
mockNet = MockNetwork(false, cordappPackages = cordappPackages)
|
||||
ledger(MockServices(cordappPackages), initialiseSerialization = false) {
|
||||
runWithError(false, true, "Issuances have a time-window")
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ class NotaryChangeTests {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
mockNet = MockNetwork()
|
||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
|
||||
oldNotaryNode = mockNet.createNotaryNode(legalName = DUMMY_NOTARY.name)
|
||||
clientNodeA = mockNet.createNode()
|
||||
clientNodeB = mockNet.createNode()
|
||||
@ -50,7 +49,6 @@ class NotaryChangeTests {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,7 +72,6 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
initialiseTestSerialization()
|
||||
countDown = CountDownLatch(1)
|
||||
smmHasRemovedAllFlows = CountDownLatch(1)
|
||||
@ -98,7 +97,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
||||
network = mockMessagingService), TestReference {
|
||||
override val vaultService: VaultServiceInternal = NodeVaultService(testClock, kms, stateLoader, database.hibernateConfig)
|
||||
override val testReference = this@NodeSchedulerServiceTest
|
||||
override val cordappProvider: CordappProviderImpl = CordappProviderImpl(CordappLoader.createWithTestPackages()).start(attachments)
|
||||
override val cordappProvider = CordappProviderImpl(CordappLoader.createWithTestPackages(listOf("net.corda.testing.contracts"))).start(attachments)
|
||||
}
|
||||
smmExecutor = AffinityExecutor.ServiceAffinityExecutor("test", 1)
|
||||
scheduler = NodeSchedulerService(services, schedulerGatedExecutor, serverThread = smmExecutor)
|
||||
@ -124,7 +123,6 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
||||
smmExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
||||
database.close()
|
||||
resetTestSerialization()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
class TestState(val flowLogicRef: FlowLogicRef, val instant: Instant, val myIdentity: Party) : LinearState, SchedulableState {
|
||||
|
@ -91,8 +91,7 @@ class ScheduledFlowTests {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
mockNet = MockNetwork(threadPerNode = true)
|
||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.testing.contracts"))
|
||||
notaryNode = mockNet.createNotaryNode(legalName = DUMMY_NOTARY.name)
|
||||
val a = mockNet.createUnstartedNode()
|
||||
val b = mockNet.createUnstartedNode()
|
||||
@ -107,7 +106,6 @@ class ScheduledFlowTests {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,14 +73,14 @@ class HibernateConfigurationTest : TestDependencyInjectionBase() {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
setCordappPackages("net.corda.testing.contracts", "net.corda.finance.contracts.asset")
|
||||
issuerServices = MockServices(DUMMY_CASH_ISSUER_KEY, BOB_KEY, BOC_KEY)
|
||||
val cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts.asset")
|
||||
issuerServices = MockServices(cordappPackages, DUMMY_CASH_ISSUER_KEY, BOB_KEY, BOC_KEY)
|
||||
val dataSourceProps = makeTestDataSourceProperties()
|
||||
val defaultDatabaseProperties = makeTestDatabaseProperties()
|
||||
database = configureDatabase(dataSourceProps, defaultDatabaseProperties, NodeSchemaService(), ::makeTestIdentityService)
|
||||
database.transaction {
|
||||
hibernateConfig = database.hibernateConfig
|
||||
services = object : MockServices(BOB_KEY, BOC_KEY, DUMMY_NOTARY_KEY) {
|
||||
services = object : MockServices(cordappPackages, BOB_KEY, BOC_KEY, DUMMY_NOTARY_KEY) {
|
||||
override val vaultService = makeVaultService(database.hibernateConfig)
|
||||
override fun recordTransactions(notifyVault: Boolean, txs: Iterable<SignedTransaction>) {
|
||||
for (stx in txs) {
|
||||
@ -105,7 +105,6 @@ class HibernateConfigurationTest : TestDependencyInjectionBase() {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
database.close()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
private fun setUpDb() {
|
||||
|
@ -65,8 +65,7 @@ class FlowFrameworkTests {
|
||||
|
||||
@Before
|
||||
fun start() {
|
||||
setCordappPackages("net.corda.finance.contracts", "net.corda.testing.contracts")
|
||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin())
|
||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("net.corda.finance.contracts", "net.corda.testing.contracts"))
|
||||
node1 = mockNet.createNode()
|
||||
node2 = mockNet.createNode()
|
||||
|
||||
@ -87,7 +86,6 @@ class FlowFrameworkTests {
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
receivedSessionMessages.clear()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -33,8 +33,7 @@ class NotaryServiceTests {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
mockNet = MockNetwork()
|
||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
|
||||
notaryNode = mockNet.createNotaryNode(legalName = DUMMY_NOTARY.name, validating = false)
|
||||
clientNode = mockNet.createNode()
|
||||
mockNet.runNetwork() // Clear network map registration messages
|
||||
@ -45,7 +44,6 @@ class NotaryServiceTests {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -33,8 +33,7 @@ class ValidatingNotaryServiceTests {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
setCordappPackages("net.corda.testing.contracts")
|
||||
mockNet = MockNetwork()
|
||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
|
||||
notaryNode = mockNet.createNotaryNode(legalName = DUMMY_NOTARY.name)
|
||||
clientNode = mockNet.createNode()
|
||||
mockNet.runNetwork() // Clear network map registration messages
|
||||
@ -45,7 +44,6 @@ class ValidatingNotaryServiceTests {
|
||||
@After
|
||||
fun cleanUp() {
|
||||
mockNet.stopNodes()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,27 +45,30 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
||||
companion object {
|
||||
private val cordappPackages = listOf("net.corda.finance.contracts.asset")
|
||||
}
|
||||
|
||||
lateinit var services: MockServices
|
||||
lateinit var issuerServices: MockServices
|
||||
private lateinit var issuerServices: MockServices
|
||||
val vaultService get() = services.vaultService as NodeVaultService
|
||||
lateinit var database: CordaPersistence
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
setCordappPackages("net.corda.finance.contracts.asset")
|
||||
LogHelper.setLevel(NodeVaultService::class)
|
||||
val databaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(BOC_KEY, DUMMY_CASH_ISSUER_KEY),
|
||||
customSchemas = setOf(CashSchemaV1))
|
||||
customSchemas = setOf(CashSchemaV1),
|
||||
cordappPackages = cordappPackages)
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
issuerServices = MockServices(DUMMY_CASH_ISSUER_KEY, BOC_KEY)
|
||||
issuerServices = MockServices(cordappPackages, DUMMY_CASH_ISSUER_KEY, BOC_KEY)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
database.close()
|
||||
LogHelper.reset(NodeVaultService::class)
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
@ -440,8 +443,7 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
||||
|
||||
@Test
|
||||
fun addNoteToTransaction() {
|
||||
val megaCorpServices = MockServices(MEGA_CORP_KEY)
|
||||
|
||||
val megaCorpServices = MockServices(cordappPackages, MEGA_CORP_KEY)
|
||||
database.transaction {
|
||||
val freshKey = services.myInfo.chooseIdentity().owningKey
|
||||
|
||||
|
@ -45,6 +45,9 @@ import java.time.temporal.ChronoUnit
|
||||
import java.util.*
|
||||
|
||||
class VaultQueryTests : TestDependencyInjectionBase() {
|
||||
companion object {
|
||||
private val cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts")
|
||||
}
|
||||
|
||||
private lateinit var services: MockServices
|
||||
private lateinit var notaryServices: MockServices
|
||||
@ -59,23 +62,21 @@ class VaultQueryTests : TestDependencyInjectionBase() {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
setCordappPackages("net.corda.testing.contracts", "net.corda.finance.contracts")
|
||||
|
||||
// register additional identities
|
||||
identitySvc.verifyAndRegisterIdentity(CASH_NOTARY_IDENTITY)
|
||||
identitySvc.verifyAndRegisterIdentity(BOC_IDENTITY)
|
||||
val databaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(MEGA_CORP_KEY, DUMMY_NOTARY_KEY),
|
||||
createIdentityService = { identitySvc },
|
||||
customSchemas = setOf(CashSchemaV1, CommercialPaperSchemaV1, DummyLinearStateSchemaV1))
|
||||
customSchemas = setOf(CashSchemaV1, CommercialPaperSchemaV1, DummyLinearStateSchemaV1),
|
||||
cordappPackages = cordappPackages)
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
notaryServices = MockServices(DUMMY_NOTARY_KEY, DUMMY_CASH_ISSUER_KEY, BOC_KEY, MEGA_CORP_KEY)
|
||||
notaryServices = MockServices(cordappPackages, DUMMY_NOTARY_KEY, DUMMY_CASH_ISSUER_KEY, BOC_KEY, MEGA_CORP_KEY)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
database.close()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1490,18 +1491,16 @@ class VaultQueryTests : TestDependencyInjectionBase() {
|
||||
// GBP issuer
|
||||
val gbpCashIssuerKey = entropyToKeyPair(BigInteger.valueOf(1001))
|
||||
val gbpCashIssuer = Party(CordaX500Name(organisation = "British Pounds Cash Issuer", locality = "London", country = "GB"), gbpCashIssuerKey.public).ref(1)
|
||||
val gbpCashIssuerServices = MockServices(gbpCashIssuerKey)
|
||||
val gbpCashIssuerServices = MockServices(cordappPackages, gbpCashIssuerKey)
|
||||
// USD issuer
|
||||
val usdCashIssuerKey = entropyToKeyPair(BigInteger.valueOf(1002))
|
||||
val usdCashIssuer = Party(CordaX500Name(organisation = "US Dollars Cash Issuer", locality = "New York", country = "US"), usdCashIssuerKey.public).ref(1)
|
||||
val usdCashIssuerServices = MockServices(usdCashIssuerKey)
|
||||
val usdCashIssuerServices = MockServices(cordappPackages, usdCashIssuerKey)
|
||||
// CHF issuer
|
||||
val chfCashIssuerKey = entropyToKeyPair(BigInteger.valueOf(1003))
|
||||
val chfCashIssuer = Party(CordaX500Name(organisation = "Swiss Francs Cash Issuer", locality = "Zurich", country = "CH"), chfCashIssuerKey.public).ref(1)
|
||||
val chfCashIssuerServices = MockServices(chfCashIssuerKey)
|
||||
|
||||
val chfCashIssuerServices = MockServices(cordappPackages, chfCashIssuerKey)
|
||||
database.transaction {
|
||||
|
||||
services.fillWithSomeTestCash(100.POUNDS, gbpCashIssuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = (gbpCashIssuer))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, usdCashIssuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = (usdCashIssuer))
|
||||
services.fillWithSomeTestCash(100.SWISS_FRANCS, chfCashIssuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = (chfCashIssuer))
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.corda.node.services.vaultService
|
||||
package net.corda.node.services.vault
|
||||
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.LinearState
|
||||
@ -34,6 +34,10 @@ import kotlin.test.assertEquals
|
||||
// TODO: Move this to the cash contract tests once mock services are further split up.
|
||||
|
||||
class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
companion object {
|
||||
private val cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts.asset")
|
||||
}
|
||||
|
||||
lateinit var services: MockServices
|
||||
lateinit var issuerServices: MockServices
|
||||
val vaultService: VaultService get() = services.vaultService
|
||||
@ -42,22 +46,20 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
setCordappPackages("net.corda.testing.contracts", "net.corda.finance.contracts.asset")
|
||||
|
||||
LogHelper.setLevel(VaultWithCashTest::class)
|
||||
val databaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(DUMMY_CASH_ISSUER_KEY, DUMMY_NOTARY_KEY),
|
||||
customSchemas = setOf(CashSchemaV1))
|
||||
customSchemas = setOf(CashSchemaV1),
|
||||
cordappPackages = cordappPackages)
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
issuerServices = MockServices(DUMMY_CASH_ISSUER_KEY, MEGA_CORP_KEY)
|
||||
notaryServices = MockServices(DUMMY_NOTARY_KEY)
|
||||
issuerServices = MockServices(cordappPackages, DUMMY_CASH_ISSUER_KEY, MEGA_CORP_KEY)
|
||||
notaryServices = MockServices(cordappPackages, DUMMY_NOTARY_KEY)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
LogHelper.reset(VaultWithCashTest::class)
|
||||
database.close()
|
||||
unsetCordappPackages()
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -81,7 +83,7 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
|
||||
@Test
|
||||
fun `issue and spend total correctly and irrelevant ignored`() {
|
||||
val megaCorpServices = MockServices(MEGA_CORP_KEY)
|
||||
val megaCorpServices = MockServices(cordappPackages, MEGA_CORP_KEY)
|
||||
val freshKey = services.keyManagementService.freshKey()
|
||||
|
||||
val usefulTX =
|
||||
|
Reference in New Issue
Block a user