refactor chain names

This commit is contained in:
a10zn8
2023-06-29 00:01:53 +04:00
parent 2607758197
commit aff954b533
52 changed files with 458 additions and 459 deletions

View File

@@ -48,7 +48,7 @@ class BlocksRedisCacheSpec extends Specification {
redis = IntegrationTestingCommons.redisConnection()
redis.sync().flushdb()
cache = new BlocksRedisCache(
redis.reactive(), Chain.ETHEREUM
redis.reactive(), Chain.ETHEREUM__MAINNET
)
}

View File

@@ -44,7 +44,7 @@ class HeightByHashRedisCacheSpec extends Specification {
redis = IntegrationTestingCommons.redisConnection()
redis.sync().flushdb()
cache = new HeightByHashRedisCache(
redis.reactive(), Chain.ETHEREUM
redis.reactive(), Chain.ETHEREUM__MAINNET
)
}

View File

@@ -47,7 +47,7 @@ class ReceiptRedisCacheSpec extends Specification {
redis = IntegrationTestingCommons.redisConnection()
redis.sync().flushdb()
cache = new ReceiptRedisCache(
redis.reactive(), Chain.ETHEREUM
redis.reactive(), Chain.ETHEREUM__MAINNET
)
}

View File

@@ -50,7 +50,7 @@ class TxRedisCacheSpec extends Specification {
def setup() {
StatefulRedisConnection<String, byte[]> redis = IntegrationTestingCommons.redisConnection()
redis.sync().flushdb()
cache = new TxRedisCache(redis.reactive(), Chain.ETHEREUM)
cache = new TxRedisCache(redis.reactive(), Chain.ETHEREUM__MAINNET)
}
def "Decode encoded"() {

View File

@@ -31,10 +31,10 @@ class ChainsConfigReaderSpec extends Specification {
def stream = this.class.getClassLoader().getResourceAsStream("configs/chains-basic.yaml")
when:
def config = reader.read(stream)
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)
def eth = config.resolve(Chain.ETHEREUM__MAINNET)
def pol = config.resolve(Chain.POLYGON_POS__MAINNET)
def opt = config.resolve(Chain.OPTIMISM__MAINNET)
def sep = config.resolve(Chain.ETHEREUM__SEPOLIA)
then:
eth.laggingLagSize == 1
eth.syncingLagSize == 6

View File

@@ -50,7 +50,7 @@ class HealthConfigReaderSpec extends Specification {
with(act.configs()) {
size() == 1
with(it[0]) {
it.blockchain == Chain.ETHEREUM
it.blockchain == Chain.ETHEREUM__MAINNET
it.minAvailable == 2
}
}
@@ -70,11 +70,11 @@ class HealthConfigReaderSpec extends Specification {
with(act.configs().toSorted { it.blockchain.id }) {
size() == 2
with(it[0]) {
it.blockchain == Chain.BITCOIN
it.blockchain == Chain.BITCOIN__MAINNET
it.minAvailable == 1
}
with(it[1]) {
it.blockchain == Chain.ETHEREUM
it.blockchain == Chain.ETHEREUM__MAINNET
it.minAvailable == 2
}
}

View File

@@ -54,23 +54,23 @@ class MainConfigReaderSpec extends Specification {
routes.size() == 5
with(routes[0]) {
id == "eth"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
}
with(routes[1]) {
id == "etc"
blockchain == Chain.ETHEREUM_CLASSIC
blockchain == Chain.ETHEREUM_CLASSIC__MAINNET
}
with(routes[2]) {
id == "kovan"
blockchain == Chain.TESTNET_KOVAN
blockchain == Chain.ETHEREUM__KOVAN
}
with(routes[3]) {
id == "goerli"
blockchain == Chain.TESTNET_GOERLI
blockchain == Chain.ETHEREUM__GOERLI
}
with(routes[4]) {
id == "rinkeby"
blockchain == Chain.TESTNET_RINKEBY
blockchain == Chain.ETHEREUM__RINKEBY
}
}
with(act.health) {
@@ -78,7 +78,7 @@ class MainConfigReaderSpec extends Specification {
with(it.configs()) {
it.size() == 1
with(it[0]) {
it.blockchain == Chain.ETHEREUM
it.blockchain == Chain.ETHEREUM__MAINNET
it.minAvailable == 1
}
}

View File

@@ -36,7 +36,7 @@ class ProxyConfigReaderSpec extends Specification {
act.routes.size() == 1
with(act.routes[0]) {
id == "ethereum"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
}
}
@@ -63,11 +63,11 @@ class ProxyConfigReaderSpec extends Specification {
act.routes.size() == 2
with(act.routes[0]) {
id == "ethereum"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
}
with(act.routes[1]) {
id == "classic"
blockchain == Chain.ETHEREUM_CLASSIC
blockchain == Chain.ETHEREUM_CLASSIC__MAINNET
}
}
@@ -87,11 +87,11 @@ class ProxyConfigReaderSpec extends Specification {
act.corsAllowedHeaders == "Content-Type"
with(act.routes[0]) {
id == "ethereum"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
}
with(act.routes[1]) {
id == "classic"
blockchain == Chain.ETHEREUM_CLASSIC
blockchain == Chain.ETHEREUM_CLASSIC__MAINNET
}
}
}

View File

@@ -33,14 +33,14 @@ class TokensConfigReaderSpec extends Specification {
act.tokens.size() == 2
with(act.tokens[0]) {
id == "dai"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
name == "DAI"
type == TokensConfig.Type.ERC20
address == "0x6B175474E89094C44Da98b954EedeAC495271d0F"
}
with(act.tokens[1]) {
id == "tether"
blockchain == Chain.ETHEREUM
blockchain == Chain.ETHEREUM__MAINNET
name == "Tether"
type == TokensConfig.Type.ERC20
address == "0xdac17f958d2ee523a2206206994597c13d831ec7"

View File

@@ -20,7 +20,6 @@ import io.emeraldpay.dshackle.config.HealthConfig
import io.emeraldpay.dshackle.upstream.Multistream
import io.emeraldpay.dshackle.upstream.MultistreamHolder
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import spock.lang.Specification
class HealthCheckSetupSpec extends Specification {
@@ -28,8 +27,8 @@ class HealthCheckSetupSpec extends Specification {
def "OK when meets availability - 1"() {
setup:
def config = new HealthConfig().tap {
it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig(
Chain.ETHEREUM, 1
it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig(
Chain.ETHEREUM__MAINNET, 1
)
}
def up1 = Mock(Upstream)
@@ -43,7 +42,7 @@ class HealthCheckSetupSpec extends Specification {
then:
act.ok
act.details == ["OK"]
1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams
1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams
1 * ethereumUpstreams.available >> true
1 * ethereumUpstreams.getAll() >> [up1]
1 * up1.isAvailable() >> true
@@ -52,8 +51,8 @@ class HealthCheckSetupSpec extends Specification {
def "OK when meets availability - 1 - bitcoin"() {
setup:
def config = new HealthConfig().tap {
it.chains[Chain.BITCOIN] = new HealthConfig.ChainConfig(
Chain.BITCOIN, 1
it.chains[Chain.BITCOIN__MAINNET] = new HealthConfig.ChainConfig(
Chain.BITCOIN__MAINNET, 1
)
}
def up1 = Mock(Upstream)
@@ -67,7 +66,7 @@ class HealthCheckSetupSpec extends Specification {
then:
act.ok
act.details == ["OK"]
1 * multistream.getUpstream(Chain.BITCOIN) >> bitcoinUpstreams
1 * multistream.getUpstream(Chain.BITCOIN__MAINNET) >> bitcoinUpstreams
1 * bitcoinUpstreams.available >> true
1 * bitcoinUpstreams.getAll() >> [up1]
1 * up1.isAvailable() >> true
@@ -76,8 +75,8 @@ class HealthCheckSetupSpec extends Specification {
def "OK when meets availability - 2/3"() {
setup:
def config = new HealthConfig().tap {
it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig(
Chain.ETHEREUM, 2
it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig(
Chain.ETHEREUM__MAINNET, 2
)
}
def up1 = Mock(Upstream)
@@ -93,7 +92,7 @@ class HealthCheckSetupSpec extends Specification {
then:
act.ok
act.details == ["OK"]
1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams
1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams
1 * ethereumUpstreams.available >> true
1 * ethereumUpstreams.getAll() >> [up1, up2, up3]
1 * up1.isAvailable() >> true
@@ -104,8 +103,8 @@ class HealthCheckSetupSpec extends Specification {
def "OK when doesn't meet availability - 2/3"() {
setup:
def config = new HealthConfig().tap {
it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig(
Chain.ETHEREUM, 2
it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig(
Chain.ETHEREUM__MAINNET, 2
)
}
def up1 = Mock(Upstream)
@@ -121,7 +120,7 @@ class HealthCheckSetupSpec extends Specification {
then:
!act.ok
act.details != ["OK"]
1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams
1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams
1 * ethereumUpstreams.available >> true
1 * ethereumUpstreams.getAll() >> [up1, up2, up3]
1 * up1.isAvailable() >> true
@@ -132,8 +131,8 @@ class HealthCheckSetupSpec extends Specification {
def "OK when meets availability - 2/3 - detailed"() {
setup:
def config = new HealthConfig().tap {
it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig(
Chain.ETHEREUM, 2
it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig(
Chain.ETHEREUM__MAINNET, 2
)
}
def up1 = Mock(Upstream)
@@ -149,8 +148,8 @@ class HealthCheckSetupSpec extends Specification {
then:
act.ok
act.details.size() > 1
1 * multistream.getAvailable() >> [Chain.ETHEREUM]
1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams
1 * multistream.getAvailable() >> [Chain.ETHEREUM__MAINNET]
1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams
1 * ethereumUpstreams.available >> true
1 * ethereumUpstreams.getAll() >> [up1, up2, up3]
_ * up1.isAvailable() >> true

View File

@@ -24,7 +24,7 @@ class AccessLogWriterSpec extends Specification {
when:
def event = new Events.Status(
Chain.ETHEREUM, UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"),
Chain.ETHEREUM__MAINNET, UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"),
new Events.StreamRequestDetails(
UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"),
Instant.ofEpochMilli(1626746880123),
@@ -43,7 +43,7 @@ class AccessLogWriterSpec extends Specification {
json["version"] == "accesslog/v1beta"
json["id"] == "9d8ecbf3-12fb-49cf-af9d-949a1050a000"
json["method"] == "Status"
json["blockchain"] == "ETHEREUM"
json["blockchain"] == "ETHEREUM__MAINNET"
json["request"]["start"] == "2021-07-20T02:08:00.123Z"
json["request"]["id"] == "9d8ecbf3-12fb-49cf-af9d-949a1050a000"
json["request"]["remote"]["ip"] == "172.217.8.78"

View File

@@ -37,7 +37,7 @@ class EventsBuilderSubscribeBalanceSpec extends Specification {
}.onReply(resp)
then:
act.index == 0
act.blockchain == Chain.ETHEREUM
act.blockchain == Chain.ETHEREUM__MAINNET
act.balanceRequest.asset == "ETHER"
act.balanceRequest.addressType == "ADDRESS_SINGLE"
act.addressBalance.asset == "ETHER"
@@ -74,7 +74,7 @@ class EventsBuilderSubscribeBalanceSpec extends Specification {
}.onReply(resp)
then:
act.index == 0
act.blockchain == Chain.BITCOIN
act.blockchain == Chain.BITCOIN__MAINNET
act.balanceRequest.asset == "BTC"
act.balanceRequest.addressType == "ADDRESS_SINGLE"
act.addressBalance.asset == "BTC"

View File

@@ -34,7 +34,7 @@ class BaseHandlerSpec extends Specification {
setup:
def handler = new BaseHandlerImpl(new WriteRpcJson(), Stub(NativeCall), Stub(ProxyServer.RequestMetricsFactory))
when:
def act = Mono.from(handler.execute(Chain.ETHEREUM, new ProxyCall(ProxyCall.RpcType.SINGLE), requestHandler, false))
def act = Mono.from(handler.execute(Chain.ETHEREUM__MAINNET, new ProxyCall(ProxyCall.RpcType.SINGLE), requestHandler, false))
.block(Duration.ofSeconds(1))
then:
act == ""
@@ -44,7 +44,7 @@ class BaseHandlerSpec extends Specification {
setup:
def handler = new BaseHandlerImpl(new WriteRpcJson(), Stub(NativeCall), Stub(ProxyServer.RequestMetricsFactory))
when:
def act = Mono.from(handler.execute(Chain.ETHEREUM, new ProxyCall(ProxyCall.RpcType.BATCH), requestHandler, false))
def act = Mono.from(handler.execute(Chain.ETHEREUM__MAINNET, new ProxyCall(ProxyCall.RpcType.BATCH), requestHandler, false))
.block(Duration.ofSeconds(1))
then:
act == "[]"
@@ -64,7 +64,7 @@ class BaseHandlerSpec extends Specification {
call.ids[0] = 5
def response = new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null)
when:
def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, false))
def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, false))
.collectList()
.block(Duration.ofSeconds(1))
.join("")
@@ -87,7 +87,7 @@ class BaseHandlerSpec extends Specification {
call.ids[0] = 5
def response = new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null)
when:
def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, false))
def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, false))
.collectList()
.block(Duration.ofSeconds(1))
.join("")
@@ -120,7 +120,7 @@ class BaseHandlerSpec extends Specification {
new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null)
]
when:
def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true))
def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true))
.collectList()
.block(Duration.ofSeconds(1))
.join("")
@@ -153,7 +153,7 @@ class BaseHandlerSpec extends Specification {
new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null)
]
when:
def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true))
def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true))
.collectList()
.block(Duration.ofSeconds(1))
.join("")
@@ -193,7 +193,7 @@ class BaseHandlerSpec extends Specification {
new NativeCall.CallResult(2, null, '{"foo": 3}'.bytes, null, null, null, null)
]
when:
def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true))
def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true))
.collectList()
.block(Duration.ofSeconds(1))
.join("")

View File

@@ -44,7 +44,7 @@ class HttpHandlerSpec extends Specification {
.build()
def respItem = new NativeCall.CallResult(1, null, "100".bytes, null, null, null, null)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(reqItem)
.build()
@@ -62,7 +62,7 @@ class HttpHandlerSpec extends Specification {
)
when:
handler.execute(Chain.ETHEREUM, [reqItem], accessHandler)
handler.execute(Chain.ETHEREUM__MAINNET, [reqItem], accessHandler)
.blockLast()
then:
@@ -79,7 +79,7 @@ class HttpHandlerSpec extends Specification {
1 * increment()
}
ProxyServer.RequestMetricsFactory metrics = Mock(ProxyServer.RequestMetricsFactory) {
1 * get(Chain.ETHEREUM, "invalid_method") >> Mock(ProxyServer.RequestMetrics) {
1 * get(Chain.ETHEREUM__MAINNET, "invalid_method") >> Mock(ProxyServer.RequestMetrics) {
1 * it.errorMetric >> errorMetric
}
}
@@ -92,7 +92,7 @@ class HttpHandlerSpec extends Specification {
)
when:
def act = handler.processRequest(Chain.ETHEREUM, Mono.just("".bytes), new AccessHandlerHttp.NoOpHandler())
def act = handler.processRequest(Chain.ETHEREUM__MAINNET, Mono.just("".bytes), new AccessHandlerHttp.NoOpHandler())
.map { new String(it.array()) }
then:
StepVerifier.create(act)
@@ -125,7 +125,7 @@ class HttpHandlerSpec extends Specification {
.build()
)
when:
def act = handler.execute(Chain.ETHEREUM, call, new AccessHandlerHttp.NoOpHandler(), false)
def act = handler.execute(Chain.ETHEREUM__MAINNET, call, new AccessHandlerHttp.NoOpHandler(), false)
then:
1 * nativeCall.nativeCallResult(_) >> Flux.just(new NativeCall.CallResult(1, null, "".bytes, null, null, null, null))

View File

@@ -16,7 +16,7 @@ class ProxyServerSpec extends Specification {
setup:
def config1 = new ProxyConfig()
config1.routes = [
new ProxyConfig.Route("test", Chain.ETHEREUM)
new ProxyConfig.Route("test", Chain.ETHEREUM__MAINNET)
]
def proxyServer = new ProxyServer(
config1,
@@ -40,7 +40,7 @@ class ProxyServerSpec extends Specification {
def config1 = new ProxyConfig()
config1.websocketEnabled = false
config1.routes = [
new ProxyConfig.Route("test", Chain.ETHEREUM)
new ProxyConfig.Route("test", Chain.ETHEREUM__MAINNET)
]
def proxyServer = new ProxyServer(
config1,

View File

@@ -39,7 +39,7 @@ class WebsocketHandlerSpec extends Specification {
new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory)
)
when:
def act = handler.parseRequest('{"id": 5, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x100001", false]}'.bytes, Chain.ETHEREUM)
def act = handler.parseRequest('{"id": 5, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x100001", false]}'.bytes, Chain.ETHEREUM__MAINNET)
.block(Duration.ofSeconds(1))
then:
@@ -54,7 +54,7 @@ class WebsocketHandlerSpec extends Specification {
1 * increment()
}
ProxyServer.RequestMetricsFactory metrics = Mock(ProxyServer.RequestMetricsFactory) {
1 * get(Chain.ETHEREUM, "invalid_method") >> Mock(ProxyServer.RequestMetrics) {
1 * get(Chain.ETHEREUM__MAINNET, "invalid_method") >> Mock(ProxyServer.RequestMetrics) {
1 * it.errorMetric >> errorMetric
}
}
@@ -62,7 +62,7 @@ class WebsocketHandlerSpec extends Specification {
new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, metrics
)
when:
def act = handler.parseRequest('hello world'.bytes, Chain.ETHEREUM)
def act = handler.parseRequest('hello world'.bytes, Chain.ETHEREUM__MAINNET)
.block(Duration.ofSeconds(1))
then:
@@ -76,7 +76,7 @@ class WebsocketHandlerSpec extends Specification {
new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory)
)
when:
def act = handler.parseRequest("[$req1]".bytes, Chain.ETHEREUM)
def act = handler.parseRequest("[$req1]".bytes, Chain.ETHEREUM__MAINNET)
.block(Duration.ofSeconds(1))
then:
@@ -96,7 +96,7 @@ class WebsocketHandlerSpec extends Specification {
def request = new RequestJson("foo_test", [], 2)
when:
def act = handler.respond(Chain.ETHEREUM, new HashMap<String, Sinks.One<Boolean>>(), Flux.just(request), requestHandler)
def act = handler.respond(Chain.ETHEREUM__MAINNET, new HashMap<String, Sinks.One<Boolean>>(), Flux.just(request), requestHandler)
.single()
.block(Duration.ofSeconds(1))
then:
@@ -109,7 +109,7 @@ class WebsocketHandlerSpec extends Specification {
def response2 = [foo: 2]
def nativeSubscribe = Mock(NativeSubscribe) {
1 * it.subscribe(Chain.ETHEREUM, "foo_test", null, Selector.empty) >> Flux.fromIterable([response1, response2])
1 * it.subscribe(Chain.ETHEREUM__MAINNET, "foo_test", null, Selector.empty) >> Flux.fromIterable([response1, response2])
}
def handler = new WebsocketHandler(
new ReadRpcJson(), new WriteRpcJson(), Stub(NativeCall), nativeSubscribe, requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory)
@@ -117,7 +117,7 @@ class WebsocketHandlerSpec extends Specification {
def request = new RequestJson("eth_subscribe", ["foo_test"], 2)
when:
def act = handler.respond(Chain.ETHEREUM, new HashMap<String, Sinks.One<Boolean>>(), Flux.just(request), requestHandler)
def act = handler.respond(Chain.ETHEREUM__MAINNET, new HashMap<String, Sinks.One<Boolean>>(), Flux.just(request), requestHandler)
.collectList()
.block(Duration.ofSeconds(1))
then:
@@ -139,7 +139,7 @@ class WebsocketHandlerSpec extends Specification {
control["5"] = sink
def request = new RequestJson("eth_unsubscribe", ["5"], 0)
when:
def act = handler.respond(Chain.ETHEREUM, control, Flux.just(request), requestHandler)
def act = handler.respond(Chain.ETHEREUM__MAINNET, control, Flux.just(request), requestHandler)
.single()
.block(Duration.ofSeconds(1))
def sinkResponse = sink.asMono().block()
@@ -158,7 +158,7 @@ class WebsocketHandlerSpec extends Specification {
def control = new HashMap<String, Sinks.One<Boolean>>()
def request = new RequestJson("eth_unsubscribe", ["5"], 0)
when:
def act = handler.respond(Chain.ETHEREUM, control, Flux.just(request), requestHandler)
def act = handler.respond(Chain.ETHEREUM__MAINNET, control, Flux.just(request), requestHandler)
.single()
.block(Duration.ofSeconds(1))
then:

View File

@@ -45,7 +45,7 @@ class QuorumRpcReaderSpec extends Specification {
}
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
@@ -76,7 +76,7 @@ class QuorumRpcReaderSpec extends Specification {
_ * getIngressReader() >> api
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
@@ -113,7 +113,7 @@ class QuorumRpcReaderSpec extends Specification {
_ * getIngressReader() >> api
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
@@ -145,7 +145,7 @@ class QuorumRpcReaderSpec extends Specification {
}
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
@@ -177,7 +177,7 @@ class QuorumRpcReaderSpec extends Specification {
}
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
@@ -210,7 +210,7 @@ class QuorumRpcReaderSpec extends Specification {
_ * getIngressReader() >> api
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
@@ -240,7 +240,7 @@ class QuorumRpcReaderSpec extends Specification {
_ * getIngressReader() >> api
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
@@ -273,7 +273,7 @@ class QuorumRpcReaderSpec extends Specification {
}
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new NotLaggingQuorum(1), Stub(Tracer))
@@ -299,7 +299,7 @@ class QuorumRpcReaderSpec extends Specification {
_ * getIngressReader() >> api
}
def apis = new FilteredApis(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
[up], Selector.empty
)
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))

View File

@@ -297,7 +297,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(upstreams)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChainValue(Chain.TESTNET_MORDEN.id)
.setChainValue(Chain.ETHEREUM__MORDEN.id)
.addAllItems([1, 2].collect { id ->
return BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(id)
@@ -305,7 +305,7 @@ class NativeCallSpec extends Specification {
.build()
})
.build()
1 * upstreams.isAvailable(Chain.TESTNET_MORDEN) >> false
1 * upstreams.isAvailable(Chain.ETHEREUM__MORDEN) >> false
when:
def resp = nativeCall.prepareCall(req)
then:
@@ -323,7 +323,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(upstreams)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -353,7 +353,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(upstreams)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -384,11 +384,11 @@ class NativeCallSpec extends Specification {
.setMethod("eth_testInvalid")
.build()
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(item)
.build()
when:
def act = nativeCall.prepareIndividualCall(Chain.ETHEREUM, req, item, TestingCommons.emptyMultistream())
def act = nativeCall.prepareIndividualCall(Chain.ETHEREUM__MAINNET, req, item, TestingCommons.emptyMultistream())
.block(Duration.ofSeconds(1))
then:
act instanceof NativeCall.InvalidCallContext
@@ -402,14 +402,14 @@ class NativeCallSpec extends Specification {
def "Prepare call adds height selector for not-lagging quorum"() {
setup:
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["foo_bar"] as Set, [] as Set, [] as Set, [] as Set
)
methods.setQuorum("foo_bar", "not_lagging")
def head = Mock(Head) {
1 * it.getCurrentHeight() >> 101
}
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream())
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
multistream.customMethods = methods
multistream.customHead = head
def multistreamHolder = Mock(MultistreamHolder) {
@@ -418,7 +418,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(multistreamHolder)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -443,11 +443,11 @@ class NativeCallSpec extends Specification {
def "Prepare call adds decorator for eth_newFilter"() {
setup:
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_newFilter"] as Set, [] as Set, [] as Set, [] as Set
)
methods.setQuorum("eth_newFilter", "always")
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream())
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
multistream.customMethods = methods
multistream.customHead = Mock(Head)
def multistreamHolder = Mock(MultistreamHolder) {
@@ -456,7 +456,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(multistreamHolder)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -474,10 +474,10 @@ class NativeCallSpec extends Specification {
def "Prepare call adds decorator for eth_getFilterChanges"() {
setup:
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_getFilterChanges"] as Set, [] as Set, [] as Set, [] as Set
)
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream())
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
multistream.customMethods = methods
multistream.customHead = Mock(Head)
def multistreamHolder = Mock(MultistreamHolder) {
@@ -486,7 +486,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(multistreamHolder)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -504,10 +504,10 @@ class NativeCallSpec extends Specification {
def "Prepare call adds decorator for eth_uninstallFilter"() {
setup:
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_uninstallFilter"] as Set, [] as Set, [] as Set, [] as Set
)
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream())
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
multistream.customMethods = methods
multistream.customHead = Mock(Head)
def multistreamHolder = Mock(MultistreamHolder) {
@@ -516,7 +516,7 @@ class NativeCallSpec extends Specification {
def nativeCall = nativeCall(multistreamHolder)
def req = BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.addItems(
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -604,10 +604,10 @@ class NativeCallSpec extends Specification {
}
def quorum = new AlwaysQuorum()
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
[] as Set, [] as Set, ["filter"] as Set, [] as Set
)
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream(
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream(
TestingCommons.api(), methods
))
multistream.customHead = Mock(Head)
@@ -639,10 +639,10 @@ class NativeCallSpec extends Specification {
}
def quorum = new AlwaysQuorum()
def methods = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
[] as Set, [] as Set, ["filter"] as Set, [] as Set
)
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream(
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream(
TestingCommons.api(), methods
))
multistream.customHead = Mock(Head)

View File

@@ -35,7 +35,7 @@ class NativeSubscribeSpec extends Specification {
def "Call with empty params when not provided"() {
setup:
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id)
.setChainValue(Chain.ETHEREUM__MAINNET.id)
.setMethod("newHeads")
.build()
@@ -47,7 +47,7 @@ class NativeSubscribeSpec extends Specification {
1 * it.getEgressSubscription() >> subscribe
}
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer)
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer)
when:
def act = nativeSubscribe.start(call)
@@ -62,7 +62,7 @@ class NativeSubscribeSpec extends Specification {
def "Call with params when provided"() {
setup:
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id)
.setChainValue(Chain.ETHEREUM__MAINNET.id)
.setMethod("logs")
.setPayload(ByteString.copyFromUtf8(
'{"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", ' +
@@ -86,7 +86,7 @@ class NativeSubscribeSpec extends Specification {
1 * it.getEgressSubscription() >> subscribe
}
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer)
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer)
when:
def act = nativeSubscribe.start(call)
@@ -101,7 +101,7 @@ class NativeSubscribeSpec extends Specification {
def "Proxy call"() {
setup:
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id)
.setChainValue(Chain.ETHEREUM__MAINNET.id)
.setMethod("newHeads")
.build()
def up = Mock(EthereumPosMultiStream) {
@@ -109,7 +109,7 @@ class NativeSubscribeSpec extends Specification {
0 * it.getEgressSubscription()
}
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer)
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer)
when:
def act = nativeSubscribe.start(call)

View File

@@ -43,11 +43,11 @@ class StreamHeadSpec extends Specification {
def "Errors on unavailable chain"() {
setup:
def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, Stub(EthereumPosRpcUpstream))
def upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, Stub(EthereumPosRpcUpstream))
def streamHead = new StreamHead(upstreams)
when:
def flux = streamHead.add(
Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM_CLASSIC).build())
Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM_CLASSIC__MAINNET).build())
)
then:
StepVerifier.create(flux)
@@ -71,7 +71,7 @@ class StreamHeadSpec extends Specification {
def heads = blocks.collect {
return BlockchainOuterClass.ChainHead.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.setTimestamp(it.timestamp.toEpochMilli())
.setBlockId(it.hash.toHex().substring(2))
.setWeight(ByteString.copyFrom(it.totalDifficulty.toByteArray()))
@@ -80,12 +80,12 @@ class StreamHeadSpec extends Specification {
.build()
}
def upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, TestingCommons.api())
def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstream)
def upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.api())
def upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstream)
def streamHead = new StreamHead(upstreams)
when:
def flux = streamHead.add(
Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM).build())
Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM__MAINNET).build())
)
then:
StepVerifier.create(flux.take(2))

View File

@@ -26,14 +26,14 @@ class SubscribeStatusSpec extends Specification {
_ * it.getAll() >> [ethereumUp]
}
def ups = Mock(MultistreamHolder) {
_ * it.getAvailable() >> [Chain.ETHEREUM]
1 * it.getUpstream(Chain.ETHEREUM) >> ethereumUpAll
_ * it.getAvailable() >> [Chain.ETHEREUM__MAINNET]
1 * it.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpAll
}
def ctrl = new SubscribeStatus(ups)
when:
def req = BlockchainOuterClass.StatusRequest.newBuilder()
.addChains(Common.ChainRef.CHAIN_ETHEREUM)
.addChains(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.build()
def act = ctrl.subscribeStatus(Mono.just(req))
.take(1)
@@ -47,7 +47,7 @@ class SubscribeStatusSpec extends Specification {
then:
StepVerifier.create(act)
.expectNextMatches {
it.chainValue == Chain.ETHEREUM.id && it.availability == BlockchainOuterClass.AvailabilityEnum.AVAIL_OK
it.chainValue == Chain.ETHEREUM__MAINNET.id && it.availability == BlockchainOuterClass.AvailabilityEnum.AVAIL_OK
}
.expectComplete()
.verify(Duration.ofSeconds(3))

View File

@@ -52,7 +52,7 @@ class TrackBitcoinAddressSpec extends Specification {
]
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
when:
def total = track.totalUnspent(address, false, unspents)
@@ -70,7 +70,7 @@ class TrackBitcoinAddressSpec extends Specification {
]
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
when:
def total = track.totalUnspent(address, false, unspents)
@@ -85,7 +85,7 @@ class TrackBitcoinAddressSpec extends Specification {
def unspents = []
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
when:
def total = track.totalUnspent(address, false, unspents)
@@ -99,7 +99,7 @@ class TrackBitcoinAddressSpec extends Specification {
setup:
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
def api = Mock(BitcoinMultistream) {
1 * getReader() >> Mock(BitcoinReader) {
@@ -122,7 +122,7 @@ class TrackBitcoinAddressSpec extends Specification {
]
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
when:
def total = track.totalUnspent(address, true, unspents)
@@ -225,39 +225,39 @@ class TrackBitcoinAddressSpec extends Specification {
def "Build proto for common balance"() {
setup:
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(123456))
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(123456))
when:
def act = track.buildResponse(balance)
then:
act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
act.balance == "123456"
act.asset.chain.number == Chain.BITCOIN.id
act.asset.chain.number == Chain.BITCOIN__MAINNET.id
act.asset.code == "BTC"
}
def "Build proto for zero balance"() {
setup:
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.ZERO)
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.ZERO)
when:
def act = track.buildResponse(balance)
then:
act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
act.balance == "0"
act.asset.chain.number == Chain.BITCOIN.id
act.asset.chain.number == Chain.BITCOIN__MAINNET.id
act.asset.code == "BTC"
}
def "Build proto for all bitcoins"() {
setup:
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(21_000_000).multiply(BigInteger.TEN.pow(8)))
def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(21_000_000).multiply(BigInteger.TEN.pow(8)))
when:
def act = track.buildResponse(balance)
then:
act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
act.balance == "2100000000000000"
act.asset.chain.number == Chain.BITCOIN.id
act.asset.chain.number == Chain.BITCOIN__MAINNET.id
act.asset.code == "BTC"
}
@@ -288,13 +288,13 @@ class TrackBitcoinAddressSpec extends Specification {
upstream
}
}
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.BITCOIN, upstream)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.BITCOIN__MAINNET, upstream)
TrackBitcoinAddress track = new TrackBitcoinAddress(upstreams)
track.setBalanceAvailability(Chain.BITCOIN, true)
track.setBalanceAvailability(Chain.BITCOIN__MAINNET, true)
when:
def resp = track.subscribe(BlockchainOuterClass.BalanceRequest.newBuilder()
.setAsset(Common.Asset.newBuilder().setChain(Common.ChainRef.CHAIN_BITCOIN))
.setAsset(Common.Asset.newBuilder().setChain(Common.ChainRef.CHAIN_BITCOIN__MAINNET))
.setAddress(
Common.AnyAddress.newBuilder().setAddressSingle(
Common.SingleAddress.newBuilder().setAddress("1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")

View File

@@ -241,7 +241,7 @@ class TrackBitcoinTxSpec extends Specification {
when:
def steps = StepVerifier.withVirtualTime {
track.untilFound(Chain.BITCOIN, upstream, txid).take(1)
track.untilFound(Chain.BITCOIN__MAINNET, upstream, txid).take(1)
}
then:
@@ -282,7 +282,7 @@ class TrackBitcoinTxSpec extends Specification {
}
when:
def act = track.subscribe(Chain.BITCOIN, upstream, txid)
def act = track.subscribe(Chain.BITCOIN__MAINNET, upstream, txid)
then:
StepVerifier.create(act)

View File

@@ -30,12 +30,12 @@ class TrackERC20AddressSpec extends Specification {
def "Init with single token"() {
setup:
MultistreamHolder ups = Mock(MultistreamHolder) {
_ * isAvailable(Chain.ETHEREUM) >> true
_ * isAvailable(Chain.ETHEREUM__MAINNET) >> true
}
TokensConfig tokens = new TokensConfig([
new TokensConfig.Token().tap {
id = "dai"
blockchain = Chain.ETHEREUM
blockchain = Chain.ETHEREUM__MAINNET
name = "DAI"
type = TokensConfig.Type.ERC20
address = Address.from("0x6B175474E89094C44Da98b954EedeAC495271d0F")
@@ -45,17 +45,17 @@ class TrackERC20AddressSpec extends Specification {
when:
track.init()
def act = track.tokens
def supportDai = track.isSupported(Chain.ETHEREUM, "DAI")
def supportSai = track.isSupported(Chain.ETHEREUM, "SAI")
def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "DAI")
def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "SAI")
then:
act.size() == 1
with(act.keySet().first()) {
chain == Chain.ETHEREUM
chain == Chain.ETHEREUM__MAINNET
name == "dai"
}
with(act.values().first()) {
chain == Chain.ETHEREUM
chain == Chain.ETHEREUM__MAINNET
name == "dai"
token != null
}
@@ -66,7 +66,7 @@ class TrackERC20AddressSpec extends Specification {
def "Init without tokens"() {
setup:
MultistreamHolder ups = Mock(MultistreamHolder) {
_ * isAvailable(Chain.ETHEREUM) >> true
_ * isAvailable(Chain.ETHEREUM__MAINNET) >> true
}
TokensConfig tokens = new TokensConfig([])
@@ -74,8 +74,8 @@ class TrackERC20AddressSpec extends Specification {
when:
track.init()
def act = track.tokens
def supportDai = track.isSupported(Chain.ETHEREUM, "dai")
def supportSai = track.isSupported(Chain.ETHEREUM, "sai")
def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "dai")
def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "sai")
then:
act.size() == 0
@@ -86,20 +86,20 @@ class TrackERC20AddressSpec extends Specification {
def "Init with two tokens"() {
setup:
MultistreamHolder ups = Mock(MultistreamHolder) {
_ * isAvailable(Chain.ETHEREUM) >> true
_ * isAvailable(Chain.ETHEREUM__MAINNET) >> true
}
TokensConfig tokens = new TokensConfig([
new TokensConfig.Token().tap {
id = "dai"
blockchain = Chain.ETHEREUM
blockchain = Chain.ETHEREUM__MAINNET
name = "DAI"
type = TokensConfig.Type.ERC20
address = Address.from("0x6B175474E89094C44Da98b954EedeAC495271d0F")
},
new TokensConfig.Token().tap {
id = "sai"
blockchain = Chain.ETHEREUM
blockchain = Chain.ETHEREUM__MAINNET
name = "SAI"
type = TokensConfig.Type.ERC20
address = Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")
@@ -109,17 +109,17 @@ class TrackERC20AddressSpec extends Specification {
when:
track.init()
def act = track.tokens
def supportDai = track.isSupported(Chain.ETHEREUM, "dai")
def supportSai = track.isSupported(Chain.ETHEREUM, "sai")
def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "dai")
def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "sai")
then:
act.size() == 2
with(act[act.keySet().find { it.name == "dai" }]) {
chain == Chain.ETHEREUM
chain == Chain.ETHEREUM__MAINNET
name == "dai"
}
with(act[act.keySet().find { it.name == "sai" }]) {
chain == Chain.ETHEREUM
chain == Chain.ETHEREUM__MAINNET
name == "sai"
}
supportDai
@@ -130,7 +130,7 @@ class TrackERC20AddressSpec extends Specification {
setup:
TrackERC20Address track = new TrackERC20Address(Stub(MultistreamHolder), new TokensConfig([]))
TrackERC20Address.TrackedAddress address = new TrackERC20Address.TrackedAddress(
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
Address.from("0x16c15c65ad00b6dfbcc2cb8a7b6c2d0103a3883b"),
new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")),
"test",
@@ -142,7 +142,7 @@ class TrackERC20AddressSpec extends Specification {
act == BlockchainOuterClass.AddressBalance.newBuilder()
.setAddress(Common.SingleAddress.newBuilder().setAddress("0x16c15c65ad00b6dfbcc2cb8a7b6c2d0103a3883b"))
.setAsset(Common.Asset.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.setCode("TEST")
)
.setBalance("1234")
@@ -194,12 +194,12 @@ class TrackERC20AddressSpec extends Specification {
}
}
def mup = Mock(MultistreamHolder) {
_ * getUpstream(Chain.ETHEREUM) >> up
_ * getUpstream(Chain.ETHEREUM__MAINNET) >> up
}
TokensConfig tokens = new TokensConfig([
new TokensConfig.Token().tap {
id = "test"
blockchain = Chain.ETHEREUM
blockchain = Chain.ETHEREUM__MAINNET
name = "TEST"
type = TokensConfig.Type.ERC20
address = Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")
@@ -220,7 +220,7 @@ class TrackERC20AddressSpec extends Specification {
)
.setAsset(
Common.Asset.newBuilder()
.setChain(Common.ChainRef.CHAIN_ETHEREUM)
.setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET)
.setCode("TEST")
)
.build()

View File

@@ -34,7 +34,7 @@ import java.time.temporal.ChronoUnit
class TrackEthereumAddressSpec extends Specification {
def chain = Common.ChainRef.CHAIN_ETHEREUM
def chain = Common.ChainRef.CHAIN_ETHEREUM__MAINNET
def address1 = "0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f"
def address1Proto = Common.SingleAddress.newBuilder()
.setAddress(address1)
@@ -57,7 +57,7 @@ class TrackEthereumAddressSpec extends Specification {
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumAddress trackAddress = new TrackEthereumAddress(upstreams)
apiMock.answer("eth_getBalance", ["0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f", "latest"], "0x499602D2")
@@ -99,7 +99,7 @@ class TrackEthereumAddressSpec extends Specification {
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumAddress trackAddress = new TrackEthereumAddress(upstreams)
apiMock.answerOnce("eth_getBalance", ["0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f", "latest"], "0x499602D2")

View File

@@ -44,7 +44,7 @@ import java.time.Instant
class TrackEthereumTxSpec extends Specification {
def chain = Common.ChainRef.CHAIN_ETHEREUM
def chain = Common.ChainRef.CHAIN_ETHEREUM__MAINNET
def txId = "0xba61ce4672751fd6086a9ac2b55547a5555af17535b6c0334ede2ecb6d64070a"
def parent = BlockHash.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")
@@ -100,7 +100,7 @@ class TrackEthereumTxSpec extends Specification {
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel())
apiMock.answer("eth_getTransactionByHash", [txId], txJson)
@@ -120,8 +120,8 @@ class TrackEthereumTxSpec extends Specification {
setup:
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
((EthereumPosMultiStream) upstreams.getUpstream(Chain.ETHEREUM)).head = Mock(DynamicMergedHead) {
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
((EthereumPosMultiStream) upstreams.getUpstream(Chain.ETHEREUM__MAINNET)).head = Mock(DynamicMergedHead) {
_ * getFlux() >> Flux.empty()
}
def scheduler = VirtualTimeScheduler.create(true)
@@ -130,9 +130,9 @@ class TrackEthereumTxSpec extends Specification {
apiMock.answer("eth_getTransactionByHash", [txId], null)
when:
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6)
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6)
def act = StepVerifier.withVirtualTime(
{ trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM).cast(EthereumPosMultiStream)) },
{ trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM__MAINNET).cast(EthereumPosMultiStream)) },
{ scheduler },
5)
@@ -170,7 +170,7 @@ class TrackEthereumTxSpec extends Specification {
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.boundedElastic())
apiMock.answer("eth_getTransactionByHash", [txId], null, 2)
@@ -191,10 +191,10 @@ class TrackEthereumTxSpec extends Specification {
setup:
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel())
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6)
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6)
def block = new BlockContainer(
100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null,
BlockId.from(txId), [TxId.from(txId)], 0, "unknown"
@@ -213,10 +213,10 @@ class TrackEthereumTxSpec extends Specification {
setup:
def apiMock = TestingCommons.api()
def upstreamMock = TestingCommons.upstream(apiMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock)
TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel())
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6)
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6)
def block = new BlockContainer(
100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, BlockId.from(txId),
[TxId.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")],
@@ -291,7 +291,7 @@ class TrackEthereumTxSpec extends Specification {
def multi = Mock(EthereumPosMultiStream) {
_ * getHead() >> upstreamMock.getHead()
}
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, multi)
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, multi)
TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel())

View File

@@ -44,7 +44,7 @@ class ConfiguredUpstreamsSpec extends Specification {
def upstream = new UpstreamsConfig.Upstream()
upstream.methods = methods
when:
def act = configurer.buildMethods(upstream, Chain.ETHEREUM)
def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET)
then:
act instanceof ManagedCallMethods
act.createQuorumFor("foo_bar") instanceof NotNullQuorum
@@ -75,7 +75,7 @@ class ConfiguredUpstreamsSpec extends Specification {
def upstream = new UpstreamsConfig.Upstream()
upstream.methods = methods
when:
def act = configurer.buildMethods(upstream, Chain.ETHEREUM)
def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET)
then:
act instanceof ManagedCallMethods
new String(act.executeHardcoded("foo_bar")) == "\"static_response\""
@@ -161,7 +161,7 @@ class ConfiguredUpstreamsSpec extends Specification {
def upstream = new UpstreamsConfig.Upstream()
upstream.methodGroups = methodsGroup
when:
def act = configurer.buildMethods(upstream, Chain.ETHEREUM)
def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET)
then:
act instanceof ManagedCallMethods
act.supportedMethods.findAll {it.containsIgnoreCase("filter")}.size() == 6

View File

@@ -42,7 +42,7 @@ class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream {
static CallMethods allMethods() {
new AggregatedCallMethods([
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
new DefaultBitcoinMethods(),
new DirectCallMethods(["eth_test"])
])

View File

@@ -40,7 +40,7 @@ class EthereumRpcUpstreamMock extends EthereumRpcUpstream {
static CallMethods allMethods() {
new AggregatedCallMethods([
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
new DefaultBitcoinMethods(),
new DirectCallMethods(["eth_test"])
])

View File

@@ -52,23 +52,23 @@ class TestingCommons {
}
static EthereumPosRpcUpstreamMock upstream() {
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api())
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api())
}
static EthereumPosRpcUpstreamMock upstream(String id) {
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api())
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api())
}
static EthereumPosRpcUpstreamMock upstream(String id, String provider) {
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api(), Collections.singletonMap("provider", provider))
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api(), Collections.singletonMap("provider", provider))
}
static EthereumPosRpcUpstreamMock upstream(String id, Reader<JsonRpcRequest, JsonRpcResponse> api) {
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api)
return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api)
}
static EthereumPosRpcUpstreamMock upstream(Reader<JsonRpcRequest, JsonRpcResponse> api) {
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api)
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api)
}
static EthereumPosRpcUpstreamMock upstream(Reader<JsonRpcRequest, JsonRpcResponse> api, String method) {
@@ -76,11 +76,11 @@ class TestingCommons {
}
static EthereumPosRpcUpstreamMock upstream(Reader<JsonRpcRequest, JsonRpcResponse> api, List<String> methods) {
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api, new DirectCallMethods(methods))
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api, new DirectCallMethods(methods))
}
static EthereumPosRpcUpstreamMock upstream(Reader<JsonRpcRequest, JsonRpcResponse> api, CallMethods callMethods) {
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api, callMethods)
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api, callMethods)
}
static Multistream multistream(Reader<JsonRpcRequest, JsonRpcResponse> api) {
@@ -88,7 +88,7 @@ class TestingCommons {
}
static Multistream multistream(EthereumPosRpcUpstreamMock up) {
return new EthereumPosMultiStream(Chain.ETHEREUM, [up], Caches.default(), Schedulers.parallel(), tracerMock()).tap {
return new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up], Caches.default(), Schedulers.parallel(), tracerMock()).tap {
start()
}
}
@@ -103,8 +103,8 @@ class TestingCommons {
static List<Multistream> defaultMultistreams() {
return [
multistreamWithoutUpstreams(Chain.ETHEREUM),
multistreamClassicWithoutUpstreams(Chain.ETHEREUM_CLASSIC)
multistreamWithoutUpstreams(Chain.ETHEREUM__MAINNET),
multistreamClassicWithoutUpstreams(Chain.ETHEREUM_CLASSIC__MAINNET)
]
}

View File

@@ -27,62 +27,62 @@ class CurrentMultistreamHolderSpec extends Specification {
def "add upstream"() {
setup:
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM, TestingCommons.api())
def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM__MAINNET, TestingCommons.api())
when:
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up, UpstreamChangeEvent.ChangeType.ADDED))
then:
current.getAvailable() == [Chain.ETHEREUM]
current.getUpstream(Chain.ETHEREUM).getAll()[0] == up
current.getAvailable() == [Chain.ETHEREUM__MAINNET]
current.getUpstream(Chain.ETHEREUM__MAINNET).getAll()[0] == up
}
def "add multiple upstreams"() {
setup:
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api())
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api())
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC__MAINNET, TestingCommons.api())
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM__MAINNET, TestingCommons.api())
when:
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC, up2, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED))
then:
current.getAvailable().toSet() == [Chain.ETHEREUM, Chain.ETHEREUM_CLASSIC].toSet()
current.getUpstream(Chain.ETHEREUM).getAll().toSet() == [up1, up3].toSet()
current.getUpstream(Chain.ETHEREUM_CLASSIC).getAll().toSet() == [up2].toSet()
current.getAvailable().toSet() == [Chain.ETHEREUM__MAINNET, Chain.ETHEREUM_CLASSIC__MAINNET].toSet()
current.getUpstream(Chain.ETHEREUM__MAINNET).getAll().toSet() == [up1, up3].toSet()
current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).getAll().toSet() == [up2].toSet()
}
def "remove upstream"() {
setup:
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api())
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api())
def up1_del = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api())
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC__MAINNET, TestingCommons.api())
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM__MAINNET, TestingCommons.api())
def up1_del = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api())
when:
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC, up2, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1_del, UpstreamChangeEvent.ChangeType.REMOVED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED))
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1_del, UpstreamChangeEvent.ChangeType.REMOVED))
then:
current.getAvailable().toSet() == [Chain.ETHEREUM, Chain.ETHEREUM_CLASSIC].toSet()
current.getUpstream(Chain.ETHEREUM).getAll().toSet() == [up3].toSet()
current.getUpstream(Chain.ETHEREUM_CLASSIC).getAll().toSet() == [up2].toSet()
current.getAvailable().toSet() == [Chain.ETHEREUM__MAINNET, Chain.ETHEREUM_CLASSIC__MAINNET].toSet()
current.getUpstream(Chain.ETHEREUM__MAINNET).getAll().toSet() == [up3].toSet()
current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).getAll().toSet() == [up2].toSet()
}
def "available after adding"() {
setup:
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api())
when:
def act = current.isAvailable(Chain.ETHEREUM)
def act = current.isAvailable(Chain.ETHEREUM__MAINNET)
then:
!act
when:
current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED))
act = current.isAvailable(Chain.ETHEREUM)
current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED))
act = current.isAvailable(Chain.ETHEREUM__MAINNET)
then:
act

View File

@@ -37,7 +37,7 @@ import static java.util.List.of
class FilteredApisSpec extends Specification {
def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM)
def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def "Verifies labels"() {
setup:
@@ -64,7 +64,7 @@ class FilteredApisSpec extends Specification {
new EthereumRpcUpstream(
"test",
(byte) 123,
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
new UpstreamsConfig.PartialOptions().buildOptions(),
UpstreamsConfig.UpstreamRole.PRIMARY,
ethereumTargets,
@@ -79,7 +79,7 @@ class FilteredApisSpec extends Specification {
it.setStatus(UpstreamAvailability.OK)
}
when:
def iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 0, 1, 0)
def iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 0, 1, 0)
iter.request(10)
then:
StepVerifier.create(iter)
@@ -90,7 +90,7 @@ class FilteredApisSpec extends Specification {
.verify(Duration.ofSeconds(1))
when:
iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 1, 1, 0)
iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 1, 1, 0)
iter.request(10)
then:
StepVerifier.create(iter)
@@ -101,7 +101,7 @@ class FilteredApisSpec extends Specification {
.verify(Duration.ofSeconds(1))
when:
iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 1, 2, 0)
iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 1, 2, 0)
iter.request(10)
then:
StepVerifier.create(iter)
@@ -117,7 +117,7 @@ class FilteredApisSpec extends Specification {
def "Exponential backoff"() {
setup:
def apis = new FilteredApis(Chain.ETHEREUM, [], Selector.empty, 0, 1, 0)
def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [], Selector.empty, 0, 1, 0)
expect:
wait == apis.waitDuration(n).toMillis() as Integer
where:
@@ -139,7 +139,7 @@ class FilteredApisSpec extends Specification {
@Retry
def "Backoff uses jitter"() {
setup:
def apis = new FilteredApis(Chain.ETHEREUM, [], Selector.empty, 0, 1, 20)
def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [], Selector.empty, 0, 1, 20)
when:
def act = apis.waitDuration(1).toMillis()
println act
@@ -165,7 +165,7 @@ class FilteredApisSpec extends Specification {
def up2 = TestingCommons.upstream(api2)
then:
StepVerifier.withVirtualTime({
def apis = new FilteredApis(Chain.ETHEREUM, [up1, up2], Selector.empty, 0, 4, 0)
def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [up1, up2], Selector.empty, 0, 4, 0)
apis.request(10)
return apis
})
@@ -189,7 +189,7 @@ class FilteredApisSpec extends Specification {
TestingCommons.upstream(it)
}
when:
def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty, 2, 1, 0)
def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty, 2, 1, 0)
act.request(10)
then:
StepVerifier.create(act)
@@ -208,7 +208,7 @@ class FilteredApisSpec extends Specification {
TestingCommons.upstream(it)
}
when:
def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty, 2, 1, 0)
def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty, 2, 1, 0)
act.request(3)
then:
StepVerifier.create(act)
@@ -265,7 +265,7 @@ class FilteredApisSpec extends Specification {
}
]
when:
def act = new FilteredApis(Chain.ETHEREUM,
def act = new FilteredApis(Chain.ETHEREUM__MAINNET,
[] + fallback + standard,
Selector.empty, 0, 3, 0)
act.request(10)
@@ -305,7 +305,7 @@ class FilteredApisSpec extends Specification {
}
]
when:
def act = new FilteredApis(Chain.ETHEREUM,
def act = new FilteredApis(Chain.ETHEREUM__MAINNET,
[] + fallback + standard + secondary,
Selector.empty, 0, 3, 0)
act.request(11)
@@ -342,7 +342,7 @@ class FilteredApisSpec extends Specification {
}
]
when:
def act = new FilteredApis(Chain.ETHEREUM,
def act = new FilteredApis(Chain.ETHEREUM__MAINNET,
[] + lagging + ok,
Selector.empty, 0, 2, 0)
act.request(4)
@@ -373,7 +373,7 @@ class FilteredApisSpec extends Specification {
}
]
when:
def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty)
def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty)
act.request(1)
then:
StepVerifier.create(act)
@@ -404,7 +404,7 @@ class FilteredApisSpec extends Specification {
}
]
when:
def act = new FilteredApis(Chain.ETHEREUM, ups, new Selector.LabelMatcher("node", of("test")))
def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, new Selector.LabelMatcher("node", of("test")))
act.request(1)
then:
StepVerifier.create(act)
@@ -446,7 +446,7 @@ class FilteredApisSpec extends Specification {
]
when:
def act = new FilteredApis(
Chain.ETHEREUM, ups,
Chain.ETHEREUM__MAINNET, ups,
new Selector.MultiMatcher(
of(
new Selector.HeightMatcher(100000000),
@@ -495,7 +495,7 @@ class FilteredApisSpec extends Specification {
]
when:
def act = new FilteredApis(
Chain.ETHEREUM, ups,
Chain.ETHEREUM__MAINNET, ups,
new Selector.MultiMatcher(
of(
new Selector.HeightMatcher(100000000),
@@ -539,7 +539,7 @@ class FilteredApisSpec extends Specification {
]
when:
def act = new FilteredApis(
Chain.ETHEREUM, ups,
Chain.ETHEREUM__MAINNET, ups,
new Selector.MultiMatcher(
of(
new Selector.HeightMatcher(100000000),

View File

@@ -50,9 +50,9 @@ class MultistreamSpec extends Specification {
def "Aggregates methods"() {
setup:
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"]))
def up2 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test2", "eth_test3"]))
def aggr = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"]))
def up2 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test2", "eth_test3"]))
def aggr = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up1, up2], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
when:
aggr.onUpstreamsUpdated()
def act = aggr.getMethods()
@@ -183,7 +183,7 @@ class MultistreamSpec extends Specification {
def up1 = TestingCommons.upstream("test-1", "internal")
def up2 = TestingCommons.upstream("test-2", "external")
def up3 = TestingCommons.upstream("test-3", "external")
def multistream = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2, up3], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
def multistream = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up1, up2, up3], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
expect:
multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock)
@@ -200,7 +200,7 @@ class MultistreamSpec extends Specification {
setup:
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id)
.setChainValue(Chain.ETHEREUM__MAINNET.id)
.setMethod("newHeads")
.build()
@@ -214,7 +214,7 @@ class MultistreamSpec extends Specification {
1 * getId() >> "external"
1 * getLabels() >> [UpstreamsConfig.Labels.fromMap(Collections.singletonMap("provider", "external"))]
}
def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM, [up1, up2], Caches.default())
def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM__MAINNET, [up1, up2], Caches.default())
when:
def act = multiStream.tryProxy(new Selector.LabelMatcher("provider", ["internal"]), call)
@@ -230,7 +230,7 @@ class MultistreamSpec extends Specification {
setup:
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id)
.setChainValue(Chain.ETHEREUM__MAINNET.id)
.setMethod("newHeads")
.build()
@@ -239,7 +239,7 @@ class MultistreamSpec extends Specification {
1 * getId() >> "2"
1 * getLabels() >> [UpstreamsConfig.Labels.fromMap(Collections.singletonMap("provider", "internal"))]
}
def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM, [up2], Caches.default())
def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM__MAINNET, [up2], Caches.default())
when:
def act = multiStream.tryProxy(new Selector.LabelMatcher("provider", ["internal"]), call)
@@ -250,15 +250,15 @@ class MultistreamSpec extends Specification {
def "Change ms methods based on upstream availability"() {
setup:
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2", "eth_test3"]))
def up2 = new EthereumPosRpcUpstreamMock("test2", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"]))
def ms = new EthereumPosMultiStream(Chain.ETHEREUM, new ArrayList<EthereumPosUpstream>(), Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2", "eth_test3"]))
def up2 = new EthereumPosRpcUpstreamMock("test2", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"]))
def ms = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, new ArrayList<EthereumPosUpstream>(), Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock())
when:
ms.onUpstreamChange(
new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED)
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)
)
ms.onUpstreamChange(
new UpstreamChangeEvent(Chain.ETHEREUM, up2, UpstreamChangeEvent.ChangeType.ADDED)
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED)
)
def states = ms.subscribeStateChanges()
then:

View File

@@ -7,7 +7,7 @@ class DefaultEthereumMethodsSpec extends Specification {
def "eth_chainId is available"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
when:
def act = methods.isAvailable("eth_chainId")
then:
@@ -16,7 +16,7 @@ class DefaultEthereumMethodsSpec extends Specification {
def "eth_chainId is hardcoded"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
when:
def act = methods.isHardcoded("eth_chainId")
then:
@@ -25,7 +25,7 @@ class DefaultEthereumMethodsSpec extends Specification {
def "eth_chainId is not callable"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
when:
def act = methods.isCallable("eth_chainId")
then:
@@ -37,17 +37,17 @@ class DefaultEthereumMethodsSpec extends Specification {
new String(new DefaultEthereumMethods(chain).executeHardcoded("eth_chainId")) == id
where:
chain | id
Chain.ETHEREUM | '"0x1"'
Chain.ETHEREUM_CLASSIC | '"0x3d"'
Chain.TESTNET_KOVAN | '"0x2a"'
Chain.TESTNET_GOERLI | '"0x5"'
Chain.TESTNET_RINKEBY | '"0x4"'
Chain.TESTNET_ROPSTEN | '"0x3"'
Chain.ETHEREUM__MAINNET | '"0x1"'
Chain.ETHEREUM_CLASSIC__MAINNET | '"0x3d"'
Chain.ETHEREUM__KOVAN | '"0x2a"'
Chain.ETHEREUM__GOERLI | '"0x5"'
Chain.ETHEREUM__RINKEBY | '"0x4"'
Chain.ETHEREUM__ROPSTEN | '"0x3"'
}
def "Optimism chain unsupported methods"() {
setup:
def methods = new DefaultEthereumMethods(Chain.OPTIMISM)
def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET)
when:
def acc = methods.isAvailable("eth_getAccounts")
def trans = methods.isAvailable("eth_sendTransaction")
@@ -61,18 +61,18 @@ class DefaultEthereumMethodsSpec extends Specification {
new DefaultEthereumMethods(chain).getSupportedMethods().containsAll(methods)
where:
chain | methods
Chain.POLYGON | ["bor_getAuthor",
"bor_getCurrentValidators",
"bor_getCurrentProposer",
"bor_getRootHash",
"bor_getSignersAtHash",
"eth_getRootHash"]
Chain.OPTIMISM | ["rollup_gasPrices"]
Chain.POLYGON_POS__MAINNET | ["bor_getAuthor",
"bor_getCurrentValidators",
"bor_getCurrentProposer",
"bor_getRootHash",
"bor_getSignersAtHash",
"eth_getRootHash"]
Chain.OPTIMISM__MAINNET | ["rollup_gasPrices"]
}
def "Has no filter methods by default"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
when:
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("filter") }
then:
@@ -81,7 +81,7 @@ class DefaultEthereumMethodsSpec extends Specification {
def "Has no trace methods by default"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
when:
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("trace") }
then:

View File

@@ -94,7 +94,7 @@ class ManagedCallMethodsSpec extends Specification {
def "Use custom quorum if provided"() {
setup:
def managed = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_test", "eth_foo", "eth_bar"] as Set,
[] as Set,
[] as Set,
@@ -120,7 +120,7 @@ class ManagedCallMethodsSpec extends Specification {
def "Doesn't reuse same instance"() {
def managed = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_test"] as Set,
[] as Set,
[] as Set,
@@ -145,7 +145,7 @@ class ManagedCallMethodsSpec extends Specification {
def "Test enable method group"() {
setup:
def managed = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
[] as Set,
[] as Set,
["filter"] as Set,
@@ -169,7 +169,7 @@ class ManagedCallMethodsSpec extends Specification {
def "Test enable method group minus one"() {
setup:
def managed = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
[] as Set,
["eth_newPendingTransactionFilter"] as Set,
["filter"] as Set,
@@ -193,7 +193,7 @@ class ManagedCallMethodsSpec extends Specification {
def "Test disabled group not disable enabled method"() {
setup:
def managed = new ManagedCallMethods(
new DefaultEthereumMethods(Chain.ETHEREUM),
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
["eth_newPendingTransactionFilter"] as Set,
[] as Set,
[] as Set,

View File

@@ -47,7 +47,7 @@ class ERC20BalanceSpec extends Specification {
JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"')
)
EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api)
EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api)
ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9"))
ERC20Balance query = new ERC20Balance()
@@ -73,12 +73,12 @@ class ERC20BalanceSpec extends Specification {
JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"')
)
EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api)
EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api)
ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9"))
ERC20Balance query = new ERC20Balance()
ApiSource apiSource = new FilteredApis(
Chain.ETHEREUM, [upstream], Selector.empty
Chain.ETHEREUM__MAINNET, [upstream], Selector.empty
)
when:

View File

@@ -50,7 +50,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -80,7 +80,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -118,7 +118,7 @@ class EthereumDirectReaderSpec extends Specification {
) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -154,7 +154,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -190,7 +190,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -223,7 +223,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
def caches = Mock(Caches) {
// note that the Caches needs a Height value, otherwise it's not cached
@@ -255,7 +255,7 @@ class EthereumDirectReaderSpec extends Specification {
1 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -286,7 +286,7 @@ class EthereumDirectReaderSpec extends Specification {
}
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -318,7 +318,7 @@ class EthereumDirectReaderSpec extends Specification {
}
}
def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
@@ -355,7 +355,7 @@ class EthereumDirectReaderSpec extends Specification {
3 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
def result = Mono.just(
new QuorumRpcReader.Result(
@@ -398,7 +398,7 @@ class EthereumDirectReaderSpec extends Specification {
3 * getApiSource(_) >> Stub(ApiSource)
}
def calls = Mock(Factory) {
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
def result = Mono.just(
new QuorumRpcReader.Result(
@@ -436,7 +436,7 @@ class EthereumDirectReaderSpec extends Specification {
}
}
def calls = Mock(Factory) {
4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
}
EthereumDirectReader reader = new EthereumDirectReader(
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()

View File

@@ -21,12 +21,12 @@ class EthereumLocalReaderSpec extends Specification {
def "Calls hardcoded"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(
new EthereumCachingReader(
TestingCommons.multistream(TestingCommons.api()),
Caches.default(),
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)),
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)),
TestingCommons.tracerMock()
),
methods,
@@ -41,12 +41,12 @@ class EthereumLocalReaderSpec extends Specification {
def "Returns empty if nonce set"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(
new EthereumCachingReader(
TestingCommons.multistream(TestingCommons.api()),
Caches.default(),
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)),
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)),
TestingCommons.tracerMock()
),
methods,
@@ -72,7 +72,7 @@ class EthereumLocalReaderSpec extends Specification {
1 * read(101L) >> Mono.just(TestingCommons.blockForEthereum(101L))
}
}
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(reader, methods, head, true)
when:
@@ -98,7 +98,7 @@ class EthereumLocalReaderSpec extends Specification {
1 * read(0L) >> Mono.just(TestingCommons.blockForEthereum(0L))
}
}
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(reader, methods, head, true)
when:
@@ -124,7 +124,7 @@ class EthereumLocalReaderSpec extends Specification {
1 * read(74735L) >> Mono.just(TestingCommons.blockForEthereum(74735L))
}
}
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(reader, methods, head, true)
when:
@@ -148,7 +148,7 @@ class EthereumLocalReaderSpec extends Specification {
_ * txByHashAsCont() >> new EmptyReader<>()
_ * blocksByHeightAsCont() >> new EmptyReader<>()
}
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
def router = new EthereumLocalReader(reader, methods, head, true)
when:

View File

@@ -37,7 +37,7 @@ class WsConnectionImplRealSpec extends Specification {
1,
new EthereumWsConnectionFactory(
"test",
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
"ws://localhost:${port}".toURI(),
"http://localhost:${port}".toURI(),
Schedulers.parallel()
@@ -117,7 +117,7 @@ class WsConnectionImplRealSpec extends Specification {
1,
new EthereumWsConnectionFactory(
"test",
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
"ws://localhost:${port}".toURI(),
"http://localhost:${port}".toURI(),
Schedulers.parallel()

View File

@@ -38,7 +38,7 @@ class WsConnectionImplSpec extends Specification {
1,
new EthereumWsConnectionFactory(
"test",
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
new URI("http://localhost"),
new URI("http://localhost"),
Schedulers.parallel()
@@ -73,7 +73,7 @@ class WsConnectionImplSpec extends Specification {
1,
new EthereumWsConnectionFactory(
"test",
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
new URI("http://localhost"),
new URI("http://localhost"),
Schedulers.parallel()
@@ -106,7 +106,7 @@ class WsConnectionImplSpec extends Specification {
1,
new EthereumWsConnectionFactory(
"test",
Chain.ETHEREUM,
Chain.ETHEREUM__MAINNET,
new URI("http://localhost"),
new URI("http://localhost"),
Schedulers.parallel()

View File

@@ -67,7 +67,7 @@ class DshacklePendingTxesSourceSpec extends Specification {
.build()
def remote = ReactorBlockchainGrpc.newReactorStub(channel)
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, remote)
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, remote)
when:
pending.available = true
@@ -76,7 +76,7 @@ class DshacklePendingTxesSourceSpec extends Specification {
then:
receivedRequest != null
receivedRequest.chainValue == Chain.ETHEREUM.id
receivedRequest.chainValue == Chain.ETHEREUM__MAINNET.id
receivedRequest.method == "newPendingTransactions"
txes.collect {it.toHex() } == [
"0xa61bab14fc9720ea8725622688c2f964666d7c2afdae38af7dad53f12f242d5c",
@@ -87,7 +87,7 @@ class DshacklePendingTxesSourceSpec extends Specification {
def "available when method is enabled on remote"() {
setup:
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, ReactorBlockchainGrpc.newReactorStub(Stub(Channel)))
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, ReactorBlockchainGrpc.newReactorStub(Stub(Channel)))
pending.available = false
when:
pending.update(
@@ -101,7 +101,7 @@ class DshacklePendingTxesSourceSpec extends Specification {
def "unavailable when not method is enabled on remote"() {
setup:
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, ReactorBlockchainGrpc.newReactorStub(Stub(Channel)))
def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, ReactorBlockchainGrpc.newReactorStub(Stub(Channel)))
pending.available = false
when:
pending.update(

View File

@@ -61,7 +61,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
def "Subscribe to head"() {
setup:
def callData = [:]
def chain = Chain.ETHEREUM
def chain = Chain.ETHEREUM__MAINNET
def api = TestingCommons.api()
def block1 = new BlockJson().with {
it.number = 650246
@@ -106,7 +106,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
new Thread({ Thread.sleep(50); upstream.head.start() }).start()
def h = upstream.head.getFlux().next().block(Duration.ofSeconds(1))
then:
callData.chain == Chain.ETHEREUM.id
callData.chain == Chain.ETHEREUM__MAINNET.id
upstream.status == UpstreamAvailability.OK
upstream.getBuildInfo() == buildInfo
h.hash == BlockId.from("0x50d26e119968e791970d84a7bf5d0ec474d3ec2ef85d5ec8915210ac6bc09ad7")
@@ -162,7 +162,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
}).start()
}
})
def upstream = new EthereumGrpcUpstream("test", hash, UpstreamsConfig.UpstreamRole.PRIMARY, Chain.ETHEREUM, client, new JsonRpcGrpcClient(client, Chain.ETHEREUM, metrics), null, ChainsConfig.ChainConfig.default(), Schedulers.parallel())
def upstream = new EthereumGrpcUpstream("test", hash, UpstreamsConfig.UpstreamRole.PRIMARY, Chain.ETHEREUM__MAINNET, client, new JsonRpcGrpcClient(client, Chain.ETHEREUM__MAINNET, metrics), null, ChainsConfig.ChainConfig.default(), Schedulers.parallel())
upstream.setLag(0)
upstream.update(
BlockchainOuterClass.DescribeChain.newBuilder()
@@ -187,7 +187,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
setup:
def callData = [:]
def finished = new CompletableFuture<Boolean>()
def chain = Chain.ETHEREUM
def chain = Chain.ETHEREUM__MAINNET
def api = TestingCommons.api()
def block1 = new BlockJson().with {
it.number = 650246
@@ -258,7 +258,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
def "Send update status if methods were changed"() {
setup:
def chain = Chain.ETHEREUM
def chain = Chain.ETHEREUM__MAINNET
def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() {
@Override
void nativeCall(BlockchainOuterClass.NativeCallRequest request, StreamObserver<BlockchainOuterClass.NativeCallReplyItem> responseObserver) {

View File

@@ -39,7 +39,7 @@ class GrpcHeadSpec extends Specification {
def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() {
@Override
void subscribeHead(Common.Chain request, StreamObserver<BlockchainOuterClass.ChainHead> responseObserver) {
if (request.type.number != Chain.BITCOIN.id) {
if (request.type.number != Chain.BITCOIN__MAINNET.id) {
responseObserver.onError(new IllegalStateException("Unsupported chain"))
return
}
@@ -64,7 +64,7 @@ class GrpcHeadSpec extends Specification {
}
def head = new GrpcHead(
"test",
Chain.BITCOIN,
Chain.BITCOIN__MAINNET,
Stub(DefaultUpstream),
client,
convert,
@@ -92,7 +92,7 @@ class GrpcHeadSpec extends Specification {
def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() {
@Override
void subscribeHead(Common.Chain request, StreamObserver<BlockchainOuterClass.ChainHead> responseObserver) {
if (request.type.number != Chain.BITCOIN.id) {
if (request.type.number != Chain.BITCOIN__MAINNET.id) {
responseObserver.onError(new IllegalStateException("Unsupported chain"))
return
}
@@ -131,7 +131,7 @@ class GrpcHeadSpec extends Specification {
}
def head = new GrpcHead(
"test",
Chain.BITCOIN,
Chain.BITCOIN__MAINNET,
Stub(DefaultUpstream),
client,
convert,

View File

@@ -34,7 +34,7 @@ class JsonRpcGrpcClientSpec extends Specification {
}
})
def client = new JsonRpcGrpcClient(
grpc, Chain.BITCOIN, null
grpc, Chain.BITCOIN__MAINNET, null
).getReader()
when:
@@ -47,7 +47,7 @@ class JsonRpcGrpcClientSpec extends Specification {
act.resultAsProcessedString == "hello world!"
requested.get() == BlockchainOuterClass.NativeCallRequest.newBuilder()
.setChain(Common.ChainRef.CHAIN_BITCOIN)
.setChain(Common.ChainRef.CHAIN_BITCOIN__MAINNET)
.addAllItems([
BlockchainOuterClass.NativeCallItem.newBuilder()
.setId(1)
@@ -68,7 +68,7 @@ class JsonRpcGrpcClientSpec extends Specification {
}
})
def client = new JsonRpcGrpcClient(
grpc, Chain.BITCOIN, null
grpc, Chain.BITCOIN__MAINNET, null
).getReader()
when:

View File

@@ -71,7 +71,7 @@ class IntegrationTest {
fun test() {
val result = stub.describe(BlockchainOuterClass.DescribeRequest.newBuilder().build())
Assertions.assertThat(result.chainsCount).isEqualTo(1)
Assertions.assertThat(result.chainsList[0].chain).isEqualTo(ChainRef.CHAIN_ETHEREUM)
Assertions.assertThat(result.chainsList[0].chain).isEqualTo(ChainRef.CHAIN_ETHEREUM__MAINNET)
Assertions.assertThat(result.chainsList[0].nodesCount).isEqualTo(1)
}

View File

@@ -10,18 +10,18 @@ internal class ChainsConfigTest {
fun patch() {
val orig = ChainsConfig(
mapOf(
Chain.BITCOIN to createRawChainConfig(0, 0),
Chain.ETHEREUM to createRawChainConfig(1, 2),
Chain.POLYGON to createRawChainConfig(3, 4)
Chain.BITCOIN__MAINNET to createRawChainConfig(0, 0),
Chain.ETHEREUM__MAINNET to createRawChainConfig(1, 2),
Chain.POLYGON_POS__MAINNET to createRawChainConfig(3, 4)
),
createRawChainConfig(1, 2)
)
val patch = ChainsConfig(
mapOf(
Chain.BITCOIN to createRawChainConfig(null, 10000),
Chain.POLYGON to createRawChainConfig(10, 11),
Chain.ARBITRUM to createRawChainConfig(999, 999)
Chain.BITCOIN__MAINNET to createRawChainConfig(null, 10000),
Chain.POLYGON_POS__MAINNET to createRawChainConfig(10, 11),
Chain.ARBITRUM__MAINNET to createRawChainConfig(999, 999)
),
createRawChainConfig(100, null)
)
@@ -31,10 +31,10 @@ internal class ChainsConfigTest {
assertEquals(
ChainsConfig(
mapOf(
Chain.BITCOIN to createRawChainConfig(0, 10000),
Chain.ETHEREUM to createRawChainConfig(1, 2),
Chain.POLYGON to createRawChainConfig(10, 11),
Chain.ARBITRUM to createRawChainConfig(999, 999)
Chain.BITCOIN__MAINNET to createRawChainConfig(0, 10000),
Chain.ETHEREUM__MAINNET to createRawChainConfig(1, 2),
Chain.POLYGON_POS__MAINNET to createRawChainConfig(10, 11),
Chain.ARBITRUM__MAINNET to createRawChainConfig(999, 999)
),
createRawChainConfig(100, 2)
),