Skip to content

Commit

Permalink
Migration to new configs: docker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vsuharnikov committed Oct 24, 2024
1 parent c82ec1f commit 589d218
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(" "),
Expand Down
23 changes: 23 additions & 0 deletions local-network/configs/wavesnode/units.conf
Original file line number Diff line number Diff line change
@@ -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
}
25 changes: 2 additions & 23 deletions local-network/configs/wavesnode/waves.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -152,3 +129,5 @@ waves {
password = ""
}
}

include required("units.conf")
24 changes: 12 additions & 12 deletions src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [ {} ]
}
12 changes: 1 addition & 11 deletions src/test/scala/units/ExtensionDomain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 589d218

Please sign in to comment.