Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pkg/chain/ethereum/ethereum_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ethereum

import (
"fmt"
"os"
"reflect"
"testing"
"time"
Expand All @@ -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)
Expand Down
Loading