Skip to content

Commit

Permalink
use random address for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ogtownsend committed Oct 10, 2024
1 parent 226fe74 commit 6ab6540
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/chains/evm/gas/rollups/op_l1_oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups/mocks"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
)

func TestOPL1Oracle_ReadV1GasPrice(t *testing.T) {
Expand Down Expand Up @@ -217,15 +218,15 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) {
baseFeeScalar := big.NewInt(10)
blobBaseFeeScalar := big.NewInt(5)
decimals := big.NewInt(6)
oracleAddress := common.HexToAddress("0x1234").String()
oracleAddress := utils.RandomAddress().String()

t.Parallel()

t.Run("correctly fetches weighted gas price if chain has upgraded to Ecotone", func(t *testing.T) {
ethClient := setupUpgradeCheck(t, oracleAddress, false, true)
mockBatchContractCall(t, ethClient, oracleAddress, baseFee, baseFeeScalar, blobBaseFee, blobBaseFeeScalar, decimals)

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
gasPrice, err := oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -245,7 +246,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) {
rpcElements[1].Result = &badData
}).Return(nil).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -256,7 +257,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) {
ethClient := setupUpgradeCheck(t, oracleAddress, false, true)
ethClient.On("BatchCallContext", mock.Anything, mock.IsType([]rpc.BatchElem{})).Return(fmt.Errorf("revert")).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -272,7 +273,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) {
rpcElements[1].Error = fmt.Errorf("revert")
}).Return(nil).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -286,15 +287,15 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) {
baseFeeScalar := big.NewInt(10)
blobBaseFeeScalar := big.NewInt(5)
decimals := big.NewInt(6)
oracleAddress := common.HexToAddress("0x1234").String()
oracleAddress := utils.RandomAddress().String()

t.Parallel()

t.Run("correctly fetches gas price if chain has upgraded to Fjord", func(t *testing.T) {
ethClient := setupUpgradeCheck(t, oracleAddress, true, true)
mockBatchContractCall(t, ethClient, oracleAddress, baseFee, baseFeeScalar, blobBaseFee, blobBaseFeeScalar, decimals)

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
gasPrice, err := oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -314,7 +315,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) {
rpcElements[1].Result = &badData
}).Return(nil).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -325,7 +326,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) {
ethClient := setupUpgradeCheck(t, oracleAddress, true, true)
ethClient.On("BatchCallContext", mock.Anything, mock.IsType([]rpc.BatchElem{})).Return(fmt.Errorf("revert")).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand All @@ -341,7 +342,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) {
rpcElements[1].Error = fmt.Errorf("revert")
}).Return(nil).Once()

daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
_, err = oracle.GetDAGasPrice(tests.Context(t))
Expand Down

0 comments on commit 6ab6540

Please sign in to comment.