config merge
This commit is contained in:
@@ -28,13 +28,24 @@ class ChainsConfigReaderSpec extends Specification {
|
||||
def stream = this.class.getClassLoader().getResourceAsStream("configs/chains-basic.yaml")
|
||||
when:
|
||||
def config = reader.read(stream)
|
||||
def act = config.resolve(Chain.ETHEREUM)
|
||||
def act2 = config.resolve(Chain.POLYGON)
|
||||
def eth = config.resolve(Chain.ETHEREUM)
|
||||
def pol = config.resolve(Chain.POLYGON)
|
||||
def opt = config.resolve(Chain.OPTIMISM)
|
||||
def sep = config.resolve(Chain.TESTNET_SEPOLIA)
|
||||
then:
|
||||
act.laggingLagSize == 5
|
||||
act.syncingLagSize == 10
|
||||
eth.laggingLagSize == 1
|
||||
eth.syncingLagSize == 6
|
||||
|
||||
act2.laggingLagSize == 1
|
||||
act2.syncingLagSize == 6
|
||||
pol.laggingLagSize == 10
|
||||
pol.syncingLagSize == 20
|
||||
|
||||
opt.laggingLagSize == 3
|
||||
opt.syncingLagSize == 6
|
||||
|
||||
sep.laggingLagSize == 1
|
||||
sep.syncingLagSize == 10
|
||||
|
||||
eth.laggingLagSize == 1
|
||||
eth.syncingLagSize == 6
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-basic.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.defaultOptions) {
|
||||
@@ -75,7 +75,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ws-only.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
@@ -100,7 +100,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ws-full.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
@@ -127,7 +127,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-bitcoin.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.defaultOptions) {
|
||||
@@ -155,7 +155,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("upstreams-ethereum-pos.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
@@ -175,7 +175,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-bitcoin-esplora.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.defaultOptions) {
|
||||
@@ -204,7 +204,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ds.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
@@ -227,7 +227,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-labels.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -248,7 +248,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-options.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -264,7 +264,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-no-defaults.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.defaultOptions) {
|
||||
@@ -287,7 +287,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-methods.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.upstreams.get(0)) {
|
||||
@@ -307,7 +307,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-methods-quorum.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
with(act.upstreams.get(0)) {
|
||||
@@ -330,7 +330,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-no-id.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
@@ -357,7 +357,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-basic.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -369,7 +369,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -381,7 +381,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles-2.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 3
|
||||
@@ -394,7 +394,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles-invalid.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -406,7 +406,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("upstreams-node-id.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 2
|
||||
@@ -424,7 +424,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("upstreams-method-groups.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
def act = reader.readInternal(config)
|
||||
then:
|
||||
act != null
|
||||
act.upstreams.size() == 1
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.emeraldpay.dshackle.config
|
||||
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class ChainsConfigTest {
|
||||
|
||||
@Test
|
||||
fun patch() {
|
||||
val orig = ChainsConfig(
|
||||
mapOf(
|
||||
Chain.BITCOIN to ChainsConfig.RawChainConfig(0, 0),
|
||||
Chain.ETHEREUM to ChainsConfig.RawChainConfig(1, 2),
|
||||
Chain.POLYGON to ChainsConfig.RawChainConfig(3, 4)
|
||||
),
|
||||
ChainsConfig.RawChainConfig(1, 2)
|
||||
)
|
||||
|
||||
val patch = ChainsConfig(
|
||||
mapOf(
|
||||
Chain.BITCOIN to ChainsConfig.RawChainConfig(null, 10000),
|
||||
Chain.POLYGON to ChainsConfig.RawChainConfig(10, 11),
|
||||
Chain.ARBITRUM to ChainsConfig.RawChainConfig(999, 999)
|
||||
),
|
||||
ChainsConfig.RawChainConfig(100, null)
|
||||
)
|
||||
|
||||
val res = orig.patch(patch)
|
||||
|
||||
assertEquals(
|
||||
ChainsConfig(
|
||||
mapOf(
|
||||
Chain.BITCOIN to ChainsConfig.RawChainConfig(0, 10000),
|
||||
Chain.ETHEREUM to ChainsConfig.RawChainConfig(1, 2),
|
||||
Chain.POLYGON to ChainsConfig.RawChainConfig(10, 11),
|
||||
Chain.ARBITRUM to ChainsConfig.RawChainConfig(999, 999)
|
||||
),
|
||||
ChainsConfig.RawChainConfig(100, 2)
|
||||
),
|
||||
res
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,9 @@ chain-settings:
|
||||
lags:
|
||||
syncing: 6
|
||||
lagging: 1
|
||||
- id: optimism
|
||||
lags:
|
||||
lagging: 3
|
||||
- id: sepolia
|
||||
lags:
|
||||
syncing: 10
|
||||
Reference in New Issue
Block a user