Skip to content

Commit c79a89d

Browse files
committed
pytest: adapt tests to avoid deprecated APIs in close (tx and txid).
Signed-off-by: Rusty Russell <[email protected]>
1 parent 809f3b0 commit c79a89d

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

tests/test_closing.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,8 +3906,8 @@ def test_closing_tx_valid(node_factory, bitcoind):
39063906
close = l1.rpc.close(l2.info['id'])
39073907

39083908
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 1)
3909-
assert only_one(bitcoind.rpc.getrawmempool()) == close['txid']
3910-
assert bitcoind.rpc.getrawtransaction(close['txid']) == close['tx']
3909+
assert only_one(bitcoind.rpc.getrawmempool()) == only_one(close['txids'])
3910+
assert bitcoind.rpc.getrawtransaction(only_one(close['txids'])) == only_one(close['txs'])
39113911
bitcoind.generate_block(1)
39123912
# Change output and the closed channel output.
39133913
wait_for(lambda: [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] * 2)
@@ -3921,8 +3921,8 @@ def test_closing_tx_valid(node_factory, bitcoind):
39213921
close = l1.rpc.close(l2.info['id'], 1)
39223922

39233923
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 1)
3924-
assert only_one(bitcoind.rpc.getrawmempool()) == close['txid']
3925-
assert bitcoind.rpc.getrawtransaction(close['txid']) == close['tx']
3924+
assert only_one(bitcoind.rpc.getrawmempool()) == only_one(close['txids'])
3925+
assert bitcoind.rpc.getrawtransaction(only_one(close['txids'])) == only_one(close['txs'])
39263926

39273927

39283928
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd does not provide feerates on regtest')
@@ -3933,7 +3933,7 @@ def test_closing_minfee(node_factory, bitcoind):
39333933

39343934
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['htlcs'] == [])
39353935

3936-
txid = l1.rpc.close(l2.info['id'])['txid']
3936+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
39373937
bitcoind.generate_block(1, wait_for_mempool=txid)
39383938

39393939

@@ -4014,7 +4014,7 @@ def test_closing_cpfp(node_factory, bitcoind):
40144014
l1.rpc.pay(l2.rpc.invoice(10000000, 'test', 'test')['bolt11'])
40154015

40164016
# Mutual close
4017-
close_txid = l1.rpc.close(l2.info['id'])['txid']
4017+
close_txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
40184018

40194019
l1out = only_one([o for o in l1.rpc.listfunds()['outputs'] if o != change])
40204020
assert l1out['txid'] == close_txid
@@ -4093,7 +4093,7 @@ def test_anchorspend_using_to_remote(node_factory, bitcoind, anchors):
40934093

40944094
l4.rpc.disconnect(l2.info['id'], force=True)
40954095
close = l4.rpc.close(l2.info['id'], 1)
4096-
bitcoind.generate_block(1, wait_for_mempool=close['txid'])
4096+
bitcoind.generate_block(1, wait_for_mempool=only_one(close['txids']))
40974097
wait_for(lambda: len(l2.rpc.listfunds()['outputs']) == 1)
40984098
# Don't need l4 any more
40994099
l4.stop()

tests/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,10 +1683,10 @@ def _close(src, dst, addr=None):
16831683
"""
16841684
r = l1.rpc.close(l2.info['id'], destination=addr)
16851685
assert r['type'] == 'mutual'
1686-
tx = bitcoind.rpc.decoderawtransaction(r['tx'])
1686+
tx = bitcoind.rpc.decoderawtransaction(only_one(r['txs']))
16871687

16881688
addrs = [scriptpubkey_addr(vout['scriptPubKey']) for vout in tx['vout']]
1689-
bitcoind.generate_block(1, wait_for_mempool=[r['txid']])
1689+
bitcoind.generate_block(1, wait_for_mempool=[only_one(r['txids'])])
16901690
sync_blockheight(bitcoind, [l1, l2])
16911691
return addrs
16921692

tests/test_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from fixtures import * # noqa: F401,F403
22
from fixtures import TEST_NETWORK
33
from pyln.client import RpcError
4-
from utils import wait_for, sync_blockheight, COMPAT, TIMEOUT, scid_to_int
4+
from utils import wait_for, sync_blockheight, COMPAT, TIMEOUT, scid_to_int, only_one
55

66
import base64
77
import os
@@ -94,7 +94,7 @@ def test_block_backfill(node_factory, bitcoind, chainparams):
9494
l3.daemon.wait_for_log('seeker: state = NORMAL')
9595

9696
# Now close the channel and make sure `l3` cleans up correctly:
97-
txid = l1.rpc.close(l2.info['id'])['txid']
97+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
9898
bitcoind.generate_block(13, wait_for_mempool=txid)
9999
wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 0)
100100

tests/test_gossip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ def test_gossip_notices_close(node_factory, bitcoind):
14301430
channel_update = l1.daemon.is_in_log(r'\[IN\] 0102').split(' ')[-1][:-1]
14311431
node_announcement = l1.daemon.is_in_log(r'\[IN\] 0101').split(' ')[-1][:-1]
14321432

1433-
txid = l2.rpc.close(l3.info['id'])['txid']
1433+
txid = only_one(l2.rpc.close(l3.info['id'])['txids'])
14341434
wait_for(lambda: l2.rpc.listpeerchannels(l3.info['id'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
14351435
bitcoind.generate_block(13, txid)
14361436

@@ -1894,7 +1894,7 @@ def test_topology_leak(node_factory, bitcoind):
18941894
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 4)
18951895

18961896
# Close and wait for gossip to catchup.
1897-
txid = l2.rpc.close(l3.info['id'])['txid']
1897+
txid = only_one(l2.rpc.close(l3.info['id'])['txids'])
18981898
bitcoind.generate_block(13, txid)
18991899

19001900
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)
@@ -1926,14 +1926,14 @@ def test_close_12_block_delay(node_factory, bitcoind):
19261926
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True)
19271927

19281928
# Close l1-l2
1929-
txid = l1.rpc.close(l2.info['id'])['txid']
1929+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
19301930
bitcoind.generate_block(1, txid)
19311931

19321932
# But l4 doesn't believe it immediately.
19331933
l4.daemon.wait_for_log("channel .* closing soon due to the funding outpoint being spent")
19341934

19351935
# Close l2-l3 one block later.
1936-
txid = l2.rpc.close(l3.info['id'])['txid']
1936+
txid = only_one(l2.rpc.close(l3.info['id'])['txids'])
19371937
bitcoind.generate_block(1, txid)
19381938
l4.daemon.wait_for_log("channel .* closing soon due to the funding outpoint being spent")
19391939

tests/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,7 @@ def test_setconfig(node_factory, bitcoind):
39963996
l1.fundchannel(l2, 400000)
39973997

39983998
l1.fundchannel(l2, 10**6)
3999-
txid = l1.rpc.close(l2.info['id'])['txid']
3999+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
40004000
# Make sure we're completely closed!
40014001
bitcoind.generate_block(1, wait_for_mempool=txid)
40024002
sync_blockheight(bitcoind, [l1, l2])

tests/test_opening.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ def test_zeroreserve(node_factory, bitcoind):
21492149
# closing should result in the output being trimmed again since we
21502150
# dropped below dust again.
21512151
c = l2.rpc.close(l1.info['id'])
2152-
decoded = bitcoind.rpc.decoderawtransaction(c['tx'])
2152+
decoded = bitcoind.rpc.decoderawtransaction(only_one(c['txs']))
21532153
# Elements has a change output always
21542154
assert len(decoded['vout']) == 1 if TEST_NETWORK == 'regtest' else 2
21552155

tests/test_pay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5753,7 +5753,7 @@ def test_offer_paths(node_factory, bitcoind):
57535753

57545754
# Make scid path invalid by closing it
57555755
close = l1.rpc.close(paths[0]['first_scid'])
5756-
bitcoind.generate_block(13, wait_for_mempool=close['txid'])
5756+
bitcoind.generate_block(13, wait_for_mempool=only_one(close['txids']))
57575757
wait_for(lambda: l5.rpc.listchannels(paths[0]['first_scid']) == {'channels': []})
57585758

57595759
# Now connect l5->l4, and it will be able to reach l3 via that, and join blinded path.

tests/test_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def test_openchannel_hook(node_factory, bitcoind):
724724
assert l2.daemon.is_in_log('reject_odd_funding_amounts.py: {}={}'.format(k, v))
725725

726726
# Close it.
727-
txid = l1.rpc.close(l2.info['id'])['txid']
727+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
728728
bitcoind.generate_block(1, txid)
729729
wait_for(lambda: [c['state'] for c in l1.rpc.listpeerchannels(l2.info['id'])['channels']] == ['ONCHAIN'])
730730

@@ -4197,7 +4197,7 @@ def test_sql(node_factory, bitcoind):
41974197
l3.daemon.wait_for_log("Refreshing channel: {}".format(scid))
41984198

41994199
# This has to wait for the hold_invoice plugin to let go!
4200-
txid = l1.rpc.close(l2.info['id'])['txid']
4200+
txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
42014201
bitcoind.generate_block(13, wait_for_mempool=txid)
42024202
wait_for(lambda: len(l3.rpc.listchannels(source=l1.info['id'])['channels']) == 0)
42034203
assert len(l3.rpc.sql("SELECT * FROM channels WHERE source = X'{}';".format(l1.info['id']))['rows']) == 0

0 commit comments

Comments
 (0)