MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_rbf_reconnect_tx_construct

Function test_rbf_reconnect_tx_construct

tests/test_opening.py:1039–1160  ·  view source on GitHub ↗
(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

1037@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
1038@pytest.mark.openchannel('v2')
1039def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
1040 disconnects = ['=WIRE_TX_ADD_INPUT', # Initial funding succeeds
1041 '-WIRE_TX_ADD_INPUT',
1042 '+WIRE_TX_ADD_INPUT',
1043 '-WIRE_TX_ADD_OUTPUT',
1044 '+WIRE_TX_ADD_OUTPUT',
1045 '-WIRE_TX_COMPLETE',
1046 '+WIRE_TX_COMPLETE',
1047 '-WIRE_COMMITMENT_SIGNED',
1048 '+WIRE_COMMITMENT_SIGNED']
1049
1050 l1, l2 = node_factory.get_nodes(2,
1051 opts=[{'disconnect': disconnects,
1052 'may_reconnect': True,
1053 'dev-no-reconnect': None},
1054 {'may_reconnect': True,
1055 'dev-no-reconnect': None,
1056 'broken_log': 'dualopend daemon died before signed PSBT returned'}])
1057
1058 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1059 amount = 2**24
1060 chan_amount = 100000
1061 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['p2tr'], amount / 10**8 + 0.01)
1062 bitcoind.generate_block(1)
1063 # Wait for it to arrive.
1064 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
1065
1066 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
1067 chan_id = res['channel_id']
1068 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
1069 assert(only_one(vins))
1070 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
1071
1072 # Check that we're waiting for lockin
1073 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
1074
1075 # rbf the lease with a higher amount
1076 rate = int(find_next_feerate(l1, l2)[:-5])
1077 # We 4x the feerate to beat the min-relay fee
1078 next_feerate = '{}perkw'.format(rate * 4)
1079
1080 # Initiate an RBF
1081 startweight = 42 + 172 # base weight, funding output
1082 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
1083 prev_utxos, reservedok=True,
1084 excess_as_change=True)
1085
1086 # Run through TX_ADD wires
1087 for d in disconnects[1:-4]:
1088 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1089 with pytest.raises(RpcError):
1090 l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
1091 wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] is False)
1092
1093 # The first TX_COMPLETE breaks
1094 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1095 bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
1096 with pytest.raises(RpcError):

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
find_next_feerateFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
utxopsbtMethod · 0.80
openchannel_bumpMethod · 0.80
openchannel_updateMethod · 0.80
wait_for_logsMethod · 0.80
listpeerchannelsMethod · 0.80
is_in_logMethod · 0.80

Tested by

no test coverage detected