From 64d667acada1220e2863ad382f346e314482d9b2 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Mon, 16 Aug 2021 22:08:56 -0400 Subject: [PATCH] solution: integration test with Rinkeby --- testing/README.adoc | 26 +++++++++++++++- testing/dshackle/dshackle-rinkeby.yaml | 26 ++++++++++++++++ .../dshackle/testing/trial/ProxyClient.groovy | 4 +++ .../trial/rinkeby/CallContractSpec.groovy | 30 +++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 testing/dshackle/dshackle-rinkeby.yaml create mode 100644 testing/trial/src/test/groovy/io/emeraldpay/dshackle/testing/trial/rinkeby/CallContractSpec.groovy diff --git a/testing/README.adoc b/testing/README.adoc index 7b4e0519..8027d983 100644 --- a/testing/README.adoc +++ b/testing/README.adoc @@ -63,7 +63,7 @@ export DSHACKLE_TEST_ETH1_WS=ws://127.0.0.1:8546 export DSHACKLE_TEST_ETH1_WSORIGIN=http://127.0.0.1:8546 ---- -Finally, run the dDshackle instance: +Finally, run the Dshackle instance: [source,bash] ---- @@ -77,4 +77,28 @@ Finally, run the dDshackle instance: ./testing/trial/gradlew -p testing/trial -PdshackleTrialMode=real cleanTest test ---- +== Real (Rinkeby) Test +Runs requests against a Rinkeby Testnet. +Configuration is similar to the Mainnet config, but instead of `ETH1` is has `RINKEBY`. + +[source,bash] +---- +export DSHACKLE_TEST_RINKEBY_RPC= +export DSHACKLE_TEST_RINKEBY_WS= +export DSHACKLE_TEST_RINKEBY_WSORIGIN= +---- + +And run the Dshackle instance: + +[source,bash] +---- +./gradlew run --args="--configPath=./testing/dshackle/dshackle-rinkeby.yaml" +---- + +=== Run tests + +[source,bash] +---- +./testing/trial/gradlew -p testing/trial -PdshackleTrialMode=rinkeby cleanTest test +---- diff --git a/testing/dshackle/dshackle-rinkeby.yaml b/testing/dshackle/dshackle-rinkeby.yaml new file mode 100644 index 00000000..e0e1d3a8 --- /dev/null +++ b/testing/dshackle/dshackle-rinkeby.yaml @@ -0,0 +1,26 @@ +version: v1 +port: 12448 + +tls: + enabled: false + +cluster: + upstreams: + - id: rinkeby-1 + chain: rinkeby + connection: + ethereum: + rpc: + url: "${DSHACKLE_TEST_RINKEBY_RPC}" + +cache: + redis: + enabled: false + +proxy: + port: 18081 + tls: + enabled: false + routes: + - id: rinkeby + blockchain: rinkeby \ No newline at end of file diff --git a/testing/trial/src/main/groovy/io/emeraldpay/dshackle/testing/trial/ProxyClient.groovy b/testing/trial/src/main/groovy/io/emeraldpay/dshackle/testing/trial/ProxyClient.groovy index 9fdda969..ae5fb595 100644 --- a/testing/trial/src/main/groovy/io/emeraldpay/dshackle/testing/trial/ProxyClient.groovy +++ b/testing/trial/src/main/groovy/io/emeraldpay/dshackle/testing/trial/ProxyClient.groovy @@ -32,6 +32,10 @@ class ProxyClient { return forPrefix(18081, "eth") } + static ProxyClient ethereumRinkeby() { + return forPrefix(18081, "rinkeby") + } + static ProxyClient forPrefix(String prefix) { return forPrefix(18080, prefix) } diff --git a/testing/trial/src/test/groovy/io/emeraldpay/dshackle/testing/trial/rinkeby/CallContractSpec.groovy b/testing/trial/src/test/groovy/io/emeraldpay/dshackle/testing/trial/rinkeby/CallContractSpec.groovy new file mode 100644 index 00000000..193f5226 --- /dev/null +++ b/testing/trial/src/test/groovy/io/emeraldpay/dshackle/testing/trial/rinkeby/CallContractSpec.groovy @@ -0,0 +1,30 @@ +package io.emeraldpay.dshackle.testing.trial.rinkeby + +import io.emeraldpay.dshackle.testing.trial.ProxyClient +import spock.lang.IgnoreIf +import spock.lang.Specification + +@IgnoreIf({ System.getProperty('trialMode') != 'rinkeby' }) +class CallContractSpec extends Specification { + + def client = ProxyClient.ethereumRinkeby() + + def "get block"() { + when: + def act = client.execute(65, "eth_call", + [ + [ + "to" : "0xB8Ba177465b3d696180742c6ba58C408175CB6Dd", + "data": "0x70a08231000000000000000000000000da3f87aa38d07f1fc836873a3b34ec23088ef78a" + ], + "0xc90f1c8c125a4d5b90742f16947bdb1d10516f173fd7fc51223d10499de2a812" + ] + ) + then: + act.id == 65 + act.result != null + act.result == "0x000000000000000000000000000000000000000000000000000000003af9a800" + act.error == null + } + +}