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 ./...
3 changes: 1 addition & 2 deletions config/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ func TestResolvePeers(t *testing.T) {
"sepolia network": {
network: network.Testnet,
expectedPeers: []string{
"/dns4/bootstrap-0.test.keep.network/tcp/3919/ipfs/16Uiu2HAmCcfVpHwfBKNFbQuhvGuFXHVLQ65gB4sJm7HyrcZuLttH",
"/dns4/bootstrap-1.test.keep.network/tcp/3919/ipfs/16Uiu2HAm3eJtyFKAttzJ85NLMromHuRg4yyum3CREMf6CHBBV6KY",
"/dns4/bst-a01.test.keep.boar.network/tcp/6001/ipfs/16Uiu2HAmSLDSahiKyTbCNNu8wJmZAsiKF7wuYJ8mogY8ZuAG1jhu",
"/dns4/keep-validator-0.eks-ap-northeast-2-secure.staging.staked.cloud/tcp/3919/ipfs/16Uiu2HAm77eSvRq5ioD4J8VFPkq3bJHBEHkssCuiFkgAoABwjo2S",
},
},
"developer network": {
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ replace (
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.22.3
github.com/btcsuite/btcd/v2 => github.com/btcsuite/btcd v0.23.4
github.com/checksum0/go-electrum => github.com/keep-network/go-electrum v0.0.0-20240206170935-6038cb594daa
github.com/keep-network/keep-common => github.com/threshold-network/keep-common v1.7.1-tlabs.0
// Temporary replacement until v1.28.2 is released containing `protodelim` package.
// See https://github.com/protocolbuffers/protobuf-go/commit/fb0abd915897428ccfdd6b03b48ad8219751ee54
google.golang.org/protobuf/dev => google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
Expand All @@ -38,7 +39,7 @@ require (
github.com/ipfs/go-log v1.0.5
github.com/ipfs/go-log/v2 v2.5.1
github.com/jbenet/goprocess v0.1.4
github.com/keep-network/keep-common v1.7.1-0.20240424094333-bd36cd25bb74
github.com/keep-network/keep-common v1.7.1-tlabs.0
github.com/libp2p/go-addr-util v0.2.0
github.com/libp2p/go-libp2p v0.32.2
github.com/libp2p/go-libp2p-kad-dht v0.25.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/keep-network/go-electrum v0.0.0-20240206170935-6038cb594daa h1:AKTJr+STc4rP9NcN2ppP9Zft3GbYechFW8q/S8UNQrQ=
github.com/keep-network/go-electrum v0.0.0-20240206170935-6038cb594daa/go.mod h1:eiMFzdvS+x8Voi0bmiZtVfJ3zMNRUnPNDnhCQR0tudo=
github.com/keep-network/keep-common v1.7.1-0.20240424094333-bd36cd25bb74 h1:cG2BiQJj6+v86duIAuDd6sPJZqLVWaOPxzt3nWQQaAo=
github.com/keep-network/keep-common v1.7.1-0.20240424094333-bd36cd25bb74/go.mod h1:OmaZrnZODf6RJ95yUn2kBjy8Z4u2npPJQkSiyimluto=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down Expand Up @@ -719,6 +717,8 @@ github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/threshold-network/keep-common v1.7.1-tlabs.0 h1:E3Qy3yoeA3+9Ybi08Bb1Xm1D2fFxoberQwUjw+UEK8k=
github.com/threshold-network/keep-common v1.7.1-tlabs.0/go.mod h1:OmaZrnZODf6RJ95yUn2kBjy8Z4u2npPJQkSiyimluto=
github.com/threshold-network/tss-lib v0.0.0-20230901144531-2e712689cfbe h1:dOKhoYxZjXwFIyGnxgU+Sa1obZPMHRhu6e44oOLkzU4=
github.com/threshold-network/tss-lib v0.0.0-20230901144531-2e712689cfbe/go.mod h1:o3zAAo7A88ZJnCE1qpjy1hTqPn+GPQlxRsj8soz14UU=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
Expand Down
23 changes: 21 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 Expand Up @@ -291,6 +291,8 @@ func TestGetLatestBlockHeight_Integration(t *testing.T) {

for testName, testConfig := range testConfigs {
t.Run(testName+"_get", func(t *testing.T) {
skipTestnetWSS(t, testName, testConfig)

electrum, cancelCtx := newTestConnection(t, testConfig.clientConfig)
defer cancelCtx()

Expand Down Expand Up @@ -320,6 +322,8 @@ func TestGetLatestBlockHeight_Integration(t *testing.T) {

for testName, config := range testConfigs {
t.Run(testName+"_compare", func(t *testing.T) {
skipTestnetWSS(t, testName, config)

result := results[config.network.String()][testName]
ref := expectedBlockHeightRef[config.network.String()]

Expand Down Expand Up @@ -584,13 +588,28 @@ func runParallel(t *testing.T, runFunc func(t *testing.T, testConfig testConfig)
testConfig := testConfig

t.Run(testName, func(t *testing.T) {
skipTestnetWSS(t, testName, testConfig)

t.Parallel()

runFunc(t, testConfig)
})
}
}

func skipTestnetWSS(t *testing.T, testName string, testConfig testConfig) {
if !strings.Contains(testConfig.clientConfig.URL, "electrumx-server.test.tbtc.network") &&
!strings.Contains(testName, "electrumx wss") &&
!strings.Contains(testName, "electrumx-server.test.tbtc.network") {
return
}

// TODO(3843): The test WSS endpoint is currently offline/handshake-failing
// (sslv3 alert handshake failure), so skip until a healthy host is restored
// or replaced.
t.Skip("skip electrumx wss tests: test endpoint TLS handshake fails")
}

func newTestConnection(t *testing.T, config electrum.Config) (bitcoin.Chain, context.CancelFunc) {
ctx, cancelCtx := context.WithCancel(context.Background())
electrum, err := electrum.Connect(ctx, config)
Expand Down
9 changes: 8 additions & 1 deletion pkg/chain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,14 @@ 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).
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.Fatal("ETHEREUM_MAINNET_RPC_URL not set")
}

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