diff --git a/pkg/chain/ethereum/ethereum_integration_test.go b/pkg/chain/ethereum/ethereum_integration_test.go index 319a84016f..35db5ad8aa 100644 --- a/pkg/chain/ethereum/ethereum_integration_test.go +++ b/pkg/chain/ethereum/ethereum_integration_test.go @@ -5,6 +5,7 @@ package ethereum import ( "fmt" + "os" "reflect" "testing" "time" @@ -17,9 +18,26 @@ import ( // TODO: Include integration test in the CI. // To run the tests execute `go test -v -tags=integration ./...` -const ethereumURL = "https://mainnet.infura.io/v3/f41c6e3d505d44c182a5e5adefdaa43f" +// ethereumURLEnvVar is the name of the env variable holding the Ethereum +// mainnet JSON-RPC endpoint used by this integration test. The test asserts +// against well-known historical block numbers on mainnet, so the URL MUST +// point to mainnet (not a testnet) or assertions will silently fail. +// +// The previous hardcoded Infura URL was checked into the repository and +// must be treated as compromised; rotate the key on the provider side and +// inject the new URL via this env variable (matches the existing org +// secret name). +const ethereumURLEnvVar = "ETHEREUM_MAINNET_RPC_URL" func TestBaseChain_GetBlockNumberByTimestamp(t *testing.T) { + ethereumURL := os.Getenv(ethereumURLEnvVar) + if ethereumURL == "" { + t.Skipf( + "skipping: env variable [%s] with Ethereum mainnet JSON-RPC URL is not set", + ethereumURLEnvVar, + ) + } + client, err := ethclient.Dial(ethereumURL) if err != nil { t.Fatal(err)