erigon-pulse/cmd/rpcdaemon/commands/otterscan_search_test.go
Willian Mitsuda 11f4978ed4
Upstream all Otterscan patches to devel (#5945)
Following our previous discussion on erigon's discord, this PR requests
to upstream all Otterscan modifications to erigon's repo.

That decision comes after getting feedback from lots of users at events
this year, and although it may introduce some friction for development,
it will make integrators life easier by having all our modifications
available out of box, e.g., dappnode users will get our RPCs since their
official packages are built from erigon repo.

I'm submitting the source-code as-is, please let me know if you think
there is a better code organization.

The current set of modifications comprises only new RPCs. There are some
proposals for extra-stages that would add new tables, but they are still
WIP and will be submitted separately in future after more testing.
2022-11-03 11:32:15 +07:00

32 lines
684 B
Go

package commands
import (
"testing"
"github.com/RoaringBitmap/roaring/roaring64"
)
func createBitmap(t *testing.T, blocks []uint64) []byte {
bm := roaring64.NewBitmap()
bm.AddMany(blocks)
chunk, err := bm.ToBytes()
if err != nil {
t.Fatal(err)
}
return chunk
}
func checkNext(t *testing.T, blockProvider BlockProvider, expectedBlock uint64, expectedHasNext bool) {
bl, hasNext, err := blockProvider()
if err != nil {
t.Fatal(err)
}
if bl != expectedBlock {
t.Fatalf("Expected block %d, received %d", expectedBlock, bl)
}
if expectedHasNext != hasNext {
t.Fatalf("Expected hasNext=%t, received=%t; at block=%d", expectedHasNext, hasNext, expectedBlock)
}
}