= Dshackle Integration Testing

Test for a correct work using a simulation of different upstream behaviours and checking the Dshackle against it.

.Modules:
- `dshackle` - Dshackle config used for testing environment
- `simple-upstream` - upstream simulator with predefines responses
- `trial` - actual tests

== How to run

NOTE: Run commands in project's root dir

NOTE: You need to open multiple consoles, since each command runs on foreground

== Basic Test

Makes some basic checks with a mocked upstreams

=== Run upstream emulator

.Runs two instances of RPC server
[source,bash]
----
DSHACKLE_TESTUP_PORT=18545 ./gradlew -p testing/simple-upstream run
DSHACKLE_TESTUP_PORT=18546 ./gradlew -p testing/simple-upstream run
----

=== Run Dshackle

[source,bash]
----
./gradlew run --args="--configPath=./testing/dshackle/dshackle-basic.yaml"
----

=== Run tests

[source,bash]
----
./testing/trial/gradlew -p testing/trial -PdshackleTrialMode=basic cleanTest test
----

== Real (Mainnet) Test

=== Run Dshackle

First you have to provide configuration to an upstream connected to the mainnet.
It may be a local Geth instance, or an other provider, like Infura (note that the test config doesn't support TLS or other auth)

[source,bash]
----
export DSHACKLE_TEST_ETH1_RPC=
export DSHACKLE_TEST_ETH1_WS=
export DSHACKLE_TEST_ETH1_WSORIGIN=
----

For a local Geth it would be:

[source,bash]
----
export DSHACKLE_TEST_ETH1_RPC=http://127.0.0.1:8545
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:

[source,bash]
----
./gradlew run --args="--configPath=./testing/dshackle/dshackle-real.yaml"
----

=== Run tests

[source,bash]
----
./testing/trial/gradlew -p testing/trial -PdshackleTrialMode=real cleanTest test
----


