-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[itests] Bitcoind integration test #1583
[itests] Bitcoind integration test #1583
Conversation
d524723
to
19bfc14
Compare
19bfc14
to
0e292f4
Compare
8c78286
to
5b4296a
Compare
lntest/itest/lnd_test.go
Outdated
@@ -14358,7 +14358,7 @@ func TestLightningNetworkDaemon(t *testing.T) { | |||
|
|||
// Next mine enough blocks in order for segwit and the CSV package | |||
// soft-fork to activate on SimNet. | |||
numBlocks := chaincfg.SimNetParams.MinerConfirmationWindow * 2 | |||
numBlocks := chaincfg.RegressionNetParams.MinerConfirmationWindow * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use harnessNetParams
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lntest/btcd.go
Outdated
@@ -76,7 +76,7 @@ func NewBackend(miner string) (*BtcdBackendConfig, func(), error) { | |||
"--logdir=" + logDir, | |||
"--connect=" + miner, | |||
} | |||
netParams := &chaincfg.SimNetParams | |||
netParams := &chaincfg.RegressionNetParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would be nice if this was provided as a function parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lntest/harness.go
Outdated
@@ -389,7 +389,7 @@ func (n *NetworkHarness) RegisterNode(node *HarnessNode) { | |||
func (n *NetworkHarness) connect(ctx context.Context, | |||
req *lnrpc.ConnectPeerRequest, a *HarnessNode) error { | |||
|
|||
syncTimeout := time.After(15 * time.Second) | |||
syncTimeout := time.After(60 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any insights as to why this had to be increased?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because bitcoind
was slower to catch up block hashes IIRC. Since this should be faster now I can try to revert this.
) | ||
|
||
// logDir is the name of the temporary log directory. | ||
const logDir = "./.backendlogs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, this is defined elsewhere already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is re-defined since it is behind a different build flag.
itests look to be failing with an infrequent error? |
2ac4811
to
190a40c
Compare
Should be fixed by d531fd3 |
btw @Roasbeef, any reasons not to switch to regtest also for |
Did a couple more travis runs and found the following flakes:
|
Tracked down the failures above and they should be resolved with the following patch: diff --git a/lntest/bitcoind.go b/lntest/bitcoind.go
index dd0cc5e9..3e7c1d35 100644
--- a/lntest/bitcoind.go
+++ b/lntest/bitcoind.go
@@ -102,6 +102,7 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
"-datadir="+tempBitcoindDir,
"-regtest",
"-txindex",
+ "-debug",
"-whitelist=127.0.0.1", // whitelist localhost to speed up relay
"-rpcauth=weks:469e9bb14ab2360f8e226efed5ca6f"+
"d$507c670e800a95284294edb5773b05544b"+
diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go
index 85212435..c2f9e5ab 100644
--- a/lntest/itest/lnd_test.go
+++ b/lntest/itest/lnd_test.go
@@ -10004,19 +10004,13 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
// We'll mine defaultCSV blocks in order to generate the sweep
// transaction of Bob's funding output. This will also bring us to the
- // maturity height of the htlc tx output.
+ // maturity height of the htlc tx output, so we should expect to see
+ // both transactions in the mempool.
if _, err := net.Miner.Node.Generate(defaultCSV); err != nil {
t.Fatalf("unable to generate blocks: %v", err)
}
- _, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
- if err != nil {
- t.Fatalf("unable to find bob's funding output sweep tx: %v", err)
- }
-
- // The second layer HTLC timeout transaction should now have been
- // broadcast on-chain.
- secondLayerHash, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
+ txids, err := waitForNTxsInMempool(net.Miner.Node, 2, minerMempoolTimeout)
if err != nil {
t.Fatalf("unable to find bob's second layer transaction")
}
@@ -10045,12 +10039,14 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
// Now we'll mine an additional block, which should include the second
// layer sweep tx.
- block := mineBlocks(t, net, 1, 1)[0]
+ block := mineBlocks(t, net, 1, 2)[0]
// The block should have confirmed Bob's second layer sweeping
// transaction. Therefore, at this point, there should be no active
// HTLC's on the commitment transaction from Alice -> Bob.
- assertTxInBlock(t, block, secondLayerHash)
+ for _, txid := range txids {
+ assertTxInBlock(t, block, txid)
+ }
nodes = []*lntest.HarnessNode{net.Alice}
err = lntest.WaitPredicate(func() bool {
predErr = assertNumActiveHtlcs(nodes, 0)
|
@wpaulino so the flakes weren't fundamental to |
Correct. Things seem to be slower with bitcoind, likely due to the several HTTP requests made. The patch above solves an incorrect assumption within the test itself. We should expect both bob's commit sweep and HTLC timeout transactions in the mempool before proceeding. Without the patch we'd only wait for one of these twice, causing us to proceed with further assumptions that rely on this one. |
This PR should now be rebased on top of #3434 in order to address the flake pointed out above. |
190a40c
to
f5b5fd4
Compare
…annel Otherwise following tests would be flaky because of unexpected sweep transaction in the mempool.
Co-authored-by: Wilmer Paulino <wilmer.paulino@gmail.com>
f5b5fd4
to
c3480c6
Compare
The local timeout could be too short for certain backends.
Looks good after rebase on #3434 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⚡️
"bitcoind", | ||
"-datadir="+tempBitcoindDir, | ||
"-regtest", | ||
"-txindex", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we run without this? Would ensure that the fallback path (no txindex, scan manually) is tested instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could run it with both options, though this would significantly increase the running time of the current integration tests. On the other hand, we properly test both variants in the unit tests of the notifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could randomize it lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🖌
This PR enables the
bitcoind
backend for integration tests.