aboutsummaryrefslogtreecommitdiffstats
path: root/light/odr_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'light/odr_test.go')
-rw-r--r--light/odr_test.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/light/odr_test.go b/light/odr_test.go
index d3f9374fd..cc7475df3 100644
--- a/light/odr_test.go
+++ b/light/odr_test.go
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -70,9 +71,15 @@ func (odr *testOdr) Retrieve(ctx context.Context, req OdrRequest) error {
}
switch req := req.(type) {
case *BlockRequest:
- req.Rlp = core.GetBodyRLP(odr.sdb, req.Hash, core.GetBlockNumber(odr.sdb, req.Hash))
+ number := rawdb.ReadHeaderNumber(odr.sdb, req.Hash)
+ if number != nil {
+ req.Rlp = rawdb.ReadBodyRLP(odr.sdb, req.Hash, *number)
+ }
case *ReceiptsRequest:
- req.Receipts = core.GetBlockReceipts(odr.sdb, req.Hash, core.GetBlockNumber(odr.sdb, req.Hash))
+ number := rawdb.ReadHeaderNumber(odr.sdb, req.Hash)
+ if number != nil {
+ req.Receipts = rawdb.ReadReceipts(odr.sdb, req.Hash, *number)
+ }
case *TrieRequest:
t, _ := trie.New(req.Id.Root, trie.NewDatabase(odr.sdb))
nodes := NewNodeSet()
@@ -108,9 +115,15 @@ func TestOdrGetReceiptsLes1(t *testing.T) { testChainOdr(t, 1, odrGetReceipts) }
func odrGetReceipts(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc *LightChain, bhash common.Hash) ([]byte, error) {
var receipts types.Receipts
if bc != nil {
- receipts = core.GetBlockReceipts(db, bhash, core.GetBlockNumber(db, bhash))
+ number := rawdb.ReadHeaderNumber(db, bhash)
+ if number != nil {
+ receipts = rawdb.ReadReceipts(db, bhash, *number)
+ }
} else {
- receipts, _ = GetBlockReceipts(ctx, lc.Odr(), bhash, core.GetBlockNumber(db, bhash))
+ number := rawdb.ReadHeaderNumber(db, bhash)
+ if number != nil {
+ receipts, _ = GetBlockReceipts(ctx, lc.Odr(), bhash, *number)
+ }
}
if receipts == nil {
return nil, nil
@@ -260,7 +273,7 @@ func testChainOdr(t *testing.T, protocol int, fn odrTestFn) {
test := func(expFail int) {
for i := uint64(0); i <= blockchain.CurrentHeader().Number.Uint64(); i++ {
- bhash := core.GetCanonicalHash(sdb, i)
+ bhash := rawdb.ReadCanonicalHash(sdb, i)
b1, err := fn(NoOdr, sdb, blockchain, nil, bhash)
if err != nil {
t.Fatalf("error in full-node test for block %d: %v", i, err)