github.com/0xsequence/ethkit@v1.25.0/ethutil/validate_logs_with_block_test.go (about)

     1  package ethutil
     2  
     3  import (
     4  	"context"
     5  	"math/big"
     6  	"testing"
     7  
     8  	"github.com/0xsequence/ethkit/ethrpc"
     9  	"github.com/0xsequence/ethkit/go-ethereum"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestValidateLogsWithBlockHeader(t *testing.T) {
    14  	p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
    15  	require.NoError(t, err)
    16  
    17  	header, err := p.HeaderByNumber(context.Background(), big.NewInt(20_000_003))
    18  	require.NoError(t, err)
    19  	require.NotNil(t, header)
    20  
    21  	logs, err := p.FilterLogs(context.Background(), ethereum.FilterQuery{
    22  		FromBlock: big.NewInt(20_000_003),
    23  		ToBlock:   big.NewInt(20_000_003),
    24  	})
    25  	require.NoError(t, err)
    26  
    27  	require.True(t, ValidateLogsWithBlockHeader(logs, header))
    28  }