github.com/0xsequence/ethkit@v1.25.0/ethproviders/ethproviders_test.go (about)

     1  package ethproviders_test
     2  
     3  import (
     4  	"context"
     5  	"math/big"
     6  	"testing"
     7  
     8  	"github.com/0xsequence/ethkit/ethproviders"
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestBasic(t *testing.T) {
    13  	cfg := ethproviders.Config{
    14  		"polygon": ethproviders.NetworkConfig{
    15  			ID:  137,
    16  			URL: "https://dev-nodes.sequence.app/polygon",
    17  		},
    18  	}
    19  
    20  	ps, err := ethproviders.NewProviders(cfg) //, "xx")
    21  	require.NoError(t, err)
    22  	p := ps.Get("polygon")
    23  	require.NotNil(t, p)
    24  
    25  	block, err := p.BlockByNumber(context.Background(), big.NewInt(1_000_000))
    26  	require.NoError(t, err)
    27  	require.NotNil(t, block)
    28  	require.Equal(t, uint64(1_000_000), block.NumberU64())
    29  }