[CORDA-2174] Fix demo node startup (#4151)

- Make issuableCurrencies config optional

- Allow additionalCordapps to override cordappsForAllNodes

In driver DSL when passing additionalCordapps to startNode and
one of the CordApps is also in cordappsForAllNodes will lead to confilc.
This commit is resolving the conflict by using the CordApp provided
by additionalCordapps
This commit is contained in:
Venelin Stoykov 2018-11-02 13:44:18 +02:00 committed by Viktor Kolomeyko
parent 24e9ceac48
commit 094eb266a8
2 changed files with 12 additions and 2 deletions

View File

@ -24,7 +24,12 @@ class ConfigHolder(services: AppServiceHub) : SingletonSerializeAsToken() {
val issuableCurrencies: List<Currency>
init {
val issuableCurrenciesStringList: List<String> = uncheckedCast(services.getAppContext().config.get("issuableCurrencies"))
val config = services.getAppContext().config
val issuableCurrenciesStringList: List<String> = if (config.exists("issuableCurrencies")) {
uncheckedCast(config.get("issuableCurrencies"))
} else {
emptyList()
}
issuableCurrencies = issuableCurrenciesStringList.map(Currency::getInstance)
(issuableCurrencies - supportedCurrencies).let {
require(it.isEmpty()) { "$it are not supported currencies" }

View File

@ -595,7 +595,12 @@ class DriverDSLImpl(
emptyList()
}
val cordappDirectories = existingCorDappDirectoriesOption + (cordappsForAllNodes + additionalCordapps).map { TestCordappDirectories.getJarDirectory(it).toString() }
// Instead of using cordappsForAllNodes we get only these that are missing from additionalCordapps
// This way we prevent errors when we want the same CordApp but with different config
val appOverrides = additionalCordapps.map { it.name to it.version}.toSet()
val baseCordapps = cordappsForAllNodes.filter { !appOverrides.contains(it.name to it.version) }
val cordappDirectories = existingCorDappDirectoriesOption + (baseCordapps + additionalCordapps).map { TestCordappDirectories.getJarDirectory(it).toString() }
val config = NodeConfig(specifiedConfig.typesafe.withValue(NodeConfiguration.cordappDirectoriesKey, ConfigValueFactory.fromIterable(cordappDirectories.toSet())))