github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/docker/test_env/geth2_test.go (about)

     1  package test_env
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/ethereum/go-ethereum/common"
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/smartcontractkit/chainlink-testing-framework/libs/blockchain"
    11  	"github.com/smartcontractkit/chainlink-testing-framework/libs/logging"
    12  	"github.com/smartcontractkit/chainlink-testing-framework/libs/utils/testcontext"
    13  )
    14  
    15  func TestEth2WithPrysmAndGeth(t *testing.T) {
    16  	l := logging.GetTestLogger(t)
    17  
    18  	builder := NewEthereumNetworkBuilder()
    19  	cfg, err := builder.
    20  		WithConsensusType(ConsensusType_PoS).
    21  		WithConsensusLayer(ConsensusLayer_Prysm).
    22  		WithExecutionLayer(ExecutionLayer_Geth).
    23  		Build()
    24  	require.NoError(t, err, "Builder validation failed")
    25  
    26  	_, eth2, err := cfg.Start()
    27  	require.NoError(t, err, "Couldn't start PoS network")
    28  
    29  	nonEip1559Network := blockchain.SimulatedEVMNetwork
    30  	nonEip1559Network.Name = "Simulated Geth + Prysm (non-EIP 1559)"
    31  	nonEip1559Network.URLs = eth2.PublicWsUrls()
    32  	clientOne, err := blockchain.ConnectEVMClient(nonEip1559Network, l)
    33  	require.NoError(t, err, "Couldn't connect to the evm client")
    34  
    35  	t.Cleanup(func() {
    36  		err = clientOne.Close()
    37  		require.NoError(t, err, "Couldn't close the client")
    38  	})
    39  
    40  	ctx := testcontext.Get(t)
    41  	address := common.HexToAddress("0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1")
    42  	err = sendAndCompareBalances(ctx, clientOne, address)
    43  	require.NoError(t, err, fmt.Sprintf("balance wasn't correctly updated when %s network", nonEip1559Network.Name))
    44  
    45  	eip1559Network := blockchain.SimulatedEVMNetwork
    46  	eip1559Network.Name = "Simulated Geth + Prysm (EIP 1559)"
    47  	eip1559Network.SupportsEIP1559 = true
    48  	eip1559Network.URLs = eth2.PublicWsUrls()
    49  	clientTwo, err := blockchain.ConnectEVMClient(eip1559Network, l)
    50  	require.NoError(t, err, "Couldn't connect to the evm client")
    51  
    52  	t.Cleanup(func() {
    53  		err = clientTwo.Close()
    54  		require.NoError(t, err, "Couldn't close the client")
    55  	})
    56  
    57  	err = sendAndCompareBalances(ctx, clientTwo, address)
    58  	require.NoError(t, err, fmt.Sprintf("balance wasn't correctly updated when %s network", eip1559Network.Name))
    59  }