Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethreceipts: check for nil in isBlockFinal #95

Merged
merged 4 commits into from
Jul 25, 2023
Merged
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
6 changes: 5 additions & 1 deletion ethreceipts/ethreceipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,11 @@ func (l *ReceiptsListener) getMaxWaitBlocks(maxWait *int) uint64 {
}

func (l *ReceiptsListener) isBlockFinal(blockNum *big.Int) bool {
diff := big.NewInt(0).Sub(l.latestBlockNum(), blockNum)
latestBlockNum := l.latestBlockNum()
if latestBlockNum == nil || blockNum == nil {
return false
}
diff := big.NewInt(0).Sub(latestBlockNum, blockNum)
return diff.Cmp(big.NewInt(int64(l.options.NumBlocksToFinality))) >= 0
}

Expand Down
10 changes: 5 additions & 5 deletions ethrpc/ethrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestERC20MintAndTransfer(t *testing.T) {
}

func TestBlockByNumber(t *testing.T) {
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test")
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
require.NoError(t, err)

{
Expand All @@ -101,7 +101,7 @@ func TestBlockByNumber(t *testing.T) {
}

// func TestBlockRange(t *testing.T) {
// p, err := ethrpc.NewProvider("https://dev-nodes.sequence.app/optimism/test")
// p, err := ethrpc.NewProvider("https://dev-nodes.sequence.app/optimism")
// require.NoError(t, err)

// {
Expand All @@ -112,7 +112,7 @@ func TestBlockByNumber(t *testing.T) {
// }

func ExampleBatchCall() {
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test")
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func ExampleBatchCall() {

func TestETHRPC(t *testing.T) {
t.Run("Single", func(t *testing.T) {
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test")
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
require.NoError(t, err)

chainID, err := p.ChainID(context.Background())
Expand All @@ -153,7 +153,7 @@ func TestETHRPC(t *testing.T) {
})

t.Run("Batch", func(t *testing.T) {
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test")
p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
require.NoError(t, err)

var (
Expand Down
Loading