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

Function test_migration

tests/test_coinmoves.py:1977–2056  ·  view source on GitHub ↗

These nodes import coinmoves from the old bookkeeper account.db

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1975@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")
1976@unittest.skipIf(TEST_NETWORK != 'regtest', "Snapshots are bitcoin regtest.")
1977def test_migration(node_factory, bitcoind):
1978 """These nodes import coinmoves from the old bookkeeper account.db"""
1979 bitcoind.generate_block(1)
1980 l1 = node_factory.get_node(dbfile="l1-before-moves-in-db.sqlite3.xz",
1981 bkpr_dbfile="l1-bkpr-accounts.sqlite3.xz",
1982 options={'database-upgrade': True},
1983 old_hsmsecret=True)
1984 l2 = node_factory.get_node(dbfile="l2-before-moves-in-db.sqlite3.xz",
1985 bkpr_dbfile="l2-bkpr-accounts.sqlite3.xz",
1986 options={'database-upgrade': True},
1987 old_hsmsecret=True)
1988 chan = only_one(l1.rpc.listpeerchannels()['channels'])
1989 payment = only_one(l1.rpc.listsendpays()['payments'])
1990
1991 expected_channel1 = [{'account_id': chan['channel_id'],
1992 'created_index': 1,
1993 'credit_msat': 0,
1994 'debit_msat': 12345678,
1995 'fees_msat': 0,
1996 'payment_hash': payment['payment_hash'],
1997 'primary_tag': 'invoice'}]
1998 expected_channel2 = [{'account_id': chan['channel_id'],
1999 'created_index': 1,
2000 'credit_msat': 12345678,
2001 'debit_msat': 0,
2002 'fees_msat': 0,
2003 'payment_hash': payment['payment_hash'],
2004 'primary_tag': 'invoice'}]
2005 expected_chain1 = [{'account_id': 'wallet',
2006 'blockheight': 102,
2007 'created_index': 1,
2008 'credit_msat': 2000000000,
2009 'debit_msat': 0,
2010 'extra_tags': [],
2011 'output_msat': 2000000000,
2012 'primary_tag': 'deposit',
2013 'utxo': '63c59b312976320528552c258ae51563498dfd042b95bb0c842696614d59bb89:1'},
2014 {'account_id': 'wallet',
2015 'blockheight': 103,
2016 'created_index': 2,
2017 'credit_msat': 0,
2018 'debit_msat': 2000000000,
2019 'extra_tags': [],
2020 'output_msat': 2000000000,
2021 'primary_tag': 'withdrawal',
2022 'spending_txid': chan['funding_txid'],
2023 'utxo': '63c59b312976320528552c258ae51563498dfd042b95bb0c842696614d59bb89:1'},
2024 {'account_id': 'wallet',
2025 'blockheight': 103,
2026 'created_index': 3,
2027 'credit_msat': 995073000,
2028 'debit_msat': 0,
2029 'extra_tags': [],
2030 'output_msat': 995073000,
2031 'primary_tag': 'deposit',
2032 'utxo': f"{chan['funding_txid']}:{chan['funding_outnum'] ^ 1}"},
2033 {'account_id': chan['channel_id'],
2034 'blockheight': 103,

Callers

nothing calls this directly

Calls 7

only_oneFunction · 0.90
check_channel_movesFunction · 0.85
check_chain_movesFunction · 0.85
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
listsendpaysMethod · 0.80
get_nodeMethod · 0.45

Tested by

no test coverage detected