Browse Source

liquid-compat: update coinmove check to be liquid compatible

🎉 :waterfall:
nifty/pset-pre
niftynei 4 years ago
parent
commit
e354cc473e
No known key found for this signature in database GPG Key ID: BFF0F67810C1EED1
  1. 5
      tests/test_connection.py
  2. 2
      tests/test_misc.py
  3. 63
      tests/test_plugin.py
  4. 4
      tests/utils.py

5
tests/test_connection.py

@ -821,8 +821,7 @@ def test_funding_toolarge(node_factory, bitcoind):
l1.rpc.fundchannel(l2.info['id'], amount)
@unittest.skipIf(TEST_NETWORK != 'regtest', "check_coin_moves is network-specific")
def test_funding_push(node_factory, bitcoind):
def test_funding_push(node_factory, bitcoind, chainparams):
""" Try to push peer some sats """
# We track balances, to verify that accounting is ok.
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
@ -862,7 +861,7 @@ def test_funding_push(node_factory, bitcoind):
{'type': 'chain_mvt', 'credit': 0, 'debit': 20000000, 'tag': 'pushed'},
{'type': 'chain_mvt', 'credit': 16777215000, 'debit': 0, 'tag': 'deposit'},
]
check_coin_moves(l1, chanid, channel_mvts)
check_coin_moves(l1, chanid, channel_mvts, chainparams)
assert account_balance(l1, chanid) == (amount - push_sat) * 1000

2
tests/test_misc.py

@ -658,7 +658,7 @@ def test_withdraw_misc(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 0, 'debit': 11957378000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 3652000, 'tag': 'chain_fees'},
]
check_coin_moves(l1, 'wallet', wallet_moves)
check_coin_moves(l1, 'wallet', wallet_moves, chainparams)
def test_minconf_withdraw(node_factory, bitcoind):

63
tests/test_plugin.py

@ -1360,7 +1360,7 @@ def test_plugin_fail(node_factory):
@unittest.skipIf(not DEVELOPER, "without DEVELOPER=1, gossip v slow")
def test_coin_movement_notices(node_factory, bitcoind):
def test_coin_movement_notices(node_factory, bitcoind, chainparams):
"""Verify that coin movements are triggered correctly.
"""
@ -1373,23 +1373,44 @@ def test_coin_movement_notices(node_factory, bitcoind):
{'type': 'chain_mvt', 'credit': 0, 'debit': 1, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 100001000, 'tag': 'withdrawal'},
]
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 5430501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 944570000, 'tag': 'withdrawal'},
]
l2_wallet_mvts = [
{'type': 'chain_mvt', 'credit': 2000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 0, 'tag': 'spend_track'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 995418000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 1000000000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 4582000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 995418000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 944570000, 'debit': 0, 'tag': 'deposit'},
]
if chainparams['elements']:
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 8955501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 941045000, 'tag': 'withdrawal'},
]
l2_wallet_mvts = [
{'type': 'chain_mvt', 'credit': 2000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 0, 'tag': 'spend_track'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 991893000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 1000000000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 8107000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 991893000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 941045000, 'debit': 0, 'tag': 'deposit'},
]
else:
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 5430501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 944570000, 'tag': 'withdrawal'},
]
l2_wallet_mvts = [
{'type': 'chain_mvt', 'credit': 2000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 0, 'tag': 'spend_track'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 995418000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 1000000000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 4582000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 995418000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 944570000, 'debit': 0, 'tag': 'deposit'},
]
l1, l2, l3 = node_factory.line_graph(3, opts=[
{'may_reconnect': True},
@ -1468,7 +1489,7 @@ def test_coin_movement_notices(node_factory, bitcoind):
assert account_balance(l2, chanid_3) == 0
# Verify we recorded all the movements we expect
check_coin_moves(l2, chanid_1, l1_l2_mvts)
check_coin_moves(l2, chanid_3, l2_l3_mvts)
check_coin_moves(l2, 'wallet', l2_wallet_mvts)
check_coin_moves(l2, chanid_1, l1_l2_mvts, chainparams)
check_coin_moves(l2, chanid_3, l2_l3_mvts, chainparams)
check_coin_moves(l2, 'wallet', l2_wallet_mvts, chainparams)
check_coin_moves_idx(l2)

4
tests/utils.py

@ -49,7 +49,7 @@ def expected_channel_features(wumbo_channels=False, extra=[]):
return hex_bits(features + extra)
def check_coin_moves(n, account_id, expected_moves):
def check_coin_moves(n, account_id, expected_moves, chainparams):
moves = n.rpc.call('listcoinmoves_plugin')['coin_moves']
node_id = n.info['id']
acct_moves = [m for m in moves if m['account_id'] == account_id]
@ -62,7 +62,7 @@ def check_coin_moves(n, account_id, expected_moves):
assert mv['debit'] == "{}msat".format(exp['debit'])
assert mv['tag'] == exp['tag']
assert mv['timestamp'] > 0
assert mv['coin_type'] == 'bcrt'
assert mv['coin_type'] == chainparams['bip173_prefix']
# chain moves should have blockheights
if mv['type'] == 'chain_mvt':
assert mv['blockheight'] is not None

Loading…
Cancel
Save