Skip to content

Commit

Permalink
tests_: add docker-compose to run tests with anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
antdanchenko committed Sep 4, 2024
1 parent d52622f commit db02a14
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
17 changes: 17 additions & 0 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
anvil:
image: ghcr.io/foundry-rs/foundry:latest
platform: linux/amd64
command:
- anvil --host 0.0.0.0 --block-time 2

go-test:
image: golang:1.21.4
depends_on:
- anvil
privileged: true
volumes:
- ../:/go/src/github.com/status-im/status-go/
working_dir: /go/src/github.com/status-im/status-go/api
command: |
go test -tags gowaku_skip_migrations -run ^TestRouterFeesUpdate github.com/status-im/status-go/api/... -v -- -anvil-host=https://anvil:8545
20 changes: 17 additions & 3 deletions api/wallet_router_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func setupSignalHandler(t *testing.T) chan responses.RouterSuggestedRoutes {
}

func setupWalletWithAnvil(t *testing.T, mnemonic string, password string, rootDataDir string) (*GethStatusBackend, error) {
initAnvil()
const pathEIP1581Root = "m/43'/60'/1581'"
const pathEIP1581Chat = pathEIP1581Root + "/0'/0"
const pathWalletRoot = "m/44'/60'/0'/0"
Expand Down Expand Up @@ -132,15 +133,15 @@ func setupWalletWithAnvil(t *testing.T, mnemonic string, password string, rootDa
Enabled: true,
}
nodeConfig.UpstreamConfig = params.UpstreamRPCConfig{
URL: "http://0.0.0.0:8545",
URL: anvilHost,
Enabled: true,
}
nodeConfig.Networks = []params.Network{
params.Network{
ChainID: uint64(31337),
ChainName: "Anvil",
DefaultRPCURL: "http://0.0.0.0:8545",
RPCURL: "http://0.0.0.0:8545",
DefaultRPCURL: anvilHost,
RPCURL: anvilHost,
ShortName: "eth",
NativeCurrencyName: "Ether",
NativeCurrencySymbol: "ETH",
Expand Down Expand Up @@ -209,11 +210,24 @@ func setupWalletWithAnvil(t *testing.T, mnemonic string, password string, rootDa
return backend, nil
}

var anvilHost string


func initAnvil() {
for _, arg := range os.Args {
if strings.Contains(arg, "anvil-host") {
anvilHost = strings.Split(arg, "=")[1]
break
}
}
}

func TestRouterFeesUpdate(t *testing.T) {
const mnemonic = "test test test test test test test test test test test junk"
const password = "111111"
rootDataDir := t.TempDir()


backend, err := setupWalletWithAnvil(t, mnemonic, password, rootDataDir)
require.NoError(t, err)

Expand Down

0 comments on commit db02a14

Please sign in to comment.