peer: fix unit test flake

This commit is contained in:
yyforyongyu 2023-10-13 00:00:46 +08:00
parent 939375f1a5
commit 839b6271e5
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868

View file

@ -1267,18 +1267,6 @@ func TestHandleRemovePendingChannel(t *testing.T) {
chanIDNotExist := lnwire.ChannelID{1}
chanIDPending := lnwire.ChannelID{2}
// Create a test brontide.
dummyConfig := Config{}
peer := NewBrontide(dummyConfig)
// Create the test state.
peer.activeChannels.Store(chanIDActive, &lnwallet.LightningChannel{})
peer.activeChannels.Store(chanIDPending, nil)
// Assert test state, we should have two channels store, one active and
// one pending.
require.Equal(t, 2, peer.activeChannels.Len())
testCases := []struct {
name string
chanID lnwire.ChannelID
@ -1314,8 +1302,23 @@ func TestHandleRemovePendingChannel(t *testing.T) {
err: errChan,
}
// Create a test brontide.
dummyConfig := Config{}
peer := NewBrontide(dummyConfig)
// Create the test state.
peer.activeChannels.Store(
chanIDActive, &lnwallet.LightningChannel{},
)
peer.activeChannels.Store(chanIDPending, nil)
// Assert test state, we should have two channels store, one
// active and one pending.
require.Equal(t, 2, peer.activeChannels.Len())
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
require := require.New(t)
// Get the number of channels before mutating the