diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-04-15 17:36:27 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-15 18:42:26 +0800 |
commit | 7221cb1434eebce879a0bd1bf3867cd8a24bcc99 (patch) | |
tree | 364dc21a521f89da13c69990238e13afeda3e6c1 /les/odr_test.go | |
parent | 6b0ddd141e2e12bb09b33e14e67aed4d5a68d66c (diff) | |
download | go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar.gz go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar.bz2 go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar.lz go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar.xz go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.tar.zst go-tangerine-7221cb1434eebce879a0bd1bf3867cd8a24bcc99.zip |
core, eth, les, light: scope receipt functionality a bit cleaner
Diffstat (limited to 'les/odr_test.go')
-rw-r--r-- | les/odr_test.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/les/odr_test.go b/les/odr_test.go index bc587a183..2cc28e384 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -60,7 +60,7 @@ func odrGetReceipts(ctx context.Context, db ethdb.Database, config *params.Chain var receipts types.Receipts if bc != nil { if number := rawdb.ReadHeaderNumber(db, bhash); number != nil { - receipts = rawdb.ReadReceipts(db, bhash, *number) + receipts = rawdb.ReadReceipts(db, bhash, *number, config) } } else { if number := rawdb.ReadHeaderNumber(db, bhash); number != nil { @@ -159,6 +159,9 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { client.pm.synchronise(client.rPeer) test := func(expFail uint64) { + // Mark this as a helper to put the failures at the correct lines + t.Helper() + for i := uint64(0); i <= server.pm.blockchain.CurrentHeader().Number.Uint64(); i++ { bhash := rawdb.ReadCanonicalHash(server.db, i) b1 := fn(light.NoOdr, server.db, server.pm.chainConfig, server.pm.blockchain.(*core.BlockChain), nil, bhash) @@ -170,10 +173,10 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { eq := bytes.Equal(b1, b2) exp := i < expFail if exp && !eq { - t.Errorf("odr mismatch") + t.Fatalf("odr mismatch: have %x, want %x", b2, b1) } if !exp && eq { - t.Errorf("unexpected odr match") + t.Fatalf("unexpected odr match") } } } @@ -182,6 +185,7 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { client.peers.Unregister(client.rPeer.id) time.Sleep(time.Millisecond * 10) // ensure that all peerSetNotify callbacks are executed test(expFail) + // expect all retrievals to pass client.peers.Register(client.rPeer) time.Sleep(time.Millisecond * 10) // ensure that all peerSetNotify callbacks are executed @@ -189,6 +193,7 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { client.rPeer.hasBlock = func(common.Hash, uint64, bool) bool { return true } client.peers.lock.Unlock() test(5) + // still expect all retrievals to pass, now data should be cached locally client.peers.Unregister(client.rPeer.id) time.Sleep(time.Millisecond * 10) // ensure that all peerSetNotify callbacks are executed |