Skip to content

Commit b08247a

Browse files
committed
autogenerate-rpc-examples.py: ensure blockheights are consistent.
This makes our transaction generation (nlocktime) consistent, as well as our htlcs for payment. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent fe5cb3b commit b08247a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/autogenerate-rpc-examples.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def setup_test_nodes(node_factory, bitcoind, regenerate_blockchain):
138138
p2sh_wrapped_addr = '2N2V4ee2vMkiXe5FSkRqFjQhiS9hKqNytv3'
139139
update_example(node=l1, method='upgradewallet', params={})
140140
txid = bitcoind.send_and_mine_block(p2sh_wrapped_addr, 20000000)
141+
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
141142
l1.daemon.wait_for_log('Owning output .* txid {} CONFIRMED'.format(txid))
142143
# Doing it with 'reserved ok' should have 1. We use a big feerate so we can get over the RBF hump
143144
update_example(node=l1, method='upgradewallet', params={'feerate': 'urgent', 'reservedok': True})
@@ -153,10 +154,14 @@ def setup_test_nodes(node_factory, bitcoind, regenerate_blockchain):
153154
l3.rpc.connect(l4.info['id'], 'localhost', l4.port)
154155
l2.rpc.connect(l5.info['id'], 'localhost', l5.port)
155156
c12, c12res = l1.fundchannel(l2, FUND_CHANNEL_AMOUNT_SAT)
157+
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
156158
c23, c23res = l2.fundchannel(l3, FUND_CHANNEL_AMOUNT_SAT)
159+
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
157160
c34, c34res = l3.fundchannel(l4, FUND_CHANNEL_AMOUNT_SAT)
161+
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
158162
c25, c25res = l2.fundchannel(l5, announce_channel=False)
159163
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
164+
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
160165
l1.wait_channel_active(c12)
161166
l1.wait_channel_active(c23)
162167
l1.wait_channel_active(c34)
@@ -1056,10 +1061,12 @@ def get_hsm_secret(n):
10561061
raise
10571062

10581063

1059-
def generate_list_examples(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22):
1064+
def generate_list_examples(bitcoind, l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22):
10601065
"""Generates lists rpc examples"""
10611066
try:
10621067
logger.info('Lists Start...')
1068+
# Make sure all nodes are caught up.
1069+
sync_blockheight(bitcoind, [l1, l2, l3])
10631070
# Transactions Lists
10641071
listfunds_res1 = l1.rpc.listfunds()
10651072
update_example(node=l1, method='listfunds', params={}, response=listfunds_res1)
@@ -1251,7 +1258,7 @@ def list_missing_examples():
12511258
generate_channels_examples(node_factory, bitcoind, l1, l3, l4, l5, regenerate_blockchain)
12521259
generate_autoclean_delete_examples(l1, l2, l3, l4, l5, c12, c23)
12531260
generate_backup_recovery_examples(node_factory, l4, l5, l6, regenerate_blockchain)
1254-
generate_list_examples(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22)
1261+
generate_list_examples(bitcoind, l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22)
12551262
update_examples_in_schema_files()
12561263
logger.info('All Done!!!')
12571264
except Exception as e:

0 commit comments

Comments
 (0)