Skip to content

Commit

Permalink
Merge pull request lightningnetwork#8180 from carlaKC/8128-brontideflake
Browse files Browse the repository at this point in the history
peer/test: fix race in TestHandleNewPendingChannel
  • Loading branch information
ellemouton authored Nov 16, 2023
2 parents 5e369a0 + a8a86b2 commit ed179e3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions peer/brontide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,18 +1183,6 @@ func TestHandleNewPendingChannel(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
Expand Down Expand Up @@ -1234,9 +1222,22 @@ func TestHandleNewPendingChannel(t *testing.T) {
t.Parallel()
require := require.New(t)

// Get the number of channels before mutating the
// state.
numChans := peer.activeChannels.Len()
// 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.
numChans := 2
require.EqualValues(
numChans, peer.activeChannels.Len(),
)

// Call the method.
peer.handleNewPendingChannel(req)
Expand Down

0 comments on commit ed179e3

Please sign in to comment.