chainntnfs/interface_test: increase wait time for mempool spends
This commit increases the time we wait for a spend client to notify a mempool spend from 50ms to 10s. This is done to catch the case where bitcoind would use up to 7 seconds before notifying about a mempool spend, which wasn't caught by the test.
This commit is contained in:
parent
4e47e4e7f1
commit
07618ca0c6
@ -425,14 +425,30 @@ func testSpendNotification(miner *rpctest.Harness,
|
|||||||
t.Fatalf("tx not relayed to miner: %v", err)
|
t.Fatalf("tx not relayed to miner: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure notifications are not yet sent.
|
// Make sure notifications are not yet sent. We launch a go routine for
|
||||||
|
// all the spend clients, such that we can wait for them all in
|
||||||
|
// parallel.
|
||||||
|
//
|
||||||
|
// Since bitcoind is at times very slow at notifying about txs in the
|
||||||
|
// mempool, we use a quite large timeout of 10 seconds.
|
||||||
|
// TODO(halseth): change this when mempool spends are removed.
|
||||||
|
mempoolSpendTimeout := 10 * time.Second
|
||||||
|
mempoolSpends := make(chan *chainntnfs.SpendDetail, numClients)
|
||||||
for _, c := range spendClients {
|
for _, c := range spendClients {
|
||||||
select {
|
go func(client *chainntnfs.SpendEvent) {
|
||||||
case <-c.Spend:
|
select {
|
||||||
t.Fatalf("did not expect to get notification before " +
|
case s := <-client.Spend:
|
||||||
"block was mined")
|
mempoolSpends <- s
|
||||||
case <-time.After(50 * time.Millisecond):
|
case <-time.After(mempoolSpendTimeout):
|
||||||
}
|
}
|
||||||
|
}(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-mempoolSpends:
|
||||||
|
t.Fatalf("did not expect to get notification before " +
|
||||||
|
"block was mined")
|
||||||
|
case <-time.After(mempoolSpendTimeout):
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we mine a single block, which should include our spend. The
|
// Now we mine a single block, which should include our spend. The
|
||||||
|
Loading…
Reference in New Issue
Block a user