test: fix basic funding integration test flakiness

This commit fixes some flakiness exhibited in the current basic funding
workflow tests. This test can fail occasionally in resource constrained
environment due to a race condition which arises after Alice learns of
the channel, but Bob is still waiting for Alice’s notification. As a
temporary fix, we now only check Alice’s state for the existence of the
channel.
This commit is contained in:
Olaoluwa Osuntokun 2016-09-06 12:04:08 -07:00
parent 803b66fd6d
commit d764493d25
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 17 additions and 38 deletions

@ -65,8 +65,11 @@ func testBasicChannelFunding(net *networkHarness, t *testing.T) {
// The channel should be listed in the peer information returned by
// both peers.
err = net.AssertChannelExists(ctxb, net.AliceClient, net.BobClient,
fundingChanPoint)
chanPoint := wire.OutPoint{
Hash: *fundingTxID,
Index: fundingChanPoint.OutputIndex,
}
err = net.AssertChannelExists(ctxb, net.AliceClient, &chanPoint)
if err != nil {
t.Fatalf("unable to assert channel existence: %v", err)
}

@ -11,7 +11,6 @@ import (
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"time"
@ -585,48 +584,25 @@ func (n *networkHarness) WaitForChannelClose(closeChanStream lnrpc.Lightning_Clo
}
// AssertChannelExists asserts that an active channel identified by
// channelPoint exists between nodeA and nodeB.
func (n *networkHarness) AssertChannelExists(ctx context.Context, nodeA, nodeB lnrpc.LightningClient,
channelPoint *lnrpc.ChannelPoint) error {
// channelPoint is known to exist from the point-of-view of node..
func (n *networkHarness) AssertChannelExists(ctx context.Context,
node lnrpc.LightningClient, chanPoint *wire.OutPoint) error {
// TODO(roasbeef): remove and use "listchannels" command after
// implemented. Also make logic below more generic after addition of
// the RPC.
req := &lnrpc.ListPeersRequest{}
alicePeerInfo, err := nodeA.ListPeers(ctx, req)
peerInfo, err := node.ListPeers(ctx, req)
if err != nil {
return fmt.Errorf("unable to list nodeA peers: %v", err)
}
bobPeerInfo, err := nodeB.ListPeers(ctx, req)
if err != nil {
return fmt.Errorf("unable to list nodeB peers: %v", err)
}
aliceChannels := alicePeerInfo.Peers[0].Channels
if len(aliceChannels) < 1 {
return fmt.Errorf("alice should have an active channel, instead have %v",
len(aliceChannels))
}
bobChannels := bobPeerInfo.Peers[0].Channels
if len(bobChannels) < 1 {
return fmt.Errorf("bob should have an active channel, instead have %v",
len(bobChannels))
for _, peer := range peerInfo.Peers {
for _, channel := range peer.Channels {
if channel.ChannelPoint == chanPoint.String() {
return nil
}
}
}
txid, err := wire.NewShaHash(channelPoint.FundingTxid)
if err != nil {
return err
}
aliceTxID := alicePeerInfo.Peers[0].Channels[0].ChannelPoint
bobTxID := bobPeerInfo.Peers[0].Channels[0].ChannelPoint
if !strings.Contains(bobTxID, txid.String()) {
return fmt.Errorf("alice's channel not found")
}
if !strings.Contains(aliceTxID, txid.String()) {
return fmt.Errorf("bob's channel not found")
}
return nil
return fmt.Errorf("channel not found")
}
// initRpcClient attempts to make an rpc connection, then create a gRPC client