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

Function test_migration_no_bkpr

tests/test_bookkeeper.py:1120–1178  ·  view source on GitHub ↗

These nodes need to invent coinmoves to make the balances work

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1118@unittest.skipIf(TEST_NETWORK != 'regtest', "Snapshots are bitcoin regtest.")
1119@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")
1120def test_migration_no_bkpr(node_factory, bitcoind):
1121 """These nodes need to invent coinmoves to make the balances work"""
1122 bitcoind.generate_block(1)
1123 l1 = node_factory.get_node(dbfile="l1-before-moves-in-db.sqlite3.xz",
1124 options={'database-upgrade': True},
1125 old_hsmsecret=True)
1126 l2 = node_factory.get_node(dbfile="l2-before-moves-in-db.sqlite3.xz",
1127 options={'database-upgrade': True},
1128 old_hsmsecret=True)
1129
1130 chan = only_one(l1.rpc.listpeerchannels()['channels'])
1131
1132 l1_events = l1.rpc.bkpr_listaccountevents()['events']
1133 for e in l1_events:
1134 del e['timestamp']
1135
1136 l2_events = l2.rpc.bkpr_listaccountevents()['events']
1137 for e in l2_events:
1138 del e['timestamp']
1139
1140 assert l1_events == [{'account': chan['channel_id'],
1141 'blockheight': 103,
1142 'credit_msat': 1000000000,
1143 'currency': 'bcrt',
1144 'debit_msat': 0,
1145 'outpoint': f"{chan['funding_txid']}:{chan['funding_outnum']}",
1146 'tag': 'channel_open',
1147 'type': 'chain'},
1148 {'account': 'wallet',
1149 'blockheight': 103,
1150 'credit_msat': 995073000,
1151 'currency': 'bcrt',
1152 'debit_msat': 0,
1153 'outpoint': f"{chan['funding_txid']}:{chan['funding_outnum'] ^ 1}",
1154 'tag': 'deposit',
1155 'type': 'chain'},
1156 {'account': chan['channel_id'],
1157 'credit_msat': 0,
1158 'currency': 'bcrt',
1159 'debit_msat': 12345678,
1160 'is_rebalance': False,
1161 'tag': 'journal_entry',
1162 'type': 'channel'}]
1163
1164 assert l2_events == [{'account': chan['channel_id'],
1165 'blockheight': 103,
1166 'credit_msat': 0,
1167 'currency': 'bcrt',
1168 'debit_msat': 0,
1169 'outpoint': f"{chan['funding_txid']}:{chan['funding_outnum']}",
1170 'tag': 'channel_open',
1171 'type': 'chain'},
1172 {'account': chan['channel_id'],
1173 'credit_msat': 12345678,
1174 'currency': 'bcrt',
1175 'debit_msat': 0,
1176 'is_rebalance': False,
1177 'tag': 'journal_entry',

Callers

nothing calls this directly

Calls 4

only_oneFunction · 0.90
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
get_nodeMethod · 0.45

Tested by

no test coverage detected