chainntnfs: Remove some unnecessary channels in interface_test.

This commit is contained in:
Jim Posen 2017-09-27 19:38:30 -07:00 committed by Olaoluwa Osuntokun
parent be7cb08f41
commit e9c16845dc
1 changed files with 6 additions and 31 deletions

View File

@ -100,13 +100,8 @@ func testSingleConfirmationNotification(miner *rpctest.Harness,
t.Fatalf("unable to generate single block: %v", err) t.Fatalf("unable to generate single block: %v", err)
} }
confSent := make(chan *chainntnfs.TxConfirmation)
go func() {
confSent <- <-confIntent.Confirmed
}()
select { select {
case confInfo := <-confSent: case confInfo := <-confIntent.Confirmed:
// Finally, we'll verify that the tx index returned is the exact same // Finally, we'll verify that the tx index returned is the exact same
// as the tx index of the transaction within the block itself. // as the tx index of the transaction within the block itself.
msgBlock, err := miner.Node.GetBlock(blockHash[0]) msgBlock, err := miner.Node.GetBlock(blockHash[0])
@ -160,16 +155,11 @@ func testMultiConfirmationNotification(miner *rpctest.Harness,
t.Fatalf("unable to generate single block: %v", err) t.Fatalf("unable to generate single block: %v", err)
} }
confSent := make(chan *chainntnfs.TxConfirmation)
go func() {
confSent <- <-confIntent.Confirmed
}()
// TODO(roasbeef): reduce all timeouts after neutrino sync tightended // TODO(roasbeef): reduce all timeouts after neutrino sync tightended
// up // up
select { select {
case <-confSent: case <-confIntent.Confirmed:
break break
case <-time.After(20 * time.Second): case <-time.After(20 * time.Second):
t.Fatalf("confirmation notification never received") t.Fatalf("confirmation notification never received")
@ -229,13 +219,8 @@ func testBatchConfirmationNotification(miner *rpctest.Harness,
t.Fatalf("unable to generate single block: %v", err) t.Fatalf("unable to generate single block: %v", err)
} }
confSent := make(chan *chainntnfs.TxConfirmation)
go func() {
confSent <- <-confIntents[i].Confirmed
}()
select { select {
case conf := <-confSent: case conf := <-confIntents[i].Confirmed:
// All of the notifications above were originally // All of the notifications above were originally
// confirmed in the same block. The returned // confirmed in the same block. The returned
// notification should list the initial confirmation // notification should list the initial confirmation
@ -529,7 +514,7 @@ func testTxConfirmedBeforeNtfnRegistration(miner *rpctest.Harness,
// notification will never be sent. // notification will never be sent.
blockHash, err := miner.Node.Generate(1) blockHash, err := miner.Node.Generate(1)
if err != nil { if err != nil {
t.Fatalf("unable to generate two blocks: %v", err) t.Fatalf("unable to generate block: %v", err)
} }
_, currentHeight, err := miner.Node.GetBestBlock() _, currentHeight, err := miner.Node.GetBestBlock()
@ -546,13 +531,8 @@ func testTxConfirmedBeforeNtfnRegistration(miner *rpctest.Harness,
t.Fatalf("unable to register ntfn: %v", err) t.Fatalf("unable to register ntfn: %v", err)
} }
confSent := make(chan *chainntnfs.TxConfirmation)
go func() {
confSent <- <-confIntent.Confirmed
}()
select { select {
case confInfo := <-confSent: case confInfo := <-confIntent.Confirmed:
// Finally, we'll verify that the tx index returned is the exact same // Finally, we'll verify that the tx index returned is the exact same
// as the tx index of the transaction within the block itself. // as the tx index of the transaction within the block itself.
msgBlock, err := miner.Node.GetBlock(blockHash[0]) msgBlock, err := miner.Node.GetBlock(blockHash[0])
@ -616,13 +596,8 @@ func testTxConfirmedBeforeNtfnRegistration(miner *rpctest.Harness,
t.Fatalf("unable to generate blocks: %v", err) t.Fatalf("unable to generate blocks: %v", err)
} }
confSent = make(chan *chainntnfs.TxConfirmation)
go func() {
confSent <- <-confIntent.Confirmed
}()
select { select {
case <-confSent: case <-confIntent.Confirmed:
break break
case <-time.After(30 * time.Second): case <-time.After(30 * time.Second):
t.Fatalf("confirmation notification never received") t.Fatalf("confirmation notification never received")