lnwallet: ensure the goroutines of all channels are stopped after test execution

This commit is contained in:
Olaoluwa Osuntokun 2017-09-24 20:20:10 -07:00
parent 9164cc218a
commit 21d151d2ce
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 12 additions and 5 deletions

@ -3120,6 +3120,8 @@ func (lc *LightningChannel) ReceiveHTLCSettle(preimage [32]byte, logIndex uint64
// entry which will remove the target log entry within the next commitment
// update. This method is intended to be called in order to cancel in
// _incoming_ HTLC.
//
// TODO(roasbeef): add value as well?
func (lc *LightningChannel) FailHTLC(rHash [32]byte) (uint64, error) {
lc.Lock()
defer lc.Unlock()

@ -133,6 +133,8 @@ func (m *mockNotfier) Stop() error {
func (m *mockNotfier) RegisterSpendNtfn(outpoint *wire.OutPoint, heightHint uint32) (*chainntnfs.SpendEvent, error) {
return &chainntnfs.SpendEvent{
Spend: make(chan *chainntnfs.SpendDetail),
Cancel: func() {
},
}, nil
}
@ -330,11 +332,6 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
Db: dbBob,
}
cleanUpFunc := func() {
os.RemoveAll(bobPath)
os.RemoveAll(alicePath)
}
aliceSigner := &mockSigner{aliceKeyPriv}
bobSigner := &mockSigner{bobKeyPriv}
@ -351,6 +348,14 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
return nil, nil, nil, err
}
cleanUpFunc := func() {
os.RemoveAll(bobPath)
os.RemoveAll(alicePath)
channelAlice.Stop()
channelBob.Stop()
}
// Now that the channel are open, simulate the start of a session by
// having Alice and Bob extend their revocation windows to each other.
err = initRevocationWindows(channelAlice, channelBob, revocationWindow)