From 0b331a2b606688b1926383ee6f74e38a5e196cc7 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Mon, 16 Apr 2018 11:29:39 +0000 Subject: [PATCH] test_lightningd.py: Clean up some uses of 'close' RPC. --- tests/test_lightningd.py | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index a7d2f95e9..d9acf69c3 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -1333,13 +1333,10 @@ class LightningDTests(BaseLightningDTests): self.pay(l1, p, 100000000) # Now close - for p in peers: - self.assertRaisesRegex(ValueError, - "Channel close negotiation not finished", - l1.rpc.close, p.info['id'], False, 0) + closes = [self.executor.submit(l1.rpc.close, p.info['id']) for p in peers] - for p in peers: - p.daemon.wait_for_log(' to CLOSINGD_COMPLETE') + for c in closes: + c.result(30) bitcoind.generate_block(1) for p in peers: @@ -3935,12 +3932,8 @@ class LightningDTests(BaseLightningDTests): l1.rpc.dev_setfees() l1.daemon.wait_for_log('dev-setfees: fees now 21098/7654/321') - # This should return with an error, then close. - self.assertRaisesRegex(ValueError, - "Channel close negotiation not finished", - l1.rpc.close, l2.info['id'], False, 0) - l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE') - l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE') + # This should return finish closing. + l1.rpc.close(l2.info['id']) @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_fee_limits(self): @@ -3977,12 +3970,8 @@ class LightningDTests(BaseLightningDTests): # 15sat/byte fee l1.daemon.wait_for_log('peer_out WIRE_REVOKE_AND_ACK') - # This should return with an error, then close. - self.assertRaisesRegex(ValueError, - "Channel close negotiation not finished", - l1.rpc.close, l3.info['id'], False, 0) - l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE') - l3.daemon.wait_for_log(' to CLOSINGD_COMPLETE') + # This should wait for close to complete + l1.rpc.close(l3.info['id']) @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_update_fee_reconnect(self): @@ -4011,11 +4000,7 @@ class LightningDTests(BaseLightningDTests): assert l2.daemon.is_in_log('got commitsig [0-9]*: feerate 14000') # Now shutdown cleanly. - self.assertRaisesRegex(ValueError, - "Channel close negotiation not finished", - l1.rpc.close, l2.info['id'], False, 0) - l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE') - l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE') + l1.rpc.close(l2.info['id']) # And should put closing into mempool. l1.daemon.wait_for_log('sendrawtx exit 0') @@ -4149,11 +4134,7 @@ class LightningDTests(BaseLightningDTests): l2.daemon.wait_for_log('Handing back peer .* to master') self.fund_channel(l1, l2, 10**6) - self.assertRaisesRegex(ValueError, - "Channel close negotiation not finished", - l1.rpc.close, l2.info['id'], False, 0) - l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE') - l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE') + l1.rpc.close(l2.info['id']) channels = l1.rpc.listpeers()['peers'][0]['channels'] assert len(channels) == 3