|
|
@ -42,20 +42,17 @@ type testBackend struct { |
|
|
|
mux *event.TypeMux |
|
|
|
mux *event.TypeMux |
|
|
|
db ethdb.Database |
|
|
|
db ethdb.Database |
|
|
|
sections uint64 |
|
|
|
sections uint64 |
|
|
|
txFeed *event.Feed |
|
|
|
txFeed event.Feed |
|
|
|
rmLogsFeed *event.Feed |
|
|
|
logsFeed event.Feed |
|
|
|
logsFeed *event.Feed |
|
|
|
rmLogsFeed event.Feed |
|
|
|
chainFeed *event.Feed |
|
|
|
pendingLogsFeed event.Feed |
|
|
|
|
|
|
|
chainFeed event.Feed |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (b *testBackend) ChainDb() ethdb.Database { |
|
|
|
func (b *testBackend) ChainDb() ethdb.Database { |
|
|
|
return b.db |
|
|
|
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) { |
|
|
|
func (b *testBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
hash common.Hash |
|
|
|
hash common.Hash |
|
|
@ -116,6 +113,10 @@ func (b *testBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscript |
|
|
|
return b.logsFeed.Subscribe(ch) |
|
|
|
return b.logsFeed.Subscribe(ch) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (b *testBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription { |
|
|
|
|
|
|
|
return b.pendingLogsFeed.Subscribe(ch) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (b *testBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { |
|
|
|
func (b *testBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { |
|
|
|
return b.chainFeed.Subscribe(ch) |
|
|
|
return b.chainFeed.Subscribe(ch) |
|
|
|
} |
|
|
|
} |
|
|
@ -160,13 +161,8 @@ func TestBlockSubscription(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
genesis = new(core.Genesis).MustCommit(db) |
|
|
|
genesis = new(core.Genesis).MustCommit(db) |
|
|
|
chain, _ = core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 10, func(i int, gen *core.BlockGen) {}) |
|
|
|
chain, _ = core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 10, func(i int, gen *core.BlockGen) {}) |
|
|
@ -205,7 +201,7 @@ func TestBlockSubscription(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
for _, e := range chainEvents { |
|
|
|
for _, e := range chainEvents { |
|
|
|
chainFeed.Send(e) |
|
|
|
backend.chainFeed.Send(e) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
<-sub0.Err() |
|
|
|
<-sub0.Err() |
|
|
@ -217,13 +213,8 @@ func TestPendingTxFilter(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
|
|
|
|
|
|
|
|
transactions = []*types.Transaction{ |
|
|
|
transactions = []*types.Transaction{ |
|
|
@ -240,7 +231,7 @@ func TestPendingTxFilter(t *testing.T) { |
|
|
|
fid0 := api.NewPendingTransactionFilter() |
|
|
|
fid0 := api.NewPendingTransactionFilter() |
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
txFeed.Send(core.NewTxsEvent{Txs: transactions}) |
|
|
|
backend.txFeed.Send(core.NewTxsEvent{Txs: transactions}) |
|
|
|
|
|
|
|
|
|
|
|
timeout := time.Now().Add(1 * time.Second) |
|
|
|
timeout := time.Now().Add(1 * time.Second) |
|
|
|
for { |
|
|
|
for { |
|
|
@ -277,13 +268,8 @@ func TestPendingTxFilter(t *testing.T) { |
|
|
|
// If not it must return an error.
|
|
|
|
// If not it must return an error.
|
|
|
|
func TestLogFilterCreation(t *testing.T) { |
|
|
|
func TestLogFilterCreation(t *testing.T) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
|
|
|
|
|
|
|
|
testCases = []struct { |
|
|
|
testCases = []struct { |
|
|
@ -326,13 +312,8 @@ func TestInvalidLogFilterCreation(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -353,13 +334,8 @@ func TestInvalidLogFilterCreation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
func TestInvalidGetLogsRequest(t *testing.T) { |
|
|
|
func TestInvalidGetLogsRequest(t *testing.T) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111") |
|
|
|
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111") |
|
|
|
) |
|
|
|
) |
|
|
@ -383,13 +359,8 @@ func TestLogFilter(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
|
|
|
|
|
|
|
|
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") |
|
|
|
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") |
|
|
@ -400,7 +371,7 @@ func TestLogFilter(t *testing.T) { |
|
|
|
secondTopic = common.HexToHash("0x2222222222222222222222222222222222222222222222222222222222222222") |
|
|
|
secondTopic = common.HexToHash("0x2222222222222222222222222222222222222222222222222222222222222222") |
|
|
|
notUsedTopic = common.HexToHash("0x9999999999999999999999999999999999999999999999999999999999999999") |
|
|
|
notUsedTopic = common.HexToHash("0x9999999999999999999999999999999999999999999999999999999999999999") |
|
|
|
|
|
|
|
|
|
|
|
// posted twice, once as vm.Logs and once as core.PendingLogsEvent
|
|
|
|
// posted twice, once as regular logs and once as pending logs.
|
|
|
|
allLogs = []*types.Log{ |
|
|
|
allLogs = []*types.Log{ |
|
|
|
{Address: firstAddr}, |
|
|
|
{Address: firstAddr}, |
|
|
|
{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 1}, |
|
|
|
{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 1}, |
|
|
@ -453,11 +424,11 @@ func TestLogFilter(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// raise events
|
|
|
|
// raise events
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
if nsend := logsFeed.Send(allLogs); nsend == 0 { |
|
|
|
if nsend := backend.logsFeed.Send(allLogs); nsend == 0 { |
|
|
|
t.Fatal("Shoud have at least one subscription") |
|
|
|
t.Fatal("Logs event not delivered") |
|
|
|
} |
|
|
|
} |
|
|
|
if err := mux.Post(core.PendingLogsEvent{Logs: allLogs}); err != nil { |
|
|
|
if nsend := backend.pendingLogsFeed.Send(allLogs); nsend == 0 { |
|
|
|
t.Fatal(err) |
|
|
|
t.Fatal("Pending logs event not delivered") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for i, tt := range testCases { |
|
|
|
for i, tt := range testCases { |
|
|
@ -502,13 +473,8 @@ func TestPendingLogsSubscription(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
mux = new(event.TypeMux) |
|
|
|
|
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
txFeed = new(event.Feed) |
|
|
|
backend = &testBackend{db: db} |
|
|
|
rmLogsFeed = new(event.Feed) |
|
|
|
|
|
|
|
logsFeed = new(event.Feed) |
|
|
|
|
|
|
|
chainFeed = new(event.Feed) |
|
|
|
|
|
|
|
backend = &testBackend{mux, db, 0, txFeed, rmLogsFeed, logsFeed, chainFeed} |
|
|
|
|
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
api = NewPublicFilterAPI(backend, false) |
|
|
|
|
|
|
|
|
|
|
|
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") |
|
|
|
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") |
|
|
@ -521,26 +487,18 @@ func TestPendingLogsSubscription(t *testing.T) { |
|
|
|
fourthTopic = common.HexToHash("0x4444444444444444444444444444444444444444444444444444444444444444") |
|
|
|
fourthTopic = common.HexToHash("0x4444444444444444444444444444444444444444444444444444444444444444") |
|
|
|
notUsedTopic = common.HexToHash("0x9999999999999999999999999999999999999999999999999999999999999999") |
|
|
|
notUsedTopic = common.HexToHash("0x9999999999999999999999999999999999999999999999999999999999999999") |
|
|
|
|
|
|
|
|
|
|
|
allLogs = []core.PendingLogsEvent{ |
|
|
|
allLogs = [][]*types.Log{ |
|
|
|
{Logs: []*types.Log{{Address: firstAddr, Topics: []common.Hash{}, BlockNumber: 0}}}, |
|
|
|
{{Address: firstAddr, Topics: []common.Hash{}, BlockNumber: 0}}, |
|
|
|
{Logs: []*types.Log{{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 1}}}, |
|
|
|
{{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 1}}, |
|
|
|
{Logs: []*types.Log{{Address: secondAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 2}}}, |
|
|
|
{{Address: secondAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 2}}, |
|
|
|
{Logs: []*types.Log{{Address: thirdAddress, Topics: []common.Hash{secondTopic}, BlockNumber: 3}}}, |
|
|
|
{{Address: thirdAddress, Topics: []common.Hash{secondTopic}, BlockNumber: 3}}, |
|
|
|
{Logs: []*types.Log{{Address: thirdAddress, Topics: []common.Hash{secondTopic}, BlockNumber: 4}}}, |
|
|
|
{{Address: thirdAddress, Topics: []common.Hash{secondTopic}, BlockNumber: 4}}, |
|
|
|
{Logs: []*types.Log{ |
|
|
|
{ |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{firstTopic}, BlockNumber: 5}, |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{firstTopic}, BlockNumber: 5}, |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{thirdTopic}, BlockNumber: 5}, |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{thirdTopic}, BlockNumber: 5}, |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{fourthTopic}, BlockNumber: 5}, |
|
|
|
{Address: thirdAddress, Topics: []common.Hash{fourthTopic}, BlockNumber: 5}, |
|
|
|
{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 5}, |
|
|
|
{Address: firstAddr, Topics: []common.Hash{firstTopic}, BlockNumber: 5}, |
|
|
|
}}, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convertLogs = func(pl []core.PendingLogsEvent) []*types.Log { |
|
|
|
|
|
|
|
var logs []*types.Log |
|
|
|
|
|
|
|
for _, l := range pl { |
|
|
|
|
|
|
|
logs = append(logs, l.Logs...) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return logs |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
testCases = []struct { |
|
|
|
testCases = []struct { |
|
|
@ -550,21 +508,52 @@ func TestPendingLogsSubscription(t *testing.T) { |
|
|
|
sub *Subscription |
|
|
|
sub *Subscription |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
// match all
|
|
|
|
// match all
|
|
|
|
{ethereum.FilterQuery{}, convertLogs(allLogs), nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{}, flattenLogs(allLogs), |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// match none due to no matching addresses
|
|
|
|
// match none due to no matching addresses
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{{}, notUsedAddress}, Topics: [][]common.Hash{nil}}, []*types.Log{}, nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{{}, notUsedAddress}, Topics: [][]common.Hash{nil}}, |
|
|
|
|
|
|
|
nil, |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// match logs based on addresses, ignore topics
|
|
|
|
// match logs based on addresses, ignore topics
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{firstAddr}}, append(convertLogs(allLogs[:2]), allLogs[5].Logs[3]), nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{firstAddr}}, |
|
|
|
|
|
|
|
append(flattenLogs(allLogs[:2]), allLogs[5][3]), |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// match none due to no matching topics (match with address)
|
|
|
|
// match none due to no matching topics (match with address)
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{{notUsedTopic}}}, []*types.Log{}, nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{{notUsedTopic}}}, |
|
|
|
|
|
|
|
nil, nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// match logs based on addresses and topics
|
|
|
|
// match logs based on addresses and topics
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, append(convertLogs(allLogs[3:5]), allLogs[5].Logs[0]), nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, |
|
|
|
|
|
|
|
append(flattenLogs(allLogs[3:5]), allLogs[5][0]), |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// match logs based on multiple addresses and "or" topics
|
|
|
|
// match logs based on multiple addresses and "or" topics
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, append(convertLogs(allLogs[2:5]), allLogs[5].Logs[0]), nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, |
|
|
|
|
|
|
|
append(flattenLogs(allLogs[2:5]), allLogs[5][0]), |
|
|
|
|
|
|
|
nil, |
|
|
|
|
|
|
|
nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// block numbers are ignored for filters created with New***Filter, these return all logs that match the given criteria when the state changes
|
|
|
|
// block numbers are ignored for filters created with New***Filter, these return all logs that match the given criteria when the state changes
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(2), ToBlock: big.NewInt(3)}, append(convertLogs(allLogs[:2]), allLogs[5].Logs[3]), nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(2), ToBlock: big.NewInt(3)}, |
|
|
|
|
|
|
|
append(flattenLogs(allLogs[:2]), allLogs[5][3]), |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
// multiple pending logs, should match only 2 topics from the logs in block 5
|
|
|
|
// multiple pending logs, should match only 2 topics from the logs in block 5
|
|
|
|
{ethereum.FilterQuery{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, fourthTopic}}}, []*types.Log{allLogs[5].Logs[0], allLogs[5].Logs[2]}, nil, nil}, |
|
|
|
{ |
|
|
|
|
|
|
|
ethereum.FilterQuery{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, fourthTopic}}}, |
|
|
|
|
|
|
|
[]*types.Log{allLogs[5][0], allLogs[5][2]}, |
|
|
|
|
|
|
|
nil, nil, |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -607,10 +596,15 @@ func TestPendingLogsSubscription(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// raise events
|
|
|
|
// raise events
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
// allLogs are type of core.PendingLogsEvent
|
|
|
|
for _, ev := range allLogs { |
|
|
|
for _, l := range allLogs { |
|
|
|
backend.pendingLogsFeed.Send(ev) |
|
|
|
if err := mux.Post(l); err != nil { |
|
|
|
|
|
|
|
t.Fatal(err) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func flattenLogs(pl [][]*types.Log) []*types.Log { |
|
|
|
|
|
|
|
var logs []*types.Log |
|
|
|
|
|
|
|
for _, l := range pl { |
|
|
|
|
|
|
|
logs = append(logs, l...) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return logs |
|
|
|
} |
|
|
|
} |
|
|
|