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

Function test_migration

tests/test_bookkeeper.py:949–1115  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

947@unittest.skipIf(TEST_NETWORK != 'regtest', "Snapshots are bitcoin regtest.")
948@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")
949def test_migration(node_factory, bitcoind):
950 generate = False
951
952 if generate:
953 l1, l2 = node_factory.line_graph(2)
954
955 l1.pay(l2, 12345678, label="Rusty's payment")
956
957 wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['htlcs'] == [])
958 wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['htlcs'] == [])
959
960 chan = only_one(l1.rpc.listpeerchannels()['channels'])
961 # Label change output and funding output
962 l1.rpc.bkpr_editdescriptionbyoutpoint(f"{chan['funding_txid']}:{chan['funding_outnum']}",
963 "Rusty's channel")
964 l1.rpc.bkpr_editdescriptionbyoutpoint(f"{chan['funding_txid']}:{chan['funding_outnum'] ^ 1}",
965 "Rusty's change")
966 else:
967 bitcoind.generate_block(1)
968 l1 = node_factory.get_node(dbfile="l1-before-moves-in-db.sqlite3.xz",
969 bkpr_dbfile="l1-bkpr-accounts.sqlite3.xz",
970 options={'database-upgrade': True},
971 old_hsmsecret=True)
972 l2 = node_factory.get_node(dbfile="l2-before-moves-in-db.sqlite3.xz",
973 bkpr_dbfile="l2-bkpr-accounts.sqlite3.xz",
974 options={'database-upgrade': True},
975 old_hsmsecret=True)
976
977 chan = only_one(l1.rpc.listpeerchannels()['channels'])
978
979 payment = only_one(l1.rpc.listsendpays()['payments'])
980 events = l1.rpc.bkpr_listaccountevents()['events']
981
982 pay_event = only_one([e for e in events if e.get('description') == "Rusty's payment"])
983 del pay_event['timestamp']
984 assert pay_event == {'account': chan['channel_id'],
985 'credit_msat': 0,
986 'currency': 'bcrt',
987 'debit_msat': 12345678,
988 'description': "Rusty's payment",
989 'is_rebalance': False,
990 'part_id': 0,
991 'payment_id': payment['payment_hash'],
992 'tag': 'invoice',
993 'type': 'channel'}
994 open_event = only_one([e for e in events if e.get('description') == "Rusty's channel"])
995 del open_event['timestamp']
996 assert open_event == {'account': chan['channel_id'],
997 'blockheight': 103,
998 'credit_msat': 1000000000,
999 'currency': 'bcrt',
1000 'debit_msat': 0,
1001 'description': "Rusty's channel",
1002 'outpoint': f"{chan['funding_txid']}:{chan['funding_outnum']}",
1003 'tag': 'channel_open',
1004 'type': 'chain'}
1005
1006 change_event = only_one([e for e in events if e.get('description') == "Rusty's change"])

Callers

nothing calls this directly

Calls 9

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
listpeerchannelsMethod · 0.80
generate_blockMethod · 0.80
listsendpaysMethod · 0.80
payMethod · 0.45
get_nodeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected