Merge pull request #7126 from yyforyongyu/temp-fix-itest

itest+funding: decrease sleep time and add a temporary fix for itest
This commit is contained in:
Olaoluwa Osuntokun
2022-11-10 16:53:44 -08:00
committed by GitHub
5 changed files with 33 additions and 4 deletions

View File

@@ -149,8 +149,8 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100).
so that the user can specify fees during channel creation time in addition
to the default configuration.
* [Sleep for one second when funding locked message is not
received](https://github.com/lightningnetwork/lnd/pull/7095) to avoid CPU
* [Sleep for 10ms when funding locked message is not
received](https://github.com/lightningnetwork/lnd/pull/7126) to avoid CPU
spike.
## Code Health

11
funding/config_rpctest.go Normal file
View File

@@ -0,0 +1,11 @@
//go:build rpctest
package funding
import "time"
func init() {
// For itest, we will use a much shorter checking interval here as
// local communications are very fast.
checkPeerFundingLockInterval = 10 * time.Millisecond
}

View File

@@ -39,6 +39,13 @@ var (
// byteOrder defines the endian-ness we use for encoding to and from
// buffers.
byteOrder = binary.BigEndian
// checkPeerFundingLockInterval is used when we are waiting for the
// peer to send us FundingLocked. We will check every 1 second to see
// if the message is received.
//
// NOTE: for itest, this value is changed to 10ms.
checkPeerFundingLockInterval = 1 * time.Second
)
// WriteOutpoint writes an outpoint to an io.Writer. This is not the same as
@@ -1022,9 +1029,9 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
if !received {
// We haven't received FundingLocked, so we'll continue
// to the next iteration of the loop after sleeping for
// one second.
// checkPeerFundingLockInterval.
select {
case <-time.After(1 * time.Second):
case <-time.After(checkPeerFundingLockInterval):
case <-f.quit:
return ErrFundingManagerShuttingDown
}

View File

@@ -90,6 +90,13 @@ func openChannelAndAssert(t *harnessTest, net *lntest.NetworkHarness,
"unable to assert channel existence",
)
// They should also notice this channel from topology subscription.
err = alice.WaitForNetworkChannelOpen(fundingChanPoint)
require.NoError(t.t, err)
err = bob.WaitForNetworkChannelOpen(fundingChanPoint)
require.NoError(t.t, err)
return fundingChanPoint
}

View File

@@ -739,6 +739,10 @@ func testUpdateChannelPolicyForPrivateChannel(net *lntest.NetworkHarness,
)
defer closeChannelAndAssert(t, net, net.Bob, chanPointBobCarol, false)
// Carol should be aware of the channel between Alice and Bob.
err = carol.WaitForNetworkChannelOpen(chanPointAliceBob)
require.NoError(t.t, err)
// Get Bob's funding point.
bobChanTXID, err := lnrpc.GetChanPointFundingTxid(chanPointBobCarol)
require.NoError(t.t, err, "unable to get txid")