mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-17 23:30:02 +02:00
Merge pull request #8092 from yyforyongyu/fix-peer-unit-test
multi: fix peer unit test and disable `paralleltest`
This commit is contained in:
commit
b0bb853f77
@ -147,6 +147,7 @@ linters:
|
|||||||
- deadcode
|
- deadcode
|
||||||
- nosnakecase
|
- nosnakecase
|
||||||
|
|
||||||
|
|
||||||
# Disable gofumpt as it has weird behavior regarding formatting multiple
|
# Disable gofumpt as it has weird behavior regarding formatting multiple
|
||||||
# lines for a function which is in conflict with our contribution
|
# lines for a function which is in conflict with our contribution
|
||||||
# guidelines. See https://github.com/mvdan/gofumpt/issues/235.
|
# guidelines. See https://github.com/mvdan/gofumpt/issues/235.
|
||||||
@ -201,6 +202,10 @@ linters:
|
|||||||
# will also catch magic numbers that make sense to extract.
|
# will also catch magic numbers that make sense to extract.
|
||||||
- gomnd
|
- gomnd
|
||||||
|
|
||||||
|
# Some of the tests cannot be parallelized. On the other hand, we don't
|
||||||
|
# gain much performance with this check so we disable it for now until
|
||||||
|
# unit tests become our CI bottleneck.
|
||||||
|
- paralleltest
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# Only show newly introduced problems.
|
# Only show newly introduced problems.
|
||||||
@ -258,10 +263,6 @@ issues:
|
|||||||
linters:
|
linters:
|
||||||
- forbidigo
|
- forbidigo
|
||||||
|
|
||||||
- path: itest/.*
|
|
||||||
linters:
|
|
||||||
- paralleltest
|
|
||||||
|
|
||||||
- path: lnmock/*
|
- path: lnmock/*
|
||||||
linters:
|
linters:
|
||||||
# forcetypeassert is skipped for the mock because the test would fail
|
# forcetypeassert is skipped for the mock because the test would fail
|
||||||
|
@ -1579,7 +1579,6 @@ func TestFundingManagerNormalWorkflow(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:paralleltest
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.typeName, func(t *testing.T) {
|
t.Run(testCase.typeName, func(t *testing.T) {
|
||||||
testNormalWorkflow(t, testCase.chanType)
|
testNormalWorkflow(t, testCase.chanType)
|
||||||
@ -4747,7 +4746,6 @@ func TestFundingManagerZeroConf(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:paralleltest
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.typeName, func(t *testing.T) {
|
t.Run(testCase.typeName, func(t *testing.T) {
|
||||||
testZeroConf(t, testCase.chanType)
|
testZeroConf(t, testCase.chanType)
|
||||||
|
@ -839,7 +839,7 @@ func TestTaprootReceiverHtlcSpend(t *testing.T) {
|
|||||||
valid: false,
|
valid: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, testCase := range testCases { //nolint:paralleltest
|
for i, testCase := range testCases {
|
||||||
i := i
|
i := i
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
spendTxCopy := spendTx.Copy()
|
spendTxCopy := spendTx.Copy()
|
||||||
@ -1140,7 +1140,7 @@ func TestTaprootCommitScriptToSelf(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases { //nolint:paralleltest
|
for i, testCase := range testCases {
|
||||||
i := i
|
i := i
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
spendTxCopy := spendTx.Copy()
|
spendTxCopy := spendTx.Copy()
|
||||||
@ -1317,7 +1317,7 @@ func TestTaprootCommitScriptRemote(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases { //nolint:paralleltest
|
for i, testCase := range testCases {
|
||||||
i := i
|
i := i
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
spendTxCopy := spendTx.Copy()
|
spendTxCopy := spendTx.Copy()
|
||||||
@ -1536,7 +1536,7 @@ func TestTaprootAnchorScript(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases { //nolint:paralleltest
|
for i, testCase := range testCases {
|
||||||
i := i
|
i := i
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
spendTxCopy := spendTx.Copy()
|
spendTxCopy := spendTx.Copy()
|
||||||
@ -1833,7 +1833,7 @@ func TestTaprootSecondLevelHtlcScript(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases { //nolint:paralleltest
|
for i, testCase := range testCases {
|
||||||
i := i
|
i := i
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
spendTxCopy := spendTx.Copy()
|
spendTxCopy := spendTx.Copy()
|
||||||
|
@ -371,7 +371,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("anchors", func(t *testing.T) { //nolint:paralleltest
|
t.Run("anchors", func(t *testing.T) {
|
||||||
testAddSettleWorkflow(
|
testAddSettleWorkflow(
|
||||||
t, true,
|
t, true,
|
||||||
channeldb.AnchorOutputsBit|channeldb.ZeroHtlcTxFeeBit,
|
channeldb.AnchorOutputsBit|channeldb.ZeroHtlcTxFeeBit,
|
||||||
@ -379,13 +379,12 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("taproot", func(t *testing.T) { //nolint:paralleltest
|
t.Run("taproot", func(t *testing.T) {
|
||||||
testAddSettleWorkflow(
|
testAddSettleWorkflow(
|
||||||
t, true, channeldb.SimpleTaprootFeatureBit, false,
|
t, true, channeldb.SimpleTaprootFeatureBit, false,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
//nolint:paralleltest
|
|
||||||
t.Run("storeFinalHtlcResolutions=true", func(t *testing.T) {
|
t.Run("storeFinalHtlcResolutions=true", func(t *testing.T) {
|
||||||
testAddSettleWorkflow(t, false, 0, true)
|
testAddSettleWorkflow(t, false, 0, true)
|
||||||
})
|
})
|
||||||
@ -819,7 +818,7 @@ func TestForceClose(t *testing.T) {
|
|||||||
anchorAmt: anchorSize * 2,
|
anchorAmt: anchorSize * 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("taproot", func(t *testing.T) { //nolint:paralleltest
|
t.Run("taproot", func(t *testing.T) {
|
||||||
testForceClose(t, &forceCloseTestCase{
|
testForceClose(t, &forceCloseTestCase{
|
||||||
chanType: channeldb.SingleFunderTweaklessBit |
|
chanType: channeldb.SingleFunderTweaklessBit |
|
||||||
channeldb.AnchorOutputsBit |
|
channeldb.AnchorOutputsBit |
|
||||||
@ -3594,10 +3593,10 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
|
|||||||
func TestChanSyncOweRevocation(t *testing.T) {
|
func TestChanSyncOweRevocation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest
|
t.Run("tweakless", func(t *testing.T) {
|
||||||
testChanSyncOweRevocation(t, channeldb.SingleFunderTweaklessBit)
|
testChanSyncOweRevocation(t, channeldb.SingleFunderTweaklessBit)
|
||||||
})
|
})
|
||||||
t.Run("taproot", func(t *testing.T) { //nolint:paralleltest
|
t.Run("taproot", func(t *testing.T) {
|
||||||
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
||||||
channeldb.AnchorOutputsBit |
|
channeldb.AnchorOutputsBit |
|
||||||
channeldb.ZeroHtlcTxFeeBit |
|
channeldb.ZeroHtlcTxFeeBit |
|
||||||
@ -3777,12 +3776,12 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
|
|||||||
func TestChanSyncOweRevocationAndCommit(t *testing.T) {
|
func TestChanSyncOweRevocationAndCommit(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest
|
t.Run("tweakless", func(t *testing.T) {
|
||||||
testChanSyncOweRevocationAndCommit(
|
testChanSyncOweRevocationAndCommit(
|
||||||
t, channeldb.SingleFunderTweaklessBit,
|
t, channeldb.SingleFunderTweaklessBit,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
t.Run("taproot", func(t *testing.T) { //nolint:paralleltest
|
t.Run("taproot", func(t *testing.T) {
|
||||||
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
||||||
channeldb.AnchorOutputsBit |
|
channeldb.AnchorOutputsBit |
|
||||||
channeldb.ZeroHtlcTxFeeBit |
|
channeldb.ZeroHtlcTxFeeBit |
|
||||||
@ -4006,12 +4005,12 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
|
|||||||
func TestChanSyncOweRevocationAndCommitForceTransition(t *testing.T) {
|
func TestChanSyncOweRevocationAndCommitForceTransition(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest
|
t.Run("tweakless", func(t *testing.T) {
|
||||||
testChanSyncOweRevocationAndCommitForceTransition(
|
testChanSyncOweRevocationAndCommitForceTransition(
|
||||||
t, channeldb.SingleFunderTweaklessBit,
|
t, channeldb.SingleFunderTweaklessBit,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
t.Run("taproot", func(t *testing.T) { //nolint:paralleltest
|
t.Run("taproot", func(t *testing.T) {
|
||||||
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
taprootBits := channeldb.SimpleTaprootFeatureBit |
|
||||||
channeldb.AnchorOutputsBit |
|
channeldb.AnchorOutputsBit |
|
||||||
channeldb.ZeroHtlcTxFeeBit |
|
channeldb.ZeroHtlcTxFeeBit |
|
||||||
|
@ -228,7 +228,7 @@ func TestMusigSesssion(t *testing.T) {
|
|||||||
// commitment, and one for the remote commitment.
|
// commitment, and one for the remote commitment.
|
||||||
muSessions := newMuSessionHarness(t)
|
muSessions := newMuSessionHarness(t)
|
||||||
|
|
||||||
t.Run("session_round_trips", func(t *testing.T) { //nolint:paralleltest
|
t.Run("session_round_trips", func(t *testing.T) {
|
||||||
const numRounds = 10
|
const numRounds = 10
|
||||||
for i := 0; i < numRounds; i++ {
|
for i := 0; i < numRounds; i++ {
|
||||||
// We'll now simulate a full commitment dance.
|
// We'll now simulate a full commitment dance.
|
||||||
@ -262,7 +262,7 @@ func TestMusigSesssion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("no_finalize_error", func(t *testing.T) { //nolint:paralleltest
|
t.Run("no_finalize_error", func(t *testing.T) {
|
||||||
// If a local party attempts to sign for their local commitment
|
// If a local party attempts to sign for their local commitment
|
||||||
// without finalizing first, they'll get this error.
|
// without finalizing first, they'll get this error.
|
||||||
_, err := muSessions.aliceSession.LocalSession.SignCommit(
|
_, err := muSessions.aliceSession.LocalSession.SignCommit(
|
||||||
|
@ -131,7 +131,7 @@ func TestWalletRebroadcaster(t *testing.T) {
|
|||||||
ChainIO: chainIO,
|
ChainIO: chainIO,
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("rebroadcast bypass", func(t *testing.T) { //nolint:paralleltest
|
t.Run("rebroadcast bypass", func(t *testing.T) {
|
||||||
// We'll make a copy of the config, but without the
|
// We'll make a copy of the config, but without the
|
||||||
// broadcaster.
|
// broadcaster.
|
||||||
testCfg := *cfg
|
testCfg := *cfg
|
||||||
@ -166,7 +166,7 @@ func TestWalletRebroadcaster(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("rebroadcast normal", func(t *testing.T) { //nolint:paralleltest
|
t.Run("rebroadcast normal", func(t *testing.T) {
|
||||||
wallet, err := NewLightningWallet(*cfg)
|
wallet, err := NewLightningWallet(*cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, wallet.Startup())
|
require.NoError(t, wallet.Startup())
|
||||||
|
@ -1267,18 +1267,6 @@ func TestHandleRemovePendingChannel(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
|
||||||
@ -1314,8 +1302,23 @@ func TestHandleRemovePendingChannel(t *testing.T) {
|
|||||||
err: errChan,
|
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.Run(tc.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
// Get the number of channels before mutating the
|
// Get the number of channels before mutating the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user