aboutsummaryrefslogtreecommitdiffstats
path: root/light/odr_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-05-07 19:35:06 +0800
committerGitHub <noreply@github.com>2018-05-07 19:35:06 +0800
commit6cf0ab38bd0af77d81aad4c104979cebee9e3e63 (patch)
tree142d6f965c44dcf9e2182da67b7bbc978c573448 /light/odr_test.go
parent5463ed99968bf71685a2a8ee9dbf8705912f00cb (diff)
downloaddexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.gz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.bz2
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.lz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.xz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.zst
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.zip
core/rawdb: separate raw database access to own package (#16666)
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)