From 162dac1271f769082bc9efecde3273cf8a33b9bf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 5 May 2017 16:11:46 +0930 Subject: [PATCH] peer_control: don't complete fundchannel command until broadcast. Under stress, the tests can mine blocks too soon, and the funding never locks. This gives more of a chance, at least. Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 9 +++++---- tests/test_lightningd.py | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 7bc907f11..8434a89f7 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -606,10 +606,6 @@ static bool opening_got_hsm_funding_sig(struct subd *hsm, const u8 *resp, tal_count(sigs), tal_count(tx->input)); peer_set_condition(fc->peer, "Waiting for our funding tx"); - /* FIXME: Defer until after funding locked. */ - tal_del_destructor(fc, fail_fundchannel_command); - command_success(fc->cmd, null_response(fc->cmd)); - fc->cmd = NULL; /* Create input parts from signatures. */ for (i = 0; i < tal_count(tx->input); i++) { @@ -629,6 +625,11 @@ static bool opening_got_hsm_funding_sig(struct subd *hsm, const u8 *resp, broadcast_tx(hsm->ld->topology, fc->peer, tx, funding_broadcast_failed); watch_tx(fc->peer, fc->peer->ld->topology, fc->peer, tx, funding_depth_cb, NULL); + + /* We could defer until after funding locked, but makes testing + * harder. */ + tal_del_destructor(fc, fail_fundchannel_command); + command_success(fc->cmd, null_response(fc->cmd)); tal_free(fc); return true; } diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index fb21314df..6b584a008 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -148,6 +148,8 @@ class LightningDTests(BaseLightningDTests): l1.rpc.addfunds(tx) l1.rpc.fundchannel(l2.info['id'], amount) + # Technically, this is async to fundchannel. + l1.daemon.wait_for_log('sendrawtx exit 0') l1.bitcoin.rpc.generate(6)