Add some funds, fund a channel without enough funds
(node_factory, bitcoind)
| 1113 | @pytest.mark.openchannel('v1') |
| 1114 | @pytest.mark.openchannel('v2') |
| 1115 | def test_funding_fail(node_factory, bitcoind): |
| 1116 | """Add some funds, fund a channel without enough funds""" |
| 1117 | max_locktime = 2016 |
| 1118 | l1 = node_factory.get_node() |
| 1119 | l2 = node_factory.get_node(options={'watchtime-blocks': max_locktime + 1}) |
| 1120 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 1121 | |
| 1122 | funds = 1000000 |
| 1123 | |
| 1124 | addr = l1.rpc.newaddr('bech32')['bech32'] |
| 1125 | l1.bitcoin.rpc.sendtoaddress(addr, funds / 10**8) |
| 1126 | bitcoind.generate_block(1) |
| 1127 | |
| 1128 | # Wait for it to arrive. |
| 1129 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) |
| 1130 | |
| 1131 | # Fail because l1 dislikes l2's huge locktime. |
| 1132 | with pytest.raises(RpcError, match=r'to_self_delay \d+ larger than \d+'): |
| 1133 | l1.rpc.fundchannel(l2.info['id'], int(funds / 10)) |
| 1134 | |
| 1135 | # channels do not disconnect on failure |
| 1136 | only_one(l1.rpc.listpeers()['peers']) |
| 1137 | only_one(l2.rpc.listpeers()['peers']) |
| 1138 | |
| 1139 | # Restart l2 without ridiculous locktime. |
| 1140 | del l2.daemon.opts['watchtime-blocks'] |
| 1141 | l2.restart() |
| 1142 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 1143 | wait_for(lambda: [p['connected'] for p in l2.rpc.listpeers()['peers']] == [True]) |
| 1144 | |
| 1145 | # We don't have enough left to cover fees if we try to spend it all. |
| 1146 | with pytest.raises(RpcError, match=r'not afford'): |
| 1147 | l1.rpc.fundchannel(l2.info['id'], funds) |
| 1148 | |
| 1149 | # Should still be connected (we didn't contact the peer) |
| 1150 | assert only_one(l1.rpc.listpeers()['peers'])['connected'] |
| 1151 | |
| 1152 | # This works. |
| 1153 | l1.rpc.fundchannel(l2.info['id'], int(funds / 10)) |
| 1154 | |
| 1155 | |
| 1156 | @pytest.mark.openchannel('v1') |
nothing calls this directly
no test coverage detected