From 461d84dd753fa838c370093ae680eee8cc5b216f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 21 May 2017 18:30:55 -0700 Subject: [PATCH] routing/chainview: report line # in test failures, bump up timeouts --- routing/chainview/interface_test.go | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index 883f20bd..24adfee2 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -84,17 +84,19 @@ func craftSpendTransaction(outpoint wire.OutPoint, payScript []byte) (*wire.MsgT func assertFilteredBlock(t *testing.T, fb *FilteredBlock, expectedHeight int32, expectedHash *chainhash.Hash, txns []*chainhash.Hash) { + _, _, line, _ := runtime.Caller(1) + if fb.Height != uint32(expectedHeight) { - t.Fatalf("block height mismatch: expected %v, got %v", - expectedHeight, fb.Height) + t.Fatalf("line %v: block height mismatch: expected %v, got %v", + line, expectedHeight, fb.Height) } if !bytes.Equal(fb.Hash[:], expectedHash[:]) { - t.Fatalf("block hash mismatch: expected %v, got %v", - expectedHash, fb.Hash) + t.Fatalf("line %v: block hash mismatch: expected %v, got %v", + line, expectedHash, fb.Hash) } if len(fb.Transactions) != len(txns) { - t.Fatalf("expected %v transaction in filtered block, instead "+ - "have %v", len(txns), len(fb.Transactions)) + t.Fatalf("line %v: expected %v transaction in filtered block, instead "+ + "have %v", line, len(txns), len(fb.Transactions)) } expectedTxids := make(map[chainhash.Hash]struct{}) @@ -108,7 +110,7 @@ func assertFilteredBlock(t *testing.T, fb *FilteredBlock, expectedHeight int32, } if len(expectedTxids) != 0 { - t.Fatalf("missing txids: %v", expectedTxids) + t.Fatalf("line %v: missing txids: %v", line, expectedTxids) } } @@ -146,7 +148,7 @@ func testFilterBlockNotifications(node *rpctest.Harness, case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight, newBlockHashes[0], []*chainhash.Hash{}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") } @@ -272,7 +274,7 @@ func testUpdateFilterBackTrack(node *rpctest.Harness, chainView FilteredChainVie case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight, initBlockHashes[0], []*chainhash.Hash{}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") } @@ -304,7 +306,7 @@ func testUpdateFilterBackTrack(node *rpctest.Harness, chainView FilteredChainVie case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight+1, newBlockHashes[0], []*chainhash.Hash{}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") } @@ -322,7 +324,7 @@ func testUpdateFilterBackTrack(node *rpctest.Harness, chainView FilteredChainVie case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight+1, newBlockHashes[0], []*chainhash.Hash{spendTxid}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") } } @@ -358,12 +360,12 @@ func testFilterSingleBlock(node *rpctest.Harness, chainView FilteredChainView, } // We should get an update, however it shouldn't yet contain any - // filtered transaction as the filter hasn't been update. + // filtered transaction as the filter hasn't been updated. select { case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight, newBlockHashes[0], []*chainhash.Hash{}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") } @@ -404,7 +406,7 @@ func testFilterSingleBlock(node *rpctest.Harness, chainView FilteredChainView, case filteredBlock := <-blockChan: assertFilteredBlock(t, filteredBlock, currentHeight+1, block.Hash(), []*chainhash.Hash{}) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 10): t.Fatalf("filtered block notification didn't arrive") }