Skip to content

Commit 8609e35

Browse files
author
Ilan
committed
Refactor tests
1 parent 102b08c commit 8609e35

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

framework/components/blockchain/blockchain_test.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/stretchr/testify/require"
1212
)
1313

14+
<<<<<<< Updated upstream
1415
func TestAnvil(t *testing.T) {
1516
anvilOut, err := NewBlockchainNetwork(&Input{
1617
Type: "anvil",
@@ -19,20 +20,43 @@ func TestAnvil(t *testing.T) {
1920
ChainID: "31337",
2021
})
2122
require.NoError(t, err)
23+
=======
24+
func TestChains(t *testing.T) {
25+
testCases := []struct {
26+
name string
27+
input *Input
28+
chainId int64
29+
}{
30+
{
31+
name: "Anvil",
32+
input: &Input{
33+
Type: "anvil",
34+
Image: "f4hrenh9it/foundry",
35+
Port: "8545",
36+
},
37+
chainId: 31337,
38+
},
39+
{
40+
name: "AnvilZksync",
41+
input: &Input{
42+
Type: "anvil-zksync",
43+
},
44+
chainId: 260,
45+
},
46+
}
47+
>>>>>>> Stashed changes
2248

23-
testChain(t, 1337, anvilOut)
49+
for _, tc := range testCases {
50+
t.Run(tc.name, func(t *testing.T) {
51+
testChain(t, tc.chainId, tc.input)
52+
})
53+
}
2454
}
2555

26-
func TestAnvilZksync(t *testing.T) {
27-
anvilOut, err := NewBlockchainNetwork(&Input{
28-
Type: "anvil-zksync",
29-
})
56+
func testChain(t *testing.T, chainId int64, input *Input) {
57+
input.ChainID = strconv.FormatInt(chainId, 10)
58+
output, err := NewBlockchainNetwork(input)
3059
require.NoError(t, err)
31-
32-
testChain(t, 260, anvilOut)
33-
}
34-
35-
func testChain(t *testing.T, chainId int64, output *Output) {
3660
rpcUrl := output.Nodes[0].HostHTTPUrl
3761

3862
reqBody := `{"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}`

0 commit comments

Comments
 (0)