aboutsummaryrefslogtreecommitdiffstats
path: root/eth/filters/filter_system_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/filters/filter_system_test.go')
-rw-r--r--eth/filters/filter_system_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go
index 1bd4d502d..48d6811c0 100644
--- a/eth/filters/filter_system_test.go
+++ b/eth/filters/filter_system_test.go
@@ -22,6 +22,8 @@ import (
"testing"
"time"
+ "golang.org/x/net/context"
+
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -38,6 +40,37 @@ var (
api = NewPublicFilterAPI(backend, false)
)
+type testBackend struct {
+ mux *event.TypeMux
+ db ethdb.Database
+}
+
+func (b *testBackend) ChainDb() ethdb.Database {
+ return b.db
+}
+
+func (b *testBackend) EventMux() *event.TypeMux {
+ return b.mux
+}
+
+func (b *testBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
+ var hash common.Hash
+ var num uint64
+ if blockNr == rpc.LatestBlockNumber {
+ hash = core.GetHeadBlockHash(b.db)
+ num = core.GetBlockNumber(b.db, hash)
+ } else {
+ num = uint64(blockNr)
+ hash = core.GetCanonicalHash(b.db, num)
+ }
+ return core.GetHeader(b.db, hash, num), nil
+}
+
+func (b *testBackend) GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) {
+ num := core.GetBlockNumber(b.db, blockHash)
+ return core.GetBlockReceipts(b.db, blockHash, num), nil
+}
+
// TestBlockSubscription tests if a block subscription returns block hashes for posted chain events.
// It creates multiple subscriptions:
// - one at the start and should receive all posted chain events and a second (blockHashes)