Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ jobs:
docker load --input /tmp/go-build-env-image.tar

- name: Run Go Integration Tests
env:
ETHEREUM_MAINNET_RPC_URL: ${{ secrets.ETHEREUM_MAINNET_RPC_URL }}
run: |
docker run \
-e ETHEREUM_MAINNET_RPC_URL \
--workdir /go/src/github.com/keep-network/keep-core \
go-build-env \
gotestsum -- -timeout 20m -tags=integration ./...
4 changes: 2 additions & 2 deletions pkg/bitcoin/electrum/electrum_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ var testConfigs = map[string]testConfig{
clientConfig: electrum.Config{
URL: "tcp://electrum.blockstream.info:60001",
RequestTimeout: requestTimeout * 2,
RequestRetryTimeout: requestRetryTimeout * 2,
RequestRetryTimeout: requestRetryTimeout * 6, // allow slower public electrum responses
},
network: bitcoin.Testnet,
},
"electrs-esplora ssl": {
clientConfig: electrum.Config{
URL: "ssl://electrum.blockstream.info:60002",
RequestTimeout: requestTimeout * 2,
RequestRetryTimeout: requestRetryTimeout * 2,
RequestRetryTimeout: requestRetryTimeout * 6, // allow slower public electrum responses
},
network: bitcoin.Testnet,
},
Expand Down
11 changes: 10 additions & 1 deletion pkg/chain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,16 @@ func (bc *baseChain) blockByNumber(number uint64) (*types.Block, error) {
ctx, cancelCtx := context.WithTimeout(context.Background(), 30*time.Second)
defer cancelCtx()

return bc.client.BlockByNumber(ctx, big.NewInt(int64(number)))
// Fetch the header to avoid decoding full transactions (some providers
// may return transaction types the client library does not support yet).
// The returned *types.Block carries only header fields; transactions and
// uncles are empty. Callers that need tx data must fetch the full block.
header, err := bc.client.HeaderByNumber(ctx, big.NewInt(int64(number)))
if err != nil {
return nil, err
}

return types.NewBlockWithHeader(header), nil
}

// headerByNumber returns the header for the given block number. Times out
Expand Down
8 changes: 6 additions & 2 deletions 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,12 @@ 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"

func TestBaseChain_GetBlockNumberByTimestamp(t *testing.T) {
ethereumURL := os.Getenv("ETHEREUM_MAINNET_RPC_URL")
if ethereumURL == "" {
t.Skip("ETHEREUM_MAINNET_RPC_URL not set; skipping mainnet integration test")
}

client, err := ethclient.Dial(ethereumURL)
if err != nil {
t.Fatal(err)
Expand Down
5 changes: 4 additions & 1 deletion pkg/tbtcpg/internal/test/marshaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"github.com/keep-network/keep-core/pkg/tbtcpg"
"math/big"
Expand Down Expand Up @@ -273,7 +274,9 @@ func (psts *ProposeSweepTestScenario) UnmarshalJSON(data []byte) error {

// Unmarshal expected error
if len(unmarshaled.ExpectedErr) > 0 {
psts.ExpectedErr = fmt.Errorf(unmarshaled.ExpectedErr)
// fmt.Errorf requires a constant format string; ExpectedErr is a
// plain string so use errors.New to avoid formatting interpretation.
psts.ExpectedErr = errors.New(unmarshaled.ExpectedErr)
}

return nil
Expand Down
Loading