(node_factory, bitcoind, chainparams)
| 22 | |
| 23 | @pytest.mark.developer("Too slow without --dev-bitcoind-poll") |
| 24 | def test_closing_simple(node_factory, bitcoind, chainparams): |
| 25 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 26 | l1, l2 = node_factory.line_graph(2, opts={'plugin': coin_mvt_plugin}) |
| 27 | chan = l1.get_channel_scid(l2) |
| 28 | channel_id = first_channel_id(l1, l2) |
| 29 | fee = closing_fee(3750, 2) if not chainparams['elements'] else 4263 |
| 30 | |
| 31 | l1.pay(l2, 200000000) |
| 32 | |
| 33 | assert bitcoind.rpc.getmempoolinfo()['size'] == 0 |
| 34 | |
| 35 | billboard = only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status'] |
| 36 | assert billboard == ['CHANNELD_NORMAL:Channel ready for use.'] |
| 37 | billboard = only_one(l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'])['status'] |
| 38 | assert billboard == ['CHANNELD_NORMAL:Channel ready for use.'] |
| 39 | |
| 40 | bitcoind.generate_block(5) |
| 41 | |
| 42 | wait_for(lambda: len(l1.getactivechannels()) == 2) |
| 43 | wait_for(lambda: len(l2.getactivechannels()) == 2) |
| 44 | billboard = only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status'] |
| 45 | # This may either be from a local_update or an announce, so just |
| 46 | # check for the substring |
| 47 | assert 'CHANNELD_NORMAL:Channel ready for use.' in billboard[0] |
| 48 | |
| 49 | l1.rpc.close(chan) |
| 50 | |
| 51 | l1.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN') |
| 52 | l2.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN') |
| 53 | |
| 54 | l1.daemon.wait_for_log(' to CLOSINGD_SIGEXCHANGE') |
| 55 | l2.daemon.wait_for_log(' to CLOSINGD_SIGEXCHANGE') |
| 56 | |
| 57 | # And should put closing into mempool. |
| 58 | l1.daemon.wait_for_log('sendrawtx exit 0') |
| 59 | l2.daemon.wait_for_log('sendrawtx exit 0') |
| 60 | |
| 61 | # Both nodes should have disabled the channel in their view |
| 62 | wait_for(lambda: len(l1.getactivechannels()) == 0) |
| 63 | wait_for(lambda: len(l2.getactivechannels()) == 0) |
| 64 | |
| 65 | assert bitcoind.rpc.getmempoolinfo()['size'] == 1 |
| 66 | |
| 67 | # Now grab the close transaction |
| 68 | closetxid = only_one(bitcoind.rpc.getrawmempool(False)) |
| 69 | |
| 70 | billboard = only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status'] |
| 71 | assert billboard == [ |
| 72 | 'CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of {} satoshi for tx:{}'.format(fee, closetxid), |
| 73 | ] |
| 74 | bitcoind.generate_block(1) |
| 75 | |
| 76 | l1.daemon.wait_for_log(r'Owning output.* \(SEGWIT\).* txid %s.* CONFIRMED' % closetxid) |
| 77 | l2.daemon.wait_for_log(r'Owning output.* \(SEGWIT\).* txid %s.* CONFIRMED' % closetxid) |
| 78 | |
| 79 | # Make sure both nodes have grabbed their close tx funds |
| 80 | assert closetxid in set([o['txid'] for o in l1.rpc.listfunds()['outputs']]) |
| 81 | assert closetxid in set([o['txid'] for o in l2.rpc.listfunds()['outputs']]) |
nothing calls this directly
no test coverage detected