lnd/lntest
Olaoluwa Osuntokun 6cd981420a
lntest: fix possible race condition re asserting channel propagation
In this commit, we attempt to fix a race condition that may occur in the
current AMP and MPP tests.

It appears the following scenario is possible:
  * The `mppTestContext` [is used to create 6 channels back to
    back](https://github.com/lightningnetwork/lnd/blob/master/lntest/itest/lnd_amp_test.go#L43)
  * The method used to create the channel ends up calling
    [`openChannelAndAssert`](edd4152682/lntest/itest/lnd_mpp_test.go (L300))
    which'll open the channel, mine 6 blocks, [then ensure that the
    channel gets
    advertised](edd4152682/lntest/itest/assertions.go (L78))
  * Later on, [we wait for all nodes to hear about all channels on the
    network
    level](https://github.com/lightningnetwork/lnd/blob/master/lntest/itest/lnd_amp_test.go#L62)

I think the issue here is that we'll potentially already have mined 30
or so blocks before getting to the final nodes, and those nodes may have
already heard about the channel already. This may then cause their
[`lightningNetworkWatcher`](edd4152682/lntest/node.go (L1213))
goroutine to not properly dispatch this, since it's assumed that the
channel hasn't been announced (or notified) when the method is called.

One solution here is to just check if the channel is already in the
node's graph or not, when we go to register the notification. If we do
this in the same state machine as the watcher, then we ensure if the
channel is already known, the client is immediately notified. One thing
that can help us debug this more in the future is adding additional
logging in some of these helper goroutines so we can more easily track
the control flow.

This commit implements this solution by checking to ensure that the
channel isn't already known in our channel graph before attempting to
wait for its notification, as we may already have missed the
notification before this registration request came in.
2021-07-14 20:12:00 -07:00
..
channels lntest/channels: introduce subpackage to deduplicate static structs 2021-01-25 14:04:39 -05:00
itest lntest/itest: log node name in addition to ID if waitForChannels fails 2021-07-14 20:11:54 -07:00
mock lntest/mock: set input index on spend event 2021-05-12 12:32:28 +02:00
wait lntest: go easy on goroutines when polling 2020-12-08 21:37:11 +01:00
bitcoind.go lntest: add build flag for disabling txindex on bitcoind 2020-10-09 13:35:04 +02:00
bitcoind_common.go itest: basic failover itest when using leader election on etcd 2021-05-04 17:33:12 +02:00
bitcoind_notxindex.go lntest: add build flag for disabling txindex on bitcoind 2020-10-09 13:35:04 +02:00
btcd.go build: update btcd and btcwallet dependencies 2021-04-05 15:41:04 -07:00
doc.go lntest: Add doc.go with package documentation. 2017-12-14 20:06:23 -08:00
fee_service.go itest: change feeServiceTarget to be 1 2021-06-29 20:25:47 +08:00
fee_service_test.go chainfee: change min conf target to be 1 2021-06-29 20:25:46 +08:00
harness.go itest: add db backend flag 2021-07-05 10:10:02 +02:00
neutrino.go lntest: decrease broadcast timeout for neutrino-backed integration tests 2021-04-29 13:56:19 -07:00
node.go lntest: fix possible race condition re asserting channel propagation 2021-07-14 20:12:00 -07:00
timeouts.go lntest/timeouts: remove spaces from build predicates 2020-11-18 15:16:25 -08:00
timeouts_darwin.go lntest/timeouts: fix darwin+kvdb_etcd build 2020-11-18 15:28:39 -08:00
timeouts_etcd.go lntest/timeouts: fix darwin+kvdb_etcd build 2020-11-18 15:28:39 -08:00