fundingmanager test: satisfy new interfaces

This commit is contained in:
Johan T. Halseth 2018-09-26 11:12:57 +02:00
parent b712b861f8
commit a433e70575
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -178,13 +178,13 @@ func (n *testNode) QuitSignal() <-chan struct{} {
return n.shutdownChannel return n.shutdownChannel
} }
func (n *testNode) AddNewChannel(channel *lnwallet.LightningChannel, func (n *testNode) AddNewChannel(channel *channeldb.OpenChannel,
quit <-chan struct{}) error { quit <-chan struct{}) error {
done := make(chan struct{}) errChan := make(chan error)
msg := &newChannelMsg{ msg := &newChannelMsg{
channel: channel, channel: channel,
done: done, err: errChan,
} }
select { select {
@ -194,12 +194,11 @@ func (n *testNode) AddNewChannel(channel *lnwallet.LightningChannel,
} }
select { select {
case <-done: case err := <-errChan:
return err
case <-quit: case <-quit:
return ErrFundingManagerShuttingDown return ErrFundingManagerShuttingDown
} }
return nil
} }
func init() { func init() {
@ -304,7 +303,8 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
return lnwire.NodeAnnouncement{}, nil return lnwire.NodeAnnouncement{}, nil
}, },
TempChanIDSeed: chanIDSeed, TempChanIDSeed: chanIDSeed,
FindChannel: func(chanID lnwire.ChannelID) (*lnwallet.LightningChannel, error) { FindChannel: func(chanID lnwire.ChannelID) (
*channeldb.OpenChannel, error) {
dbChannels, err := cdb.FetchAllChannels() dbChannels, err := cdb.FetchAllChannels()
if err != nil { if err != nil {
return nil, err return nil, err
@ -312,10 +312,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
for _, channel := range dbChannels { for _, channel := range dbChannels {
if chanID.IsChanPoint(&channel.FundingOutpoint) { if chanID.IsChanPoint(&channel.FundingOutpoint) {
return lnwallet.NewLightningChannel( return channel, nil
signer,
nil,
channel)
} }
} }
@ -992,14 +989,14 @@ func assertHandleFundingLocked(t *testing.T, alice, bob *testNode) {
// They should both send the new channel state to their peer. // They should both send the new channel state to their peer.
select { select {
case c := <-alice.newChannels: case c := <-alice.newChannels:
close(c.done) close(c.err)
case <-time.After(time.Second * 15): case <-time.After(time.Second * 15):
t.Fatalf("alice did not send new channel to peer") t.Fatalf("alice did not send new channel to peer")
} }
select { select {
case c := <-bob.newChannels: case c := <-bob.newChannels:
close(c.done) close(c.err)
case <-time.After(time.Second * 15): case <-time.After(time.Second * 15):
t.Fatalf("bob did not send new channel to peer") t.Fatalf("bob did not send new channel to peer")
} }