funding: check error to avoid panic during test
This commit, the error returned from `getInitialFwdingPolicy` is checked in order to avoid a nil pointer dereference panic during the TestFundingManagerCustomChannelParameters test.
This commit is contained in:
3 files changed
+14
-12
No files matched your search
+1
-4
@@ -4439,10 +4439,7 @@ func (f *Manager) getInitialFwdingPolicy(permChanID lnwire.ChannelID) (
|
||||
chanID := make([]byte, 32)
|
||||
copy(chanID, permChanID[:])
|
||||
|
||||
value, err := f.cfg.Wallet.Cfg.Database.GetInitialFwdingPolicy(
|
||||
chanID,
|
||||
)
|
||||
|
||||
value, err := f.cfg.Wallet.Cfg.Database.GetInitialFwdingPolicy(chanID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+10
-8
@@ -3082,15 +3082,17 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) {
|
||||
|
||||
// After the funding is sigend and before the channel announcement
|
||||
// we expect Alice and Bob to store their respective fees in the database.
|
||||
forwardingPolicy, _ := alice.fundingMgr.getInitialFwdingPolicy(fundingSigned.ChanID)
|
||||
if err := assertFees(forwardingPolicy, 42, 1337); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
forwardingPolicy, err := alice.fundingMgr.getInitialFwdingPolicy(
|
||||
fundingSigned.ChanID,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, assertFees(forwardingPolicy, 42, 1337))
|
||||
|
||||
forwardingPolicy, _ = bob.fundingMgr.getInitialFwdingPolicy(fundingSigned.ChanID)
|
||||
if err := assertFees(forwardingPolicy, 100, 1000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
forwardingPolicy, err = bob.fundingMgr.getInitialFwdingPolicy(
|
||||
fundingSigned.ChanID,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, assertFees(forwardingPolicy, 100, 1000))
|
||||
|
||||
// Wait for Alice to published the funding tx to the network.
|
||||
var fundingTx *wire.MsgTx
|
||||
|
||||
Reference in new issue
Block a user