diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/CacheConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/CacheConfigReaderSpec.groovy index 8b0901ed..99305cf9 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/CacheConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/CacheConfigReaderSpec.groovy @@ -23,7 +23,7 @@ class CacheConfigReaderSpec extends Specification { def "Read full"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("cache-redis-full.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/cache-redis-full.yaml") when: def act = reader.read(config) @@ -39,7 +39,7 @@ class CacheConfigReaderSpec extends Specification { def "Read disabled"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("cache-redis-disabled.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/cache-redis-disabled.yaml") when: def act = reader.read(config) diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy index a340c75c..9006581b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy @@ -24,7 +24,7 @@ class HealthConfigReaderSpec extends Specification { def "Read empty"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-health-empty.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-health-empty.yaml") when: def act = reader.read(config) @@ -38,7 +38,7 @@ class HealthConfigReaderSpec extends Specification { def "Read single"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-health-1.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-health-1.yaml") when: def act = reader.read(config) @@ -58,7 +58,7 @@ class HealthConfigReaderSpec extends Specification { def "Read multiple"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-health-2.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-health-2.yaml") when: def act = reader.read(config) diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy index 89d48c42..8a0c0eab 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy @@ -22,11 +22,12 @@ import spock.lang.Specification class MainConfigReaderSpec extends Specification { - MainConfigReader reader = new MainConfigReader(TestingCommons.fileResolver()) - - def "Read full config"() { + def "Read full config with inclusion"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-full.yaml") + // the File Resolver should be able to resolve/include files + MainConfigReader reader = new MainConfigReader(TestingCommons.fileResolver()) + // note that it references another config to be included + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-full.yaml") when: def act = reader.read(config) diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/MonitoringConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/MonitoringConfigReaderSpec.groovy index a1fa8f67..eee026ca 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/MonitoringConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/MonitoringConfigReaderSpec.groovy @@ -23,7 +23,7 @@ class MonitoringConfigReaderSpec extends Specification { def "Read basic monitoring config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-monitoring-basic.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-monitoring-basic.yaml") when: def act = reader.read(config) diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy index 8d2f827d..473247df 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy @@ -24,7 +24,7 @@ class ProxyConfigReaderSpec extends Specification { def "Read basic proxy config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-basic.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-proxy-basic.yaml") when: def act = reader.read(config) @@ -42,7 +42,7 @@ class ProxyConfigReaderSpec extends Specification { def "Read proxy config with websocket disabled"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-no-ws.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-proxy-no-ws.yaml") when: def act = reader.read(config) @@ -53,7 +53,7 @@ class ProxyConfigReaderSpec extends Specification { def "Read proxy config with two elements"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-two.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-proxy-two.yaml") when: def act = reader.read(config) @@ -73,7 +73,7 @@ class ProxyConfigReaderSpec extends Specification { def "Read max proxy config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-max.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/dshackle-proxy-max.yaml") when: def act = reader.read(config) diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy index 5b4589a8..d115c12e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy @@ -25,7 +25,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse standard config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-basic.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-basic.yaml") when: def act = reader.read(config) then: @@ -73,7 +73,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse websocket-only config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-ws-only.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ws-only.yaml") when: def act = reader.read(config) then: @@ -98,7 +98,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse full defined websocket config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-ws-full.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ws-full.yaml") when: def act = reader.read(config) then: @@ -125,7 +125,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse bitcoin upstreams"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-bitcoin.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-bitcoin.yaml") when: def act = reader.read(config) then: @@ -173,7 +173,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse bitcoin upstreams with esplora"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-bitcoin-esplora.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-bitcoin-esplora.yaml") when: def act = reader.read(config) then: @@ -202,7 +202,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse ds config"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-ds.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-ds.yaml") when: def act = reader.read(config) then: @@ -225,7 +225,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with labels"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-labels.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-labels.yaml") when: def act = reader.read(config) then: @@ -246,7 +246,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with options"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-options.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-options.yaml") when: def act = reader.read(config) then: @@ -262,7 +262,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config without defaults"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-no-defaults.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-no-defaults.yaml") when: def act = reader.read(config) then: @@ -285,7 +285,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with methods"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-methods.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-methods.yaml") when: def act = reader.read(config) then: @@ -305,7 +305,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with methods and quorum"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-methods-quorum.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-methods-quorum.yaml") when: def act = reader.read(config) then: @@ -328,7 +328,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with invalid ids"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-no-id.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-no-id.yaml") when: def act = reader.read(config) then: @@ -355,7 +355,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config without fallback role"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-basic.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-basic.yaml") when: def act = reader.read(config) then: @@ -367,7 +367,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with fallback role"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-roles.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles.yaml") when: def act = reader.read(config) then: @@ -379,7 +379,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with secondary role"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-roles-2.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles-2.yaml") when: def act = reader.read(config) then: @@ -392,7 +392,7 @@ class UpstreamsConfigReaderSpec extends Specification { def "Parse config with invalid role"() { setup: - def config = this.class.getClassLoader().getResourceAsStream("upstreams-roles-invalid.yaml") + def config = this.class.getClassLoader().getResourceAsStream("configs/upstreams-roles-invalid.yaml") when: def act = reader.read(config) then: diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy index a6e4c114..a7405aa4 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy @@ -108,7 +108,7 @@ class TestingCommons { } static FileResolver fileResolver() { - return new FileResolver(new File("src/test/resources")) + return new FileResolver(new File("src/test/resources/configs")) } static BlockContainer blockForEthereum(Long height) { diff --git a/src/test/resources/cache-redis-disabled.yaml b/src/test/resources/configs/cache-redis-disabled.yaml similarity index 100% rename from src/test/resources/cache-redis-disabled.yaml rename to src/test/resources/configs/cache-redis-disabled.yaml diff --git a/src/test/resources/cache-redis-full.yaml b/src/test/resources/configs/cache-redis-full.yaml similarity index 100% rename from src/test/resources/cache-redis-full.yaml rename to src/test/resources/configs/cache-redis-full.yaml diff --git a/src/test/resources/dshackle-full.yaml b/src/test/resources/configs/dshackle-full.yaml similarity index 100% rename from src/test/resources/dshackle-full.yaml rename to src/test/resources/configs/dshackle-full.yaml diff --git a/src/test/resources/dshackle-health-1.yaml b/src/test/resources/configs/dshackle-health-1.yaml similarity index 100% rename from src/test/resources/dshackle-health-1.yaml rename to src/test/resources/configs/dshackle-health-1.yaml diff --git a/src/test/resources/dshackle-health-2.yaml b/src/test/resources/configs/dshackle-health-2.yaml similarity index 100% rename from src/test/resources/dshackle-health-2.yaml rename to src/test/resources/configs/dshackle-health-2.yaml diff --git a/src/test/resources/dshackle-health-empty.yaml b/src/test/resources/configs/dshackle-health-empty.yaml similarity index 100% rename from src/test/resources/dshackle-health-empty.yaml rename to src/test/resources/configs/dshackle-health-empty.yaml diff --git a/src/test/resources/dshackle-monitoring-basic.yaml b/src/test/resources/configs/dshackle-monitoring-basic.yaml similarity index 100% rename from src/test/resources/dshackle-monitoring-basic.yaml rename to src/test/resources/configs/dshackle-monitoring-basic.yaml diff --git a/src/test/resources/dshackle-proxy-basic.yaml b/src/test/resources/configs/dshackle-proxy-basic.yaml similarity index 100% rename from src/test/resources/dshackle-proxy-basic.yaml rename to src/test/resources/configs/dshackle-proxy-basic.yaml diff --git a/src/test/resources/dshackle-proxy-max.yaml b/src/test/resources/configs/dshackle-proxy-max.yaml similarity index 100% rename from src/test/resources/dshackle-proxy-max.yaml rename to src/test/resources/configs/dshackle-proxy-max.yaml diff --git a/src/test/resources/dshackle-proxy-no-ws.yaml b/src/test/resources/configs/dshackle-proxy-no-ws.yaml similarity index 100% rename from src/test/resources/dshackle-proxy-no-ws.yaml rename to src/test/resources/configs/dshackle-proxy-no-ws.yaml diff --git a/src/test/resources/dshackle-proxy-two.yaml b/src/test/resources/configs/dshackle-proxy-two.yaml similarity index 100% rename from src/test/resources/dshackle-proxy-two.yaml rename to src/test/resources/configs/dshackle-proxy-two.yaml diff --git a/src/test/resources/upstreams-basic.yaml b/src/test/resources/configs/upstreams-basic.yaml similarity index 100% rename from src/test/resources/upstreams-basic.yaml rename to src/test/resources/configs/upstreams-basic.yaml diff --git a/src/test/resources/upstreams-bitcoin-esplora.yaml b/src/test/resources/configs/upstreams-bitcoin-esplora.yaml similarity index 100% rename from src/test/resources/upstreams-bitcoin-esplora.yaml rename to src/test/resources/configs/upstreams-bitcoin-esplora.yaml diff --git a/src/test/resources/upstreams-bitcoin.yaml b/src/test/resources/configs/upstreams-bitcoin.yaml similarity index 100% rename from src/test/resources/upstreams-bitcoin.yaml rename to src/test/resources/configs/upstreams-bitcoin.yaml diff --git a/src/test/resources/upstreams-ds.yaml b/src/test/resources/configs/upstreams-ds.yaml similarity index 100% rename from src/test/resources/upstreams-ds.yaml rename to src/test/resources/configs/upstreams-ds.yaml diff --git a/src/test/resources/upstreams-extra.yaml b/src/test/resources/configs/upstreams-extra.yaml similarity index 100% rename from src/test/resources/upstreams-extra.yaml rename to src/test/resources/configs/upstreams-extra.yaml diff --git a/src/test/resources/upstreams-labels.yaml b/src/test/resources/configs/upstreams-labels.yaml similarity index 100% rename from src/test/resources/upstreams-labels.yaml rename to src/test/resources/configs/upstreams-labels.yaml diff --git a/src/test/resources/upstreams-methods-quorum.yaml b/src/test/resources/configs/upstreams-methods-quorum.yaml similarity index 100% rename from src/test/resources/upstreams-methods-quorum.yaml rename to src/test/resources/configs/upstreams-methods-quorum.yaml diff --git a/src/test/resources/upstreams-methods.yaml b/src/test/resources/configs/upstreams-methods.yaml similarity index 100% rename from src/test/resources/upstreams-methods.yaml rename to src/test/resources/configs/upstreams-methods.yaml diff --git a/src/test/resources/upstreams-no-defaults.yaml b/src/test/resources/configs/upstreams-no-defaults.yaml similarity index 100% rename from src/test/resources/upstreams-no-defaults.yaml rename to src/test/resources/configs/upstreams-no-defaults.yaml diff --git a/src/test/resources/upstreams-no-id.yaml b/src/test/resources/configs/upstreams-no-id.yaml similarity index 100% rename from src/test/resources/upstreams-no-id.yaml rename to src/test/resources/configs/upstreams-no-id.yaml diff --git a/src/test/resources/upstreams-options.yaml b/src/test/resources/configs/upstreams-options.yaml similarity index 100% rename from src/test/resources/upstreams-options.yaml rename to src/test/resources/configs/upstreams-options.yaml diff --git a/src/test/resources/configs/upstreams-priority.yaml b/src/test/resources/configs/upstreams-priority.yaml new file mode 100644 index 00000000..2a165754 --- /dev/null +++ b/src/test/resources/configs/upstreams-priority.yaml @@ -0,0 +1,26 @@ +version: v1 + +upstreams: + + - id: local + chain: ethereum + priority: 100 + connection: + ethereum: + rpc: + url: "http://localhost:8545" + + - id: infura + chain: ethereum + role: fallback + priority: 50 + connection: + ethereum: + rpc: + url: "https://mainnet.infura.io/v3/fa28c968191849c1aff541ad1d8511f2" + + - id: remote + priority: 75 + connection: + grpc: + host: "10.2.0.15" \ No newline at end of file diff --git a/src/test/resources/upstreams-roles-2.yaml b/src/test/resources/configs/upstreams-roles-2.yaml similarity index 100% rename from src/test/resources/upstreams-roles-2.yaml rename to src/test/resources/configs/upstreams-roles-2.yaml diff --git a/src/test/resources/upstreams-roles-invalid.yaml b/src/test/resources/configs/upstreams-roles-invalid.yaml similarity index 100% rename from src/test/resources/upstreams-roles-invalid.yaml rename to src/test/resources/configs/upstreams-roles-invalid.yaml diff --git a/src/test/resources/upstreams-roles.yaml b/src/test/resources/configs/upstreams-roles.yaml similarity index 100% rename from src/test/resources/upstreams-roles.yaml rename to src/test/resources/configs/upstreams-roles.yaml diff --git a/src/test/resources/upstreams-ws-full.yaml b/src/test/resources/configs/upstreams-ws-full.yaml similarity index 100% rename from src/test/resources/upstreams-ws-full.yaml rename to src/test/resources/configs/upstreams-ws-full.yaml diff --git a/src/test/resources/upstreams-ws-only.yaml b/src/test/resources/configs/upstreams-ws-only.yaml similarity index 100% rename from src/test/resources/upstreams-ws-only.yaml rename to src/test/resources/configs/upstreams-ws-only.yaml