forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
funding: remove dead code and sanity check pending chan ID (lightning…
…network#7887) * funding: remove unused field `newChanBarriers` This commit removes the occurance of `newChanBarriers` as it's not used anywhere. * funding: rename method names to clear the funding flow Slightly refactored the names so it's easier to see which side is processing what messages. * lnwallet: sanity check empty pending channel ID This commit adds a sanity check to make sure an empty pending channel ID will not be accepted.
- Loading branch information
1 parent
80bfd17
commit ec2377d
Showing
4 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package lnwallet | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestRegisterFundingIntent checks RegisterFundingIntent behaves as expected. | ||
func TestRegisterFundingIntent(t *testing.T) { | ||
t.Parallel() | ||
|
||
require := require.New(t) | ||
|
||
// Create a testing wallet. | ||
lw, err := NewLightningWallet(Config{}) | ||
require.NoError(err) | ||
|
||
// Init an empty testing channel ID. | ||
var testID [32]byte | ||
|
||
// Call the method with empty ID should give us an error. | ||
err = lw.RegisterFundingIntent(testID, nil) | ||
require.ErrorIs(err, ErrEmptyPendingChanID) | ||
|
||
// Modify the ID and call the method again should result in no error. | ||
testID[0] = 1 | ||
err = lw.RegisterFundingIntent(testID, nil) | ||
require.NoError(err) | ||
|
||
// Call the method using the same ID should give us an error. | ||
err = lw.RegisterFundingIntent(testID, nil) | ||
require.ErrorIs(err, ErrDuplicatePendingChanID) | ||
} |