From 589d21845a50f7d2262e423e0157677fa414fd22 Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Thu, 24 Oct 2024 16:14:39 +0400 Subject: [PATCH] Migration to new configs: docker tests --- .../network/test/docker/EcContainer.scala | 13 ++++++---- .../test/docker/WavesNodeContainer.scala | 4 +-- local-network/configs/wavesnode/units.conf | 23 +++++++++++++++++ local-network/configs/wavesnode/waves.conf | 25 ++----------------- src/test/resources/application.conf | 24 +++++++++--------- src/test/scala/units/ExtensionDomain.scala | 12 +-------- 6 files changed, 48 insertions(+), 53 deletions(-) create mode 100644 local-network/configs/wavesnode/units.conf diff --git a/consensus-client-it/src/test/scala/units/network/test/docker/EcContainer.scala b/consensus-client-it/src/test/scala/units/network/test/docker/EcContainer.scala index 1388f7b7..70131e03 100644 --- a/consensus-client-it/src/test/scala/units/network/test/docker/EcContainer.scala +++ b/consensus-client-it/src/test/scala/units/network/test/docker/EcContainer.scala @@ -1,6 +1,6 @@ package units.network.test.docker -import com.typesafe.config.ConfigFactory +import com.typesafe.config.{ConfigFactory, ConfigValueFactory} import net.ceedubs.ficus.Ficus.toFicusConfig import org.testcontainers.containers.BindMode import org.testcontainers.containers.Network.NetworkImpl @@ -48,8 +48,11 @@ object EcContainer { val EnginePort = 8551 // TODO move - private val baseConfig = ConfigFactory.load(this.getClass.getClassLoader, "application.conf") - private val baseClientConfig = baseConfig.as[ClientConfig]("waves.l2") - - private def mkConfig(host: String, port: Int): ClientConfig = baseClientConfig.copy(executionClientAddress = s"http://$host:$port") + private val baseConfig = ConfigFactory.load(this.getClass.getClassLoader, "application.conf") + private def mkConfig(host: String, port: Int): ClientConfig = baseConfig + .getConfig("units.defaults") + .withValue("chain-contract", ConfigValueFactory.fromAnyRef("")) // Doesn't matter for HttpEngineApiClient + .withValue("execution-client-address", ConfigValueFactory.fromAnyRef(s"http://$host:$port")) + .resolve() + .as[ClientConfig] } diff --git a/consensus-client-it/src/test/scala/units/network/test/docker/WavesNodeContainer.scala b/consensus-client-it/src/test/scala/units/network/test/docker/WavesNodeContainer.scala index afcc8a6b..819b5080 100644 --- a/consensus-client-it/src/test/scala/units/network/test/docker/WavesNodeContainer.scala +++ b/consensus-client-it/src/test/scala/units/network/test/docker/WavesNodeContainer.scala @@ -30,8 +30,8 @@ class WavesNodeContainer( "NODE_NUMBER" -> s"$number", "WAVES_WALLET_SEED" -> Base58.encode(baseSeed.getBytes(StandardCharsets.UTF_8)), "JAVA_OPTS" -> List( - s"-Dwaves.l2.chain-contract=$chainContractAddress", - s"-Dwaves.l2.execution-client-address=$ecEngineApiUrl", + s"-Dunits.defaults.chain-contract=$chainContractAddress", + s"-Dunits.defaults.execution-client-address=$ecEngineApiUrl", "-Dlogback.file.level=TRACE", "-Dfile.encoding=UTF-8" ).mkString(" "), diff --git a/local-network/configs/wavesnode/units.conf b/local-network/configs/wavesnode/units.conf new file mode 100644 index 00000000..f5eacd6f --- /dev/null +++ b/local-network/configs/wavesnode/units.conf @@ -0,0 +1,23 @@ +units { + defaults { + chain-contract = "3FdaanzgX4roVgHevhq8L8q42E7EZL9XTQr" + execution-client-address = "http://ec-"${NODE_NUMBER}":8551" + network { + port = 6865 + bind-address = "0.0.0.0" + known-peers = [ + "wavesnode-1:6865" + "wavesnode-2:6865" + "wavesnode-3:6865" + "wavesnode-4:6865" + ] + + enable-peers-exchange = off + peers-broadcast-interval = 1d + } + + jwt-secret-file = "/etc/secrets/jwt-secret-"${NODE_NUMBER}".hex" + } + + chains = [ {} ] # Enable one network +} diff --git a/local-network/configs/wavesnode/waves.conf b/local-network/configs/wavesnode/waves.conf index cfa6632e..0e35eca9 100644 --- a/local-network/configs/wavesnode/waves.conf +++ b/local-network/configs/wavesnode/waves.conf @@ -95,29 +95,6 @@ waves { } } - # P2P Network settings - l2 { - chain-contract = "3FdaanzgX4roVgHevhq8L8q42E7EZL9XTQr" - - execution-client-address = "http://ec-"${NODE_NUMBER}":8551" - jwt-secret-file = "/etc/secrets/jwt-secret-"${NODE_NUMBER}".hex" - - network { - bind-address = "0.0.0.0" - port = 6865 - known-peers = [ - "wavesnode-1:6865" - "wavesnode-2:6865" - "wavesnode-3:6865" - "wavesnode-4:6865" - ] - enable-peers-exchange = off - peers-broadcast-interval = 1d - } - - mining-enable = yes - } - rest-api { # Enable/disable node's REST API enable = yes @@ -152,3 +129,5 @@ waves { password = "" } } + +include required("units.conf") diff --git a/src/test/resources/application.conf b/src/test/resources/application.conf index a459ddeb..7bb1c414 100644 --- a/src/test/resources/application.conf +++ b/src/test/resources/application.conf @@ -3,18 +3,18 @@ waves { } units { - defaults.mining-enable = false + defaults { + chain-contract = "3MsD16zWCbJ4G7QnJizA9x7tM6yDHShoSYB" # Seed: chain-contract + execution-client-address = "http://127.0.0.1:8551" + network = ${waves.network} - chains = [ - { - chain-contract = "3MsD16zWCbJ4G7QnJizA9x7tM6yDHShoSYB" # Seed: chain-contract - execution-client-address = "http://127.0.0.1:8551" - network = ${waves.network} + api-request-retries = 2 + api-request-retry-wait-time = 2s + block-delay = 6s + block-sync-request-timeout = 500ms - api-request-retries = 2 - api-request-retry-wait-time = 2s - block-delay = 6s - block-sync-request-timeout = 500ms - } - ] + mining-enable = false + } + + chains = [ {} ] } diff --git a/src/test/scala/units/ExtensionDomain.scala b/src/test/scala/units/ExtensionDomain.scala index 6795784b..3c9eeeed 100644 --- a/src/test/scala/units/ExtensionDomain.scala +++ b/src/test/scala/units/ExtensionDomain.scala @@ -51,7 +51,6 @@ import units.test.CustomMatchers import java.nio.charset.StandardCharsets import scala.annotation.tailrec import scala.concurrent.duration.{DurationInt, FiniteDuration} -import scala.jdk.CollectionConverters.CollectionHasAsScala import scala.reflect.ClassTag class ExtensionDomain( @@ -68,16 +67,7 @@ class ExtensionDomain( with ScorexLogging { self => override val chainContractAccount: KeyPair = KeyPair("chain-contract".getBytes(StandardCharsets.UTF_8)) - val l2Config = { - val defaultConfig = settings.config.getConfig("units.defaults") - val newChainConfigs = settings.config - .getConfigList("units.chains") - .asScala - .map(cfg => cfg.withFallback(defaultConfig).resolve().as[ClientConfig]) - - newChainConfigs.head - } - + val l2Config = settings.config.as[ClientConfig]("units.defaults") require(l2Config.chainContractAddress == chainContractAddress, "Check settings") val ecGenesisBlock = EcBlock(