mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 17:56:25 +02:00
Merge pull request #8180 from carlaKC/8128-brontideflake
peer/test: fix race in TestHandleNewPendingChannel
This commit is contained in:
@@ -1183,18 +1183,6 @@ func TestHandleNewPendingChannel(t *testing.T) {
|
|||||||
chanIDNotExist := lnwire.ChannelID{1}
|
chanIDNotExist := lnwire.ChannelID{1}
|
||||||
chanIDPending := lnwire.ChannelID{2}
|
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 {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
chanID lnwire.ChannelID
|
chanID lnwire.ChannelID
|
||||||
@@ -1234,9 +1222,22 @@ func TestHandleNewPendingChannel(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
// Get the number of channels before mutating the
|
// Create a test brontide.
|
||||||
// state.
|
dummyConfig := Config{}
|
||||||
numChans := peer.activeChannels.Len()
|
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.
|
// Call the method.
|
||||||
peer.handleNewPendingChannel(req)
|
peer.handleNewPendingChannel(req)
|
||||||
|
Reference in New Issue
Block a user