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

Function test_db_forward_migrate

tests/test_db.py:491–536  ·  view source on GitHub ↗
(bitcoind, node_factory)

Source from the content-addressed store, hash-verified

489@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete db")
490@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")
491def test_db_forward_migrate(bitcoind, node_factory):
492 # For posterity, here is how I generated the db, in v0.12.1:
493 # l1, l2, l3, l4, l5 = node_factory.get_nodes(5)
494
495 # node_factory.join_nodes([l2, l1, l3], True, FUNDAMOUNT, True, True)
496 # node_factory.join_nodes([l4, l1, l5], True, FUNDAMOUNT, True, True)
497
498 # # Both ends remembered
499 # l2.rpc.pay(l3.rpc.invoice(10000, 'test_db_forward_migrate', 'test_db_forward_migrate')['bolt11'])
500
501 # # Both ends forgotten
502 # l4.rpc.pay(l5.rpc.invoice(10000, 'test_db_forward_migrate', 'test_db_forward_migrate')['bolt11'])
503
504 # # Outgoing forgotten
505 # l2.rpc.pay(l5.rpc.invoice(10000, 'test_db_forward_migrate2', 'test_db_forward_migrate2')['bolt11'])
506
507 # # Incoming forgotten
508 # l4.rpc.pay(l3.rpc.invoice(10000, 'test_db_forward_migrate2', 'test_db_forward_migrate2')['bolt11'])
509
510 # time.sleep(5)
511 # l4.rpc.close(l1.info['id'])
512 # l5.rpc.close(l1.info['id'])
513 # bitcoind.generate_block(100, wait_for_mempool=2)
514 # l4.rpc.disconnect(l1.info['id'])
515 # l5.rpc.disconnect(l1.info['id'])
516
517 # wait_for(lambda: l1.rpc.listpeers(l4.info['id'])['peers'] == [])
518 # wait_for(lambda: l1.rpc.listpeers(l5.info['id'])['peers'] == [])
519 # assert False
520 bitcoind.generate_block(113)
521 l1 = node_factory.get_node(dbfile='v0.12.1-forward.sqlite3.xz',
522 old_hsmsecret=True,
523 options={'database-upgrade': True})
524
525 assert l1.rpc.getinfo()['fees_collected_msat'] == 4
526 assert len(l1.rpc.listforwards()['forwards']) == 4
527
528 # The two null in_htlc_id are replaced with bogus entries!
529 assert sum([f['in_htlc_id'] > 0xFFFFFFFFFFFF for f in l1.rpc.listforwards()['forwards']]) == 2
530
531 # Make sure autoclean can handle these!
532 l1.stop()
533 l1.daemon.opts['autoclean-succeededforwards-age'] = 2
534 l1.daemon.opts['autoclean-cycle'] = 1
535 l1.start()
536 wait_for(lambda: l1.rpc.listforwards()['forwards'] == [])
537
538
539@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Canned db used")

Callers

nothing calls this directly

Calls 7

wait_forFunction · 0.90
generate_blockMethod · 0.80
listforwardsMethod · 0.80
get_nodeMethod · 0.45
getinfoMethod · 0.45
stopMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected