pytest: don't use deprecated amount fields

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-06-20 19:52:09 +09:30
parent 5c208c1b06
commit 6afc0affef
4 changed files with 61 additions and 75 deletions

View file

@ -257,10 +257,10 @@ def test_balance(node_factory):
l1, l2 = node_factory.line_graph(2, fundchannel=True)
p1 = only_one(l1.rpc.getpeer(peer_id=l2.info['id'], level='info')['channels'])
p2 = only_one(l2.rpc.getpeer(l1.info['id'], 'info')['channels'])
assert p1['msatoshi_to_us'] == 10**6 * 1000
assert p1['msatoshi_total'] == 10**6 * 1000
assert p2['msatoshi_to_us'] == 0
assert p2['msatoshi_total'] == 10**6 * 1000
assert p1['to_us_msat'] == 10**6 * 1000
assert p1['total_msat'] == 10**6 * 1000
assert p2['to_us_msat'] == 0
assert p2['total_msat'] == 10**6 * 1000
@pytest.mark.openchannel('v1')
@ -1024,7 +1024,7 @@ def test_funding_all_too_much(node_factory):
pending = only_one([o for o in outputs if o['status'] != 'confirmed'])
assert pending['status'] == 'unconfirmed'
assert pending['reserved'] is False
assert only_one(l1.rpc.listfunds()['channels'])['channel_total_sat'] == 2**24 - 1
assert only_one(l1.rpc.listfunds()['channels'])['amount_msat'] == Millisatoshi(str(2**24 - 1) + "sat")
@pytest.mark.openchannel('v1')
@ -1135,7 +1135,7 @@ def test_funding_push(node_factory, bitcoind, chainparams):
# Send funds.
amount = 2**24
push_sat = 20000
push_msat = 20000 * 1000
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
bitcoind.generate_block(1)
@ -1144,16 +1144,16 @@ def test_funding_push(node_factory, bitcoind, chainparams):
# Fail to open (try to push too much)
with pytest.raises(RpcError, match=r'Requested to push_msat of 20000000msat is greater than available funding amount 10000sat'):
l1.rpc.fundchannel(l2.info['id'], 10000, push_msat=push_sat * 1000)
l1.rpc.fundchannel(l2.info['id'], 10000, push_msat=push_msat)
# This should work.
amount = amount - 1
l1.rpc.fundchannel(l2.info['id'], amount, push_msat=push_sat * 1000)
l1.rpc.fundchannel(l2.info['id'], amount, push_msat=push_msat)
bitcoind.generate_block(1)
sync_blockheight(bitcoind, [l1])
funds = only_one(l1.rpc.listfunds()['channels'])
assert funds['channel_sat'] + push_sat == funds['channel_total_sat']
assert funds['our_amount_msat'] + push_msat == funds['amount_msat']
chanid = first_channel_id(l2, l1)
channel_mvts_1 = [
@ -1167,7 +1167,7 @@ def test_funding_push(node_factory, bitcoind, chainparams):
check_coin_moves(l1, chanid, channel_mvts_1, chainparams)
check_coin_moves(l2, chanid, channel_mvts_2, chainparams)
assert account_balance(l1, chanid) == (amount - push_sat) * 1000
assert account_balance(l1, chanid) == amount * 1000 - push_msat
@pytest.mark.openchannel('v1')
@ -1596,7 +1596,7 @@ def test_funding_close_upfront(node_factory, bitcoind):
for node in [l1, l2]:
channel = node.rpc.listpeers()['peers'][0]['channels'][-1]
assert amount * 1000 == channel['msatoshi_total']
assert amount * 1000 == channel['total_msat']
def _close(src, dst, addr=None):
"""Close the channel from src to dst, with the specified address.
@ -1694,7 +1694,7 @@ def test_funding_external_wallet(node_factory, bitcoind):
for node in [l1, l2]:
node.daemon.wait_for_log(r'State changed from CHANNELD_AWAITING_LOCKIN to CHANNELD_NORMAL')
channel = node.rpc.listpeers()['peers'][0]['channels'][0]
assert amount * 1000 == channel['msatoshi_total']
assert amount * 1000 == channel['total_msat']
# Test that we don't crash if peer disconnects after fundchannel_start
l2.connect(l3)
@ -2235,7 +2235,7 @@ def test_channel_persistence(node_factory, bitcoind, executor):
wait_for(lambda: len(l2.rpc.listpeers()['peers']) == 1)
# Wait for the restored HTLC to finish
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99990000)
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['to_us_msat'] == 99990000)
wait_for(lambda: len([p for p in l1.rpc.listpeers()['peers'] if p['connected']]))
wait_for(lambda: len([p for p in l2.rpc.listpeers()['peers'] if p['connected']]))
@ -2243,14 +2243,14 @@ def test_channel_persistence(node_factory, bitcoind, executor):
# Now make sure this is really functional by sending a payment
l1.pay(l2, 10000)
# L1 doesn't actually update msatoshi_to_us until it receives
# L1 doesn't actually update to_us_msat until it receives
# revoke_and_ack from L2, which can take a little bit.
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99980000)
assert only_one(l2.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 20000
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['to_us_msat'] == 99980000)
assert only_one(l2.rpc.listpeers()['peers'][0]['channels'])['to_us_msat'] == 20000
# Finally restart l1, and make sure it remembers
l1.restart()
assert only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99980000
assert only_one(l1.rpc.listpeers()['peers'][0]['channels'])['to_us_msat'] == 99980000
# Now make sure l1 is watching for unilateral closes
l2.rpc.dev_fail(l1.info['id'])

View file

@ -627,7 +627,6 @@ def test_amountless_invoice(node_factory):
inv = l2.rpc.invoice('any', 'lbl', 'desc')['bolt11']
i = l2.rpc.listinvoices()['invoices']
assert(len(i) == 1)
assert('msatoshi_received' not in i[0])
assert('amount_received_msat' not in i[0])
assert(i[0]['status'] == 'unpaid')
details = l1.rpc.decodepay(inv)
@ -637,7 +636,6 @@ def test_amountless_invoice(node_factory):
i = l2.rpc.listinvoices()['invoices']
assert(len(i) == 1)
assert(i[0]['msatoshi_received'] == 1337)
assert(i[0]['amount_received_msat'] == Millisatoshi(1337))
assert(i[0]['status'] == 'paid')

View file

@ -2325,7 +2325,7 @@ def test_listforwards(node_factory, bitcoind):
# status=settled
settled_forwards = l2.rpc.listforwards(status='settled')['forwards']
assert len(settled_forwards) == 2
assert sum(x['out_msatoshi'] for x in settled_forwards) == 3000
assert sum(x['out_msat'] for x in settled_forwards) == 3000
# status=local_failed
failed_forwards = l2.rpc.listforwards(status='local_failed')['forwards']

View file

@ -33,7 +33,7 @@ def test_pay(node_factory):
after = time.time()
preimage = details['payment_preimage']
assert details['status'] == 'complete'
assert details['msatoshi'] == 123000
assert details['amount_msat'] == Millisatoshi(123000)
assert details['destination'] == l2.info['id']
assert details['created_at'] >= before
assert details['created_at'] <= after
@ -357,7 +357,7 @@ def test_pay_optional_args(node_factory):
inv1 = l2.rpc.invoice(123000, 'test_pay', 'desc')['bolt11']
l1.dev_pay(inv1, label='desc', use_shadow=False)
payment1 = l1.rpc.listsendpays(inv1)['payments']
assert len(payment1) and payment1[0]['msatoshi_sent'] == 123000
assert len(payment1) and payment1[0]['amount_sent_msat'] == 123000
assert payment1[0]['label'] == 'desc'
inv2 = l2.rpc.invoice(321000, 'test_pay2', 'description')['bolt11']
@ -614,10 +614,10 @@ def test_sendpay(node_factory):
# FIXME: test paying via another node, should fail to pay twice.
p1 = l1.rpc.getpeer(l2.info['id'], 'info')
p2 = l2.rpc.getpeer(l1.info['id'], 'info')
assert only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000
assert only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000
assert only_one(p2['channels'])['msatoshi_to_us'] == 0
assert only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000
assert only_one(p1['channels'])['to_us_msat'] == 10**6 * 1000
assert only_one(p1['channels'])['total_msat'] == 10**6 * 1000
assert only_one(p2['channels'])['to_us_msat'] == 0
assert only_one(p2['channels'])['total_msat'] == 10**6 * 1000
# This works.
before = int(time.time())
@ -627,13 +627,13 @@ def test_sendpay(node_factory):
# Check details
assert details['payment_hash'] == rhash
assert details['destination'] == l2.info['id']
assert details['msatoshi'] == amt
assert details['amount_msat'] == amt
assert details['created_at'] >= before
assert details['created_at'] <= after
# Check receiver
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['status'] == 'paid'
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['pay_index'] == 1
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['msatoshi_received'] == rs['msatoshi']
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['amount_received_msat'] == rs['msatoshi']
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['payment_preimage'] == preimage
# Balances should reflect it.
@ -641,10 +641,10 @@ def test_sendpay(node_factory):
p1 = l1.rpc.getpeer(l2.info['id'], 'info')
p2 = l2.rpc.getpeer(l1.info['id'], 'info')
return (
only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000 - amt
and only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000
and only_one(p2['channels'])['msatoshi_to_us'] == amt
and only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000
only_one(p1['channels'])['to_us_msat'] == 10**6 * 1000 - amt
and only_one(p1['channels'])['total_msat'] == 10**6 * 1000
and only_one(p2['channels'])['to_us_msat'] == amt
and only_one(p2['channels'])['total_msat'] == 10**6 * 1000
)
wait_for(check_balances)
@ -656,7 +656,7 @@ def test_sendpay(node_factory):
assert preimage == preimage2
l1.daemon.wait_for_log('Payment ./.: .* COMPLETE')
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['status'] == 'paid'
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['msatoshi_received'] == rs['msatoshi']
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['amount_received_msat'] == rs['msatoshi']
# Overpaying by "only" a factor of 2 succeeds.
inv = l2.rpc.invoice(amt, 'testpayment3', 'desc')
@ -666,7 +666,7 @@ def test_sendpay(node_factory):
l1.rpc.sendpay([routestep], rhash, payment_secret=inv['payment_secret'])
preimage3 = l1.rpc.waitsendpay(rhash)['payment_preimage']
assert only_one(l2.rpc.listinvoices('testpayment3')['invoices'])['status'] == 'paid'
assert only_one(l2.rpc.listinvoices('testpayment3')['invoices'])['msatoshi_received'] == amt * 2
assert only_one(l2.rpc.listinvoices('testpayment3')['invoices'])['amount_received_msat'] == amt * 2
# Test listsendpays
payments = l1.rpc.listsendpays()['payments']
@ -797,7 +797,6 @@ def test_decodepay(node_factory):
'fj9srp'
)
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 2500 * 10**11 // 1000000
assert b11['amount_msat'] == Millisatoshi(2500 * 10**11 // 1000000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -831,7 +830,6 @@ def test_decodepay(node_factory):
'herry pie, one sausage, one cupcake, and one slice of watermelon'
)
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(str(20 * 10**11 // 1000) + 'msat')
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -864,7 +862,6 @@ def test_decodepay(node_factory):
'herry pie, one sausage, one cupcake, and one slice of watermelon'
)
assert b11['currency'] == 'tb'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(20 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -896,7 +893,6 @@ def test_decodepay(node_factory):
# * `dhhwkj`: Bech32 checksum
b11 = l1.rpc.decodepay('lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfpp3qjmp7lwpagxun9pygexvgpjdc4jdj85fr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzqj9n4evl6mr5aj9f58zp6fyjzup6ywn3x6sk8akg5v4tgn2q8g4fhx05wf6juaxu9760yp46454gpg5mtzgerlzezqcqvjnhjh8z3g2qqdhhwkj', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon')
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(20 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -939,7 +935,6 @@ def test_decodepay(node_factory):
# * `mf9swh`: Bech32 checksum
b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppj3a24vwu6r8ejrss3axul8rxldph2q7z9kmrgvr7xlaqm47apw3d48zm203kzcq357a4ls9al2ea73r8jcceyjtya6fu5wzzpe50zrge6ulk4nvjcpxlekvmxl6qcs9j3tz0469gq5g658y', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon')
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(20 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -966,7 +961,6 @@ def test_decodepay(node_factory):
# * `qdtpa4`: Bech32 checksum
b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kepvrhrm9s57hejg0p662ur5j5cr03890fa7k2pypgttmh4897d3raaq85a293e9jpuqwl0rnfuwzam7yr8e690nd2ypcq9hlkdwdvycqa0qza8', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon')
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(20 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -993,7 +987,6 @@ def test_decodepay(node_factory):
# * `akvd7y`: Bech32 checksum
b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfp4qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q28j0v3rwgy9pvjnd48ee2pl8xrpxysd5g44td63g6xcjcu003j3qe8878hluqlvl3km8rm92f5stamd3jw763n3hck0ct7p8wwj463cql26ava', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon')
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 20 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(20 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -1023,7 +1016,6 @@ def test_decodepay(node_factory):
# * `73t7cl`: Bech32 checksum
b11 = l1.rpc.decodepay('lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9qzsze992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq73t7cl')
assert b11['currency'] == 'bc'
assert b11['msatoshi'] == 25 * 10**11 // 1000
assert b11['amount_msat'] == Millisatoshi(25 * 10**11 // 1000)
assert b11['created_at'] == 1496314658
assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102'
@ -1063,7 +1055,7 @@ def test_decodepay(node_factory):
b11 = "lnbcrt71p0g4u8upp5xn4k45tsp05akmn65s5k2063d5fyadhjse9770xz5sk7u4x6vcmqdqqcqzynxqrrssx94cf4p727jamncsvcd8m99n88k423ruzq4dxwevfatpp5gx2mksj2swshjlx4pe3j5w9yed5xjktrktzd3nc2a04kq8yu84l7twhwgpxjn3pw"
b11 = l1.rpc.decodepay(b11)
sat_per_btc = 10**8
assert(b11['msatoshi'] == 7 * sat_per_btc * 1000)
assert(b11['amount_msat'] == 7 * sat_per_btc * 1000)
with pytest.raises(RpcError):
l1.rpc.decodepay('1111111')
@ -1206,7 +1198,7 @@ def test_forward_different_fees_and_cltv(node_factory, bitcoind):
# * `amt_to_forward` = 4999999
# * `outgoing_cltv_value` = current-block-height + 9 + 42
#
assert route[0]['msatoshi'] == 4999999
assert route[0]['amount_msat'] == 4999999
assert route[0]['delay'] == 9 + shadow_route
# BOLT #7:
@ -1229,9 +1221,9 @@ def test_forward_different_fees_and_cltv(node_factory, bitcoind):
route = l1.rpc.getroute(l3.info['id'], 4999999, 1)["route"]
assert len(route) == 2
assert route[0]['msatoshi'] == 5010198
assert route[0]['amount_msat'] == 5010198
assert route[0]['delay'] == 20 + 9 + shadow_route
assert route[1]['msatoshi'] == 4999999
assert route[1]['amount_msat'] == 4999999
assert route[1]['delay'] == 9 + shadow_route
inv = l3.rpc.invoice(4999999, 'test_forward_different_fees_and_cltv', 'desc')
@ -1294,9 +1286,9 @@ def test_forward_pad_fees_and_cltv(node_factory, bitcoind):
route = l1.rpc.getroute(l3.info['id'], 4999999, 1)["route"]
assert len(route) == 2
assert route[0]['msatoshi'] == 5010198
assert route[0]['amount_msat'] == 5010198
assert route[0]['delay'] == 20 + 9
assert route[1]['msatoshi'] == 4999999
assert route[1]['amount_msat'] == 4999999
assert route[1]['delay'] == 9
# Modify so we overpay, overdo the cltv.
@ -1373,22 +1365,22 @@ def test_forward_stats(node_factory, bitcoind):
# Check that we correctly account channel changes
assert inchan['in_payments_offered'] == 3
assert inchan['in_payments_fulfilled'] == 1
assert inchan['in_msatoshi_offered'] >= 3 * amount
assert inchan['in_msatoshi_fulfilled'] >= amount
assert inchan['in_offered_msat'] >= Millisatoshi(3 * amount)
assert inchan['in_fulfilled_msat'] >= Millisatoshi(amount)
assert outchan['out_payments_offered'] == 1
assert outchan['out_payments_fulfilled'] == 1
assert outchan['out_msatoshi_offered'] >= amount
assert outchan['out_msatoshi_offered'] == outchan['out_msatoshi_fulfilled']
assert outchan['out_offered_msat'] >= Millisatoshi(amount)
assert outchan['out_offered_msat'] == outchan['out_fulfilled_msat']
assert outchan['out_msatoshi_fulfilled'] < inchan['in_msatoshi_fulfilled']
assert outchan['out_fulfilled_msat'] < inchan['in_fulfilled_msat']
stats = l2.rpc.listforwards()
assert [f['status'] for f in stats['forwards']] == ['settled', 'failed', 'offered']
assert l2.rpc.getinfo()['msatoshi_fees_collected'] == 1 + amount // 100000
assert l1.rpc.getinfo()['msatoshi_fees_collected'] == 0
assert l3.rpc.getinfo()['msatoshi_fees_collected'] == 0
assert l2.rpc.getinfo()['fees_collected_msat'] == 1 + amount // 100000
assert l1.rpc.getinfo()['fees_collected_msat'] == 0
assert l3.rpc.getinfo()['fees_collected_msat'] == 0
assert stats['forwards'][0]['received_time'] <= stats['forwards'][0]['resolved_time']
assert stats['forwards'][1]['received_time'] <= stats['forwards'][1]['resolved_time']
assert 'received_time' in stats['forwards'][2] and 'resolved_time' not in stats['forwards'][2]
@ -1611,7 +1603,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
stats = l2.rpc.listforwards()
assert [f['status'] for f in stats['forwards']] == ['local_failed', 'local_failed', 'local_failed', 'local_failed', 'local_failed']
assert l2.rpc.getinfo()['msatoshi_fees_collected'] == 0
assert l2.rpc.getinfo()['fees_collected_msat'] == 0
assert 'received_time' in stats['forwards'][0] and 'resolved_time' not in stats['forwards'][0]
assert 'received_time' in stats['forwards'][1] and 'resolved_time' not in stats['forwards'][1]
@ -1708,7 +1700,7 @@ def test_pay_retry(node_factory, bitcoind, executor, chainparams):
"""
peer_node = opener.rpc.listpeers(peer.info['id'])['peers'][0]
chan = peer_node['channels'][0]
maxpay = chan['spendable_msatoshi']
maxpay = chan['spendable_msat']
lbl = ''.join(random.choice(string.ascii_letters) for _ in range(20))
inv = peer.rpc.invoice(maxpay, lbl, "exhaust_channel")
routestep = {
@ -2102,7 +2094,7 @@ def test_setchannel_state(node_factory, bitcoind):
inv = l2.rpc.invoice(100000, 'test_setchannel_state', 'desc')['bolt11']
result = l0.dev_pay(inv, use_shadow=False)
assert result['status'] == 'complete'
assert result['msatoshi_sent'] == 100042
assert result['amount_sent_msat'] == 100042
# Disconnect and unilaterally close from l2 to l1
l2.rpc.disconnect(l1.info['id'], force=True)
@ -2215,8 +2207,8 @@ def test_setchannel_routing(node_factory, bitcoind):
# Now try below minimum
route_ok = l1.rpc.getroute(l3.info['id'], 17, 1)["route"]
assert len(route_ok) == 2
assert route_ok[0]['msatoshi'] == 1337 + 17
assert route_ok[1]['msatoshi'] == 17
assert route_ok[0]['amount_msat'] == 1337 + 17
assert route_ok[1]['amount_msat'] == 17
route_bad = copy.deepcopy(route_ok)
route_bad[0]['msatoshi'] = 1337 + 16
@ -2271,8 +2263,8 @@ def test_setchannel_zero(node_factory, bitcoind):
# test if zero fees are applied
route = l1.rpc.getroute(l3.info['id'], 4999999, 1)["route"]
assert len(route) == 2
assert route[0]['msatoshi'] == 4999999
assert route[1]['msatoshi'] == 4999999
assert route[0]['amount_msat'] == 4999999
assert route[1]['amount_msat'] == 4999999
# Wait for l3 to know about our low-balling, otherwise they'll add a wrong
# routehint to the invoice.
@ -2282,7 +2274,7 @@ def test_setchannel_zero(node_factory, bitcoind):
inv = l3.rpc.invoice(4999999, 'test_setchannel_3', 'desc')['bolt11']
result = l1.dev_pay(inv, use_shadow=False)
assert result['status'] == 'complete'
assert result['msatoshi_sent'] == 4999999
assert result['amount_sent_msat'] == 4999999
# FIXME: hack something up to advertize min_htlc > 0, then test mintoolow.
with pytest.raises(RpcError, match="htlcmax cannot be less than htlcmin"):
@ -2338,7 +2330,7 @@ def test_setchannel_restart(node_factory, bitcoind):
inv = l3.rpc.invoice(499999, 'test_setchannel_1', 'desc')['bolt11']
result = l1.dev_pay(inv, use_shadow=False)
assert result['status'] == 'complete'
assert result['msatoshi_sent'] == 501404
assert result['amount_sent_msat'] == 501404
@pytest.mark.developer("updates are delayed without --dev-fast-gossip")
@ -3523,7 +3515,7 @@ def test_keysend(node_factory):
inv = invs[0]
print(inv)
assert(inv['msatoshi_received'] >= amt)
assert(inv['amount_received_msat'] >= Millisatoshi(amt))
# Now send a direct one instead from l1 to l2
l1.rpc.keysend(l2.info['id'], amt)
@ -3531,7 +3523,7 @@ def test_keysend(node_factory):
assert(len(invs) == 1)
inv = invs[0]
assert(inv['msatoshi_received'] >= amt)
assert(inv['amount_received_msat'] >= Millisatoshi(amt))
# And finally try to send a keysend payment to l4, which doesn't
# support it. It MUST fail.
@ -3563,7 +3555,7 @@ def test_keysend_extra_tlvs(node_factory):
assert(l2.daemon.is_in_log(r'plugin-sphinx-receiver.py.*extratlvs.*133773310.*feedc0de'))
inv = invs[0]
assert(inv['msatoshi_received'] >= amt)
assert(inv['amount_received_msat'] >= Millisatoshi(amt))
# Now try again with the TLV type in extra_tlvs as string:
l1.rpc.keysend(l2.info['id'], amt, extratlvs={133773310: 'FEEDC0DE'})
@ -3613,7 +3605,7 @@ def test_keysend_routehint(node_factory):
assert(len(invs) == 1)
inv = invs[0]
assert(inv['msatoshi_received'] >= amt)
assert(inv['amount_received_msat'] >= Millisatoshi(amt))
def test_invalid_onion_channel_update(node_factory):
@ -3751,7 +3743,7 @@ def test_mpp_presplit(node_factory):
assert(p['parts'] >= 5)
inv = l3.rpc.listinvoices()['invoices'][0]
assert(inv['msatoshi'] == inv['msatoshi_received'])
assert(inv['amount_msat'] == inv['amount_received_msat'])
# Make sure that bolt11 isn't duplicated for every part
bolt11s = 0
@ -4244,7 +4236,7 @@ def test_large_mpp_presplit(node_factory):
assert(p['parts'] <= PRESPLIT_MAX_SPLITS)
inv = l3.rpc.listinvoices()['invoices'][0]
assert(inv['msatoshi'] == inv['msatoshi_received'])
assert(inv['amount_msat'] == inv['amount_received_msat'])
@pytest.mark.developer("builds large network, which is slow if not DEVELOPER")
@ -4883,10 +4875,8 @@ def do_test_sendinvoice(node_factory, bitcoind, disable):
assert out['status'] == 'paid'
assert 'payment_preimage' in out
assert 'expires_at' in out
assert out['msatoshi'] == 100000000
assert out['amount_msat'] == Millisatoshi(100000000)
assert 'pay_index' in out
assert out['msatoshi_received'] == 100000000
assert out['amount_received_msat'] == Millisatoshi(100000000)
# Note, if we're slow, this fails with "Offer no longer available",
@ -4932,10 +4922,8 @@ def do_test_sendinvoice(node_factory, bitcoind, disable):
assert out['status'] == 'paid'
assert 'payment_preimage' in out
assert 'expires_at' in out
assert out['msatoshi'] == 10000000
assert out['amount_msat'] == Millisatoshi(10000000)
assert 'pay_index' in out
assert out['msatoshi_received'] == 10000000
assert out['amount_received_msat'] == Millisatoshi(10000000)