Skip to content

Commit 9287ce5

Browse files
committed
run TestConfig without -race
1 parent acc4642 commit 9287ce5

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

.github/workflows/seth-test.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,61 @@ jobs:
1212
- regex: TestSmoke
1313
network-type: Geth
1414
url: "ws://localhost:8546"
15+
extra_flags: "-race"
1516
- regex: TestSmoke
1617
network-type: Anvil
1718
url: "http://localhost:8545"
19+
extra_flags: "-race"
1820
- regex: TestAPI
1921
network-type: Geth
2022
url: "ws://localhost:8546"
23+
extra_flags: "-race"
2124
- regex: TestAPI
2225
network-type: Anvil
2326
url: "http://localhost:8545"
27+
extra_flags: "-race"
2428
- regex: TestTrace
2529
network-type: Geth
2630
url: "ws://localhost:8546"
31+
extra_flags: "-race"
2732
- regex: TestTrace
2833
network-type: Anvil
2934
url: "http://localhost:8545"
35+
extra_flags: "-race"
3036
- regex: TestCLI
3137
network-type: Geth
3238
url: "ws://localhost:8546"
39+
extra_flags: "-race"
3340
- regex: TestCLI
3441
network-type: Anvil
3542
url: "http://localhost:8545"
43+
extra_flags: "-race"
3644
# TODO: wasn't stable before, fix if possible
3745
# - regex: TestGasBumping
3846
# network-type: Geth
3947
# url: "ws://localhost:8546"
4048
# - regex: TestGasBumping
4149
# network-type: Anvil
4250
# url: "http://localhost:8545"
43-
- regex: "'TestContractMap|TestGasEstimator|TestRPCHealthCheck|TestUtil|TestContract|TestConfig'"
51+
# Some test config tests use Simualted Backend, which is not has data races...
52+
- regex: "'TestConfig'"
4453
network-type: Geth
4554
url: "ws://localhost:8546"
55+
extra_flags: "''"
4656
# TODO: still expects Geth WS URL for some reason
47-
# - regex: "'TestContractMap|TestGasEstimator|TestRPCHealthCheck|TestUtil|TestContract|TestConfig'"
48-
# network-type: Anvil
49-
# url: "http://localhost:8545"
57+
- regex: "'TestConfig'"
58+
network-type: Anvil
59+
url: "http://localhost:8545"
60+
extra_flags: "''"
61+
- regex: "'TestContractMap|TestGasEstimator|TestRPCHealthCheck|TestUtil|TestContract'"
62+
network-type: Geth
63+
url: "ws://localhost:8546"
64+
extra_flags: "-race"
65+
# TODO: still expects Geth WS URL for some reason
66+
- regex: "'TestContractMap|TestGasEstimator|TestRPCHealthCheck|TestUtil|TestContract'"
67+
network-type: Anvil
68+
url: "http://localhost:8545"
69+
extra_flags: "-race"
5070
defaults:
5171
run:
5272
working-directory: seth
@@ -86,4 +106,4 @@ jobs:
86106
just-version: '1.39.0'
87107
- name: Run tests
88108
run: |
89-
devbox run -- just seth-test ${{ matrix.test.network-type }} ${{ matrix.test.url }} ${{ matrix.test.regex }}
109+
devbox run -- just seth-test ${{ matrix.test.network-type }} ${{ matrix.test.url }} ${{ matrix.test.regex }} ${{ matrix.test.extra_flags}}

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ seth-Geth:
120120
geth --graphql --http --http.api admin,debug,web3,eth,txpool,personal,miner,net --http.corsdomain "*" --ws --ws.api admin,debug,web3,eth,txpool,personal,miner,net --ws.origins "*" --mine --miner.etherbase 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --unlock f39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --allow-insecure-unlock --datadir ./geth_data --password geth_data/password.txt --nodiscover --vmdebug --networkid 1337 > /dev/null 2>&1 &
121121

122122
# Seth: run Seth tests, example: just seth-test Anvil http://localhost:8545 "TestAPI"
123-
seth-test network url test_regex:
123+
seth-test network url test_regex extra_flags:
124124
@just seth-{{network}}
125-
cd seth && SETH_URL={{url}} SETH_NETWORK={{network}} SETH_ROOT_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 go test -v -race `go list ./... | grep -v examples` -run "{{test_regex}}" || pkill -f {{network}}
125+
cd seth && SETH_URL={{url}} SETH_NETWORK={{network}} SETH_ROOT_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 go test -v "{{extra_flags}}" `go list ./... | grep -v examples` -run "{{test_regex}}" || pkill -f {{network}}
126126

127127
# Run pre-commit hooks, build, lint, tidy, check typos
128128
pre-commit:

seth/client_builder_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/ecdsa"
55
"math/big"
66
"os"
7+
"strings"
78
"testing"
89
"time"
910

@@ -47,8 +48,9 @@ func getRpc() (string, error) {
4748
if os.Getenv("SETH_NETWORK") == "" {
4849
return "", errors.New("SETH_NETWORK is not set")
4950
}
51+
5052
url := "ws://localhost:8546"
51-
if os.Getenv("SETH_NETWORK") == "anvil" {
53+
if strings.EqualFold(os.Getenv("SETH_NETWORK"), "anvil") {
5254
url = "ws://localhost:8545"
5355
}
5456

@@ -131,6 +133,9 @@ func TestConfig_MaximalBuilder(t *testing.T) {
131133
}
132134

133135
func TestConfig_ModifyExistingConfigWithBuilder(t *testing.T) {
136+
if strings.EqualFold(os.Getenv("SETH_NETWORK"), "anvil") {
137+
t.Skip("skipping test in anvil network")
138+
}
134139
configPath := os.Getenv(seth.CONFIG_FILE_ENV_VAR)
135140
require.NotEmpty(t, configPath, "expected config file path to be set")
136141

@@ -295,10 +300,13 @@ func TestConfig_NoPrivateKeys_RpcHealthEnabled(t *testing.T) {
295300
func TestConfig_NoPrivateKeys_PendingNonce(t *testing.T) {
296301
builder := seth.NewClientBuilder()
297302

298-
_, err := builder.
303+
url, err := getRpc()
304+
require.NoError(t, err, "failed to get rpc url")
305+
306+
_, err = builder.
299307
// network
300308
WithNetworkName("my network").
301-
WithRpcUrl("ws://localhost:8546").
309+
WithRpcUrl(url).
302310
// Gas price and estimations
303311
WithEIP1559DynamicFees(true).
304312
WithDynamicGasPrices(120_000_000_000, 44_000_000_000).
@@ -384,7 +392,7 @@ func TestConfig_NoPrivateKeys_Tracing(t *testing.T) {
384392
require.NoError(t, err, "failed to the client")
385393
require.Equal(t, 0, len(client.PrivateKeys), "expected 0 private keys")
386394

387-
ethClient, err := ethclient.Dial("ws://localhost:8546")
395+
ethClient, err := ethclient.Dial(url)
388396
require.NoError(t, err, "failed to dial eth client")
389397

390398
pk, err := crypto.HexToECDSA("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")

0 commit comments

Comments
 (0)