-
Notifications
You must be signed in to change notification settings - Fork 186
/
rescan_test.go
668 lines (558 loc) · 19.7 KB
/
rescan_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
package neutrino
import (
"errors"
"os"
"reflect"
"runtime/pprof"
"sync"
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/gcs"
"github.com/btcsuite/btcd/btcutil/gcs/builder"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightninglabs/neutrino/blockntfns"
"github.com/lightninglabs/neutrino/headerfs"
)
// mockChainSource is a mock implementation of the ChainSource interface that
// aims to ease testing the behavior of the Rescan struct.
type mockChainSource struct {
ntfnChan chan blockntfns.BlockNtfn
filtersQueried chan chainhash.Hash
mu sync.Mutex // all fields below are protected
bestBlock headerfs.BlockStamp
blockHeightIndex map[chainhash.Hash]uint32
blockHashesByHeight map[uint32]*chainhash.Hash
blockHeaders map[chainhash.Hash]*wire.BlockHeader
blocks map[chainhash.Hash]*btcutil.Block
failGetFilter bool // if true, returns nil filter in GetCFilter
filters map[chainhash.Hash]*gcs.Filter
filterHeadersByHeight map[uint32]*chainhash.Hash
subscribeOverride func(uint32) (*blockntfns.Subscription, error)
}
var _ ChainSource = (*mockChainSource)(nil)
// newMockChainSource creates a new mock chain backed by numBlocks.
func newMockChainSource(numBlocks int) *mockChainSource {
chain := &mockChainSource{
ntfnChan: make(chan blockntfns.BlockNtfn),
filtersQueried: make(chan chainhash.Hash),
blockHeightIndex: make(map[chainhash.Hash]uint32),
blockHashesByHeight: make(map[uint32]*chainhash.Hash),
blockHeaders: make(map[chainhash.Hash]*wire.BlockHeader),
blocks: make(map[chainhash.Hash]*btcutil.Block),
filterHeadersByHeight: make(map[uint32]*chainhash.Hash),
filters: make(map[chainhash.Hash]*gcs.Filter),
}
genesisHash := chain.ChainParams().GenesisHash
genesisBlock := chain.ChainParams().GenesisBlock
chain.blockHeightIndex[*genesisHash] = 0
chain.blockHashesByHeight[0] = genesisHash
chain.blockHeaders[*genesisHash] = &genesisBlock.Header
chain.blocks[*genesisHash] = btcutil.NewBlock(genesisBlock)
filter, _ := gcs.FromBytes(0, builder.DefaultP, builder.DefaultM, nil)
chain.filters[*genesisHash] = filter
filterHeader, _ := builder.MakeHeaderForFilter(filter, chainhash.Hash{})
chain.filterHeadersByHeight[0] = &filterHeader
chain.bestBlock = headerfs.BlockStamp{
Height: 0,
Hash: *genesisHash,
Timestamp: genesisBlock.Header.Timestamp,
}
for i := 0; i < numBlocks-1; i++ {
chain.addNewBlock(false)
}
return chain
}
// addNewBlock advances the chain by one block. The notify boolean can be used
// to notify the new block.
func (c *mockChainSource) addNewBlock(notify bool) headerfs.BlockStamp {
c.mu.Lock()
newHeight := uint32(c.bestBlock.Height + 1)
prevHash := c.bestBlock.Hash
c.mu.Unlock()
genesisTimestamp := c.ChainParams().GenesisBlock.Header.Timestamp
header := &wire.BlockHeader{
PrevBlock: prevHash,
Timestamp: genesisTimestamp.Add(
time.Duration(newHeight) * 10 * time.Minute,
),
}
return c.addNewBlockWithHeader(header, notify)
}
// addNewBlock advances the chain by one block with the given header. The notify
// boolean can be used to notify the new block.
//
// NOTE: The header's PrevBlock should properly point to the best block in the
// chain.
func (c *mockChainSource) addNewBlockWithHeader(header *wire.BlockHeader,
notify bool) headerfs.BlockStamp {
c.mu.Lock()
newHeight := uint32(c.bestBlock.Height + 1)
newHash := header.BlockHash()
c.blockHeightIndex[newHash] = newHeight
c.blockHashesByHeight[newHeight] = &newHash
c.blockHeaders[newHash] = header
c.blocks[newHash] = btcutil.NewBlock(wire.NewMsgBlock(header))
newFilter, _ := gcs.FromBytes(0, builder.DefaultP, builder.DefaultM, nil)
c.filters[newHash] = newFilter
newFilterHeader, _ := builder.MakeHeaderForFilter(
newFilter, *c.filterHeadersByHeight[newHeight-1],
)
c.filterHeadersByHeight[newHeight] = &newFilterHeader
c.bestBlock.Height++
c.bestBlock.Hash = newHash
c.bestBlock.Timestamp = header.Timestamp
bestBlock := c.bestBlock
c.mu.Unlock()
if notify {
c.ntfnChan <- blockntfns.NewBlockConnected(*header, newHeight)
}
return bestBlock
}
// rollback rolls back the chain by one block. The notify boolean can be used to
// notify the stale block.
func (c *mockChainSource) rollback(notify bool) headerfs.BlockStamp {
c.mu.Lock()
curHeight := uint32(c.bestBlock.Height)
curHeader := c.blockHeaders[c.bestBlock.Hash]
prevHeader := c.blockHeaders[curHeader.PrevBlock]
delete(c.blockHeightIndex, c.bestBlock.Hash)
delete(c.blockHashesByHeight, curHeight)
delete(c.blockHeaders, c.bestBlock.Hash)
delete(c.blocks, c.bestBlock.Hash)
delete(c.filterHeadersByHeight, curHeight)
delete(c.filters, c.bestBlock.Hash)
c.bestBlock.Height--
c.bestBlock.Hash = curHeader.PrevBlock
c.bestBlock.Timestamp = prevHeader.Timestamp
bestBlock := c.bestBlock
c.mu.Unlock()
if notify {
c.ntfnChan <- blockntfns.NewBlockDisconnected(
*curHeader, curHeight, *prevHeader,
)
}
return bestBlock
}
// rollbackToHeight rolls back the chain to the specified height. The notify
// boolean can be used to notify all stale blocks.
func (c *mockChainSource) rollbackToHeight(height int32, notify bool) {
c.mu.Lock()
bestBlock := c.bestBlock
c.mu.Unlock()
for bestBlock.Height > height {
bestBlock = c.rollback(notify)
}
}
// ChainParams returns the parameters of the current chain.
func (c *mockChainSource) ChainParams() chaincfg.Params {
return chaincfg.MainNetParams
}
// BestBlock retrieves the most recent block's height and hash where we have
// both the header and filter header ready.
func (c *mockChainSource) BestBlock() (*headerfs.BlockStamp, error) {
c.mu.Lock()
defer c.mu.Unlock()
// Return a copy to prevent mutating internal state.
return &headerfs.BlockStamp{
Height: c.bestBlock.Height,
Hash: c.bestBlock.Hash,
Timestamp: c.bestBlock.Timestamp,
}, nil
}
// GetBlockHeaderByHeight returns the header of the block with the given height.
func (c *mockChainSource) GetBlockHeaderByHeight(
height uint32) (*wire.BlockHeader, error) {
c.mu.Lock()
defer c.mu.Unlock()
blockHash, ok := c.blockHashesByHeight[height]
if !ok {
return nil, errors.New("block height not found")
}
blockHeader, ok := c.blockHeaders[*blockHash]
if !ok {
return nil, errors.New("block header not found")
}
return blockHeader, nil
}
// GetBlockHeader returns the header of the block with the given hash.
func (c *mockChainSource) GetBlockHeader(
hash *chainhash.Hash) (*wire.BlockHeader, uint32, error) {
c.mu.Lock()
defer c.mu.Unlock()
blockHeader, ok := c.blockHeaders[*hash]
if !ok {
return nil, 0, errors.New("block header not found")
}
blockHeight, ok := c.blockHeightIndex[*hash]
if !ok {
return nil, 0, errors.New("block height not found")
}
return blockHeader, blockHeight, nil
}
// GetBlock returns the block with the given hash.
func (c *mockChainSource) GetBlock(hash chainhash.Hash,
_ ...QueryOption) (*btcutil.Block, error) {
c.mu.Lock()
defer c.mu.Unlock()
block, ok := c.blocks[hash]
if !ok {
return nil, errors.New("block not found")
}
return block, nil
}
// GetFilterHeaderByHeight returns the filter header of the block with the given
// height.
func (c *mockChainSource) GetFilterHeaderByHeight(
height uint32) (*chainhash.Hash, error) {
c.mu.Lock()
defer c.mu.Unlock()
filterHeader, ok := c.filterHeadersByHeight[height]
if !ok {
return nil, errors.New("filter header not found")
}
return filterHeader, nil
}
// setFailGetFilter determines whether we should fail to retrieve for a block.
func (c *mockChainSource) setFailGetFilter(b bool) {
c.mu.Lock()
defer c.mu.Unlock()
c.failGetFilter = b
}
// IsCurrent returns true if the backend chain thinks that its view of
// the network is current.
func (c *mockChainSource) IsCurrent() bool {
return true
}
// GetCFilter returns the filter of the given type for the block with the given
// hash.
func (c *mockChainSource) GetCFilter(hash chainhash.Hash,
filterType wire.FilterType, options ...QueryOption) (*gcs.Filter, error) {
defer func() {
c.filtersQueried <- hash
}()
c.mu.Lock()
defer c.mu.Unlock()
if c.failGetFilter {
return nil, errors.New("failed filter")
}
filter, ok := c.filters[hash]
if !ok {
return nil, errors.New("filter not found")
}
return filter, nil
}
// overrideSubscribe allows us to override the mockChainSource's Subscribe
// method implementation to ease testing.
func (c *mockChainSource) overrideSubscribe(
f func(uint32) (*blockntfns.Subscription, error)) {
c.mu.Lock()
defer c.mu.Unlock()
c.subscribeOverride = f
}
// Subscribe returns a block subscription that delivers block notifications in
// order. The bestHeight parameter can be used to signal that a backlog of
// notifications should be delivered from this height. When providing a
// bestHeight of 0, a backlog will not be delivered.
func (c *mockChainSource) Subscribe(
bestHeight uint32) (*blockntfns.Subscription, error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.subscribeOverride != nil {
return c.subscribeOverride(bestHeight)
}
for i := bestHeight + 1; i <= uint32(c.bestBlock.Height); i++ {
hash := c.blockHashesByHeight[i]
header := c.blockHeaders[*hash]
c.ntfnChan <- blockntfns.NewBlockConnected(*header, i)
}
return &blockntfns.Subscription{
Notifications: c.ntfnChan,
Cancel: func() {},
}, nil
}
// rescanTestContext serves as a harness to aid testing the Rescan struct.
type rescanTestContext struct {
t *testing.T
chain *mockChainSource
blocksConnected chan headerfs.BlockStamp
blocksDisconnected chan headerfs.BlockStamp
rescan *Rescan
errChan <-chan error
quit chan struct{}
}
// newRescanTestContext creates a new test harness for the Rescan struct backed
// by a chain of numBlocks.
func newRescanTestContext(t *testing.T, numBlocks int, // nolint:unparam
options ...RescanOption) *rescanTestContext {
blocksConnected := make(chan headerfs.BlockStamp)
blocksDisconnected := make(chan headerfs.BlockStamp)
ntfnHandlers := rpcclient.NotificationHandlers{
OnFilteredBlockConnected: func(height int32,
header *wire.BlockHeader, _ []*btcutil.Tx) {
blocksConnected <- headerfs.BlockStamp{
Hash: header.BlockHash(),
Height: height,
Timestamp: header.Timestamp,
}
},
OnFilteredBlockDisconnected: func(height int32,
header *wire.BlockHeader) {
blocksDisconnected <- headerfs.BlockStamp{
Hash: header.BlockHash(),
Height: height,
Timestamp: header.Timestamp,
}
},
}
quit := make(chan struct{})
chain := newMockChainSource(numBlocks)
rescanOptions := []RescanOption{
NotificationHandlers(ntfnHandlers), QuitChan(quit),
}
rescanOptions = append(rescanOptions, options...)
rescan := NewRescan(chain, rescanOptions...)
return &rescanTestContext{
t: t,
chain: chain,
blocksConnected: blocksConnected,
blocksDisconnected: blocksDisconnected,
rescan: rescan,
quit: quit,
}
}
// start starts the backing rescan.
func (ctx *rescanTestContext) start(waitUntilSynced bool) { // nolint:unparam
if !waitUntilSynced {
ctx.errChan = ctx.rescan.Start()
return
}
// Override the mock chain subscribe implementation so that it delivers
// a signal once synced.
signal := make(chan struct{})
deliverSyncSignal := func(bestHeight uint32) (*blockntfns.Subscription, error) {
if bestHeight == uint32(ctx.chain.bestBlock.Height) {
close(signal)
}
return &blockntfns.Subscription{
Notifications: ctx.chain.ntfnChan,
Cancel: func() {},
}, nil
}
ctx.chain.overrideSubscribe(deliverSyncSignal)
// Start the rescan and wait for the signal to be delivered.
ctx.errChan = ctx.rescan.Start()
select {
case <-signal:
case <-time.After(5 * time.Second):
ctx.t.Fatal("expected to receive synced signal")
}
// Once done, we can revert to our original subscribe implementation.
ctx.chain.overrideSubscribe(nil)
}
// stop stops the rescan test harness and ensures it exits cleanly.
func (ctx *rescanTestContext) stop() {
close(ctx.quit)
select {
case err := <-ctx.errChan:
if err != ErrRescanExit {
ctx.t.Fatalf("expected ErrRescanExit upon shutdown, "+
"got %v", err)
}
case <-time.After(time.Second):
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
ctx.t.Fatal("rescan did not exit cleanly")
}
select {
case <-ctx.blocksConnected:
ctx.t.Fatalf("received unexpected block connected after shutdown")
case <-ctx.blocksDisconnected:
ctx.t.Fatalf("received unexpected block disconnected after shutdown")
case <-ctx.chain.filtersQueried:
ctx.t.Fatalf("received unexpected filter query after shutdown")
default:
}
}
// recvBlockConnected is a helper method used to expect a block connected
// notification being delivered.
func (ctx *rescanTestContext) recvBlockConnected(block headerfs.BlockStamp) {
ctx.t.Helper()
select {
case recvBlock := <-ctx.blocksConnected:
if !reflect.DeepEqual(recvBlock, block) {
ctx.t.Fatalf("expected block connected notification "+
"for %v, got %v", spew.Sdump(block),
spew.Sdump(recvBlock))
}
case <-time.After(time.Second):
ctx.t.Fatalf("expected to receive block connected "+
"notification for %v", spew.Sdump(block))
}
}
// assertFilterQueried asserts that a filter for the given block hash was
// queried for.
func (ctx *rescanTestContext) assertFilterQueried(hash chainhash.Hash) {
ctx.t.Helper()
var hashQueried chainhash.Hash
select {
case hashQueried = <-ctx.chain.filtersQueried:
if !hashQueried.IsEqual(&hash) {
ctx.t.Fatalf("expected to query filter %v, got %v",
hash, hashQueried)
}
case <-time.After(time.Second):
ctx.t.Fatal("expected rescan to query for filter")
}
}
// TestRescanNewBlockAfterRetry ensures that the rescan can properly queue
// blocks for which we are missing a filter for.
func TestRescanNewBlockAfterRetry(t *testing.T) {
t.Parallel()
// Dummy options to allow the Rescan to fetch block filters.
ctx := newRescanTestContext(t, 10, []RescanOption{
StartTime(time.Time{}),
WatchInputs(InputWithScript{}),
}...)
ctx.start(true)
defer ctx.stop()
// Modify the mocked chain such that it fails to retrieve block filters.
ctx.chain.setFailGetFilter(true)
// Adding multiple new blocks to the chain should result in the first
// retry block being queried until successful.
block1 := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block1.Hash)
block2 := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block1.Hash)
// Revert the mocked chain so that block filters can be retrieved
// successfully.
ctx.chain.setFailGetFilter(false)
// The blocks should now be notified in their expected order.
ctx.assertFilterQueried(block1.Hash)
ctx.recvBlockConnected(block1)
ctx.assertFilterQueried(block2.Hash)
ctx.recvBlockConnected(block2)
}
// TestRescanReorgAllButFirstRetryBlocks ensures the rescan stops retrying
// blocks for which it has received disconnected notifications for.
func TestRescanReorgAllButFirstRetryBlocks(t *testing.T) {
t.Parallel()
// Dummy options to allow the Rescan to fetch block filters.
ctx := newRescanTestContext(t, 10, []RescanOption{
StartTime(time.Time{}),
WatchInputs(InputWithScript{}),
}...)
ctx.start(true)
defer ctx.stop()
// Modify the mocked chain such that it fails to retrieve block filters.
ctx.chain.setFailGetFilter(true)
// Adding multiple new blocks to the chain should result in the first
// retry block being queried until successful.
block := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block.Hash)
ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block.Hash)
ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block.Hash)
// We'll then reorg back to the first retry block. This should cause us
// to stop retrying the following reorged blocks.
ctx.chain.rollbackToHeight(block.Height, true)
// Revert the mocked chain so that block filters can be retrieved
// successfully.
ctx.chain.setFailGetFilter(false)
// Since the first block wasn't reorged, we should expect a notification
// for it.
ctx.assertFilterQueried(block.Hash)
ctx.recvBlockConnected(block)
}
// TestRescanReorgAllRetryBlocks ensures the rescan stops retrying blocks for
// which it has received disconnected notifications for and queries for blocks
// of the new chain instead.
func TestRescanReorgAllRetryBlocks(t *testing.T) {
t.Parallel()
// Dummy options to allow the Rescan to fetch block filters.
ctx := newRescanTestContext(t, 10, []RescanOption{
StartTime(time.Time{}),
WatchInputs(InputWithScript{}),
}...)
ctx.start(true)
defer ctx.stop()
// Note the block which we'll revert back to.
bestBlock, err := ctx.chain.BestBlock()
if err != nil {
ctx.t.Fatalf("unable to retrieve best block: %v", err)
}
// Modify the mocked chain such that it fails to retrieve block filters.
ctx.chain.setFailGetFilter(true)
// Adding multiple new blocks to the chain should result in the first
// retry block being queried until successful.
block1 := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block1.Hash)
block2 := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block1.Hash)
// We'll then reorg back to a height where the new blocks we've added
// and retried are stale, causing us to no longer retry them. The rescan
// won't deliver any disconnected notifications to its caller since it
// never delivered connected notifications for them.
ctx.chain.rollbackToHeight(bestBlock.Height, true)
// Revert the mocked chain so that block filters can be retrieved
// successfully.
ctx.chain.setFailGetFilter(false)
// We'll then add two new blocks from a different chain to ensure the
// rescan can properly follow it.
newBlock1 := ctx.chain.addNewBlockWithHeader(
&wire.BlockHeader{PrevBlock: bestBlock.Hash}, true,
)
if newBlock1.Hash == block1.Hash {
ctx.t.Fatal("expected different hashes for blocks on " +
"different chains")
}
ctx.assertFilterQueried(newBlock1.Hash)
ctx.recvBlockConnected(newBlock1)
newBlock2 := ctx.chain.addNewBlock(true)
if newBlock2.Hash == block2.Hash {
ctx.t.Fatal("expected different hashes for blocks on " +
"different chains")
}
ctx.assertFilterQueried(newBlock2.Hash)
ctx.recvBlockConnected(newBlock2)
}
// TestRescanRetryBlocksAfterCatchingUp ensures the rescan stops retrying blocks
// after catching up with the chain. Catching up assumes that we already have an
// accurate representation of the chain.
func TestRescanRetryBlocksAfterCatchingUp(t *testing.T) {
t.Parallel()
// Dummy options to allow the Rescan to fetch block filters.
ctx := newRescanTestContext(t, 10, []RescanOption{
StartTime(time.Time{}),
WatchInputs(InputWithScript{}),
}...)
ctx.start(true)
defer ctx.stop()
// Modify the mocked chain such that it fails to retrieve block filters.
ctx.chain.setFailGetFilter(true)
// Adding multiple new blocks to the chain should result in the first
// retry block being queried until successful.
block1 := ctx.chain.addNewBlock(true)
ctx.assertFilterQueried(block1.Hash)
// We'll prevent notifying new blocks and instead notify an invalid
// block which should prompt the rescan to catch up with the chain
// manually.
block2 := ctx.chain.addNewBlock(false)
block3 := ctx.chain.addNewBlock(false)
ctx.chain.ntfnChan <- blockntfns.NewBlockConnected(wire.BlockHeader{}, 0)
// Revert the mocked chain so that block filters can be retrieved
// successfully.
ctx.chain.setFailGetFilter(false)
// The notifications for all the blocks added above should now be
// delivered as part of catching up.
ctx.assertFilterQueried(block1.Hash)
ctx.recvBlockConnected(block1)
ctx.assertFilterQueried(block2.Hash)
ctx.recvBlockConnected(block2)
ctx.assertFilterQueried(block3.Hash)
ctx.recvBlockConnected(block3)
}