1- package blockchain
1+ package simple_node_set_test
22
33import (
44 "encoding/json"
@@ -9,46 +9,50 @@ import (
99 "testing"
1010
1111 "github.com/stretchr/testify/require"
12+
13+ "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
1214)
1315
1416func TestChains (t * testing.T ) {
1517 testCases := []struct {
1618 name string
17- input * Input
19+ input * blockchain. Input
1820 chainId int64
1921 }{
2022 {
2123 name : "Anvil" ,
22- input : & Input {
23- Type : "anvil" ,
24- Image : "f4hrenh9it/foundry" ,
25- Port : "8555" ,
24+ input : & blockchain.Input {
25+ Type : "anvil" ,
26+ Image : "f4hrenh9it/foundry" ,
27+ Port : "8547" ,
28+ ChainID : "31337" ,
2629 },
27- chainId : 31337 ,
2830 },
2931 {
3032 name : "AnvilZksync" ,
31- input : & Input {
32- Type : "anvil-zksync" ,
33- Port : "8011" ,
33+ input : & blockchain.Input {
34+ Type : "anvil-zksync" ,
35+ Port : "8011" ,
36+ ChainID : "260" ,
3437 },
35- chainId : 260 ,
3638 },
3739 }
3840
3941 for _ , tc := range testCases {
4042 t .Run (tc .name , func (t * testing.T ) {
41- testChain (t , tc .chainId , tc . input )
43+ testChain (t , tc .input )
4244 })
4345 }
4446}
4547
46- func testChain (t * testing.T , chainId int64 , input * Input ) {
47- input .ChainID = strconv .FormatInt (chainId , 10 )
48- output , err := NewBlockchainNetwork (input )
48+ func testChain (t * testing.T , input * blockchain.Input ) {
49+ chainId , err := strconv .ParseInt (input .ChainID , 10 , 64 )
4950 require .NoError (t , err )
50- rpcUrl := output .Nodes [0 ].HostHTTPUrl
5151
52+ output , err := blockchain .NewBlockchainNetwork (input )
53+ require .NoError (t , err )
54+
55+ rpcUrl := output .Nodes [0 ].HostHTTPUrl
5256 reqBody := `{"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}`
5357 resp , err := http .Post (rpcUrl , "application/json" , strings .NewReader (reqBody ))
5458 require .NoError (t , err )
@@ -63,8 +67,9 @@ func testChain(t *testing.T, chainId int64, input *Input) {
6367 }
6468 err = json .Unmarshal (responseData , & respJSON )
6569 require .NoError (t , err )
70+ result := respJSON .Result
6671
67- actualChainId , err := strconv .ParseInt (strings .TrimPrefix (respJSON . Result , "0x" ), 16 , 64 )
72+ actualChainId , err := strconv .ParseInt (strings .TrimPrefix (result , "0x" ), 16 , 64 )
6873 require .NoError (t , err )
6974
7075 require .Equal (t , chainId , actualChainId )
0 commit comments