Skip to content

Commit

Permalink
pytest: clean up tests/test_db.py::test_last_tx_psbt_upgrade
Browse files Browse the repository at this point in the history
Ignore bad gossip, and use the broken_log option rather than manually filtering logs.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 9, 2024
1 parent 61cc3aa commit 1c3312c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def test_last_tx_psbt_upgrade(node_factory, bitcoind):
upgraded_psbts = ['cHNidP8BAgQCAAAAAQME74HcIAEEAQEBBQEDAQYBAwH7BAIAAAAAAQErQEIPAAAAAAAiACCiWhNhgwfpKsHIgLqGzpSdj8cCpITLFVpVRddsOobajiICAjJCZt6EA7OrFXoJ8feE1YevYYMcmYwVG8whu3TCsjFLRzBEAiBhqTjjdJx2TqTNUwYJgmjhH6p8FJnbnj/N/Jv0dEiQmwIgXG/ki8U0iN0YPbrhpl7goGhXUj/8+JRg0uKLJrkHLrsBAQMEAQAAAAEFR1IhAgZUBJOphZmWemHEUXLfSWgeOYpssIkKUG5092wtK+JCIQIyQmbehAOzqxV6CfH3hNWHr2GDHJmMFRvMIbt0wrIxS1KuIgYCBlQEk6mFmZZ6YcRRct9JaB45imywiQpQbnT3bC0r4kIIWA8TsgAAAAAiBgIyQmbehAOzqxV6CfH3hNWHr2GDHJmMFRvMIbt0wrIxSwhK0xNpAAAAAAEOII3WmYYbAAYeUJN6Iz21hL+O1MC/ULRMBBH3GwMaBkVQAQ8EAAAAAAEQBA73qYAAAQMIUMMAAAAAAAABBCIAIHM1bP9+FYjxSTXvE44UKr77X349Ud6UJ1jc1aF5RJtiAAEDCFCpBgAAAAAAAQQiACAt9UXqiCiJhGxS/F4RGsB84H4MCUGKwVdDpvYoTCpPpwABAwggoQcAAAAAAAEEFgAU6JlU+sj3otzlHglde+tSccP32lYA', 'cHNidP8BAgQCAAAAAQMEyVVUIAEEAQEBBQEBAQYB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FYwNV9OfQ8plfogtk/wk9f66qPNu2aAQ8EAQAAAAEQBFZtHYAAAQMIUMMAAAAAAAABBCIAIFZ5p9BuG9J2qiX1bp5N9+B9mDfvsMX2NgTxDNn3ZqA+AAEDCNTdBgAAAAAAAQQWABR+W1yPT8GpSE4ln5LKTLt/ooFOpAABAwiabAcAAAAAAAEEIgAgq2Im3r/+/0p0HAE2f6PIdRckg8+z4yfQ+MeqTFHt7KoA']

l1 = node_factory.get_node(dbfile='last_tx_upgrade.sqlite3.xz',
# FIXME: gossipd gets upset, since it seems like the db with remote announcement_sigs was
# actually from l2, not l1. But if we make this l1, then last_tx changes
broken_log='gossipd rejected our channel announcement',
allow_bad_gossip=True,
options={'database-upgrade': True})

b64_last_txs = [base64.b64encode(x['last_tx']).decode('utf-8') for x in l1.db_query('SELECT last_tx FROM channels ORDER BY id;')]
Expand All @@ -207,6 +211,8 @@ def test_last_tx_psbt_upgrade(node_factory, bitcoind):
time.sleep(2)

l2 = node_factory.get_node(dbfile='last_tx_closed.sqlite3.xz',
broken_log='gossipd rejected our channel announcement',
allow_bad_gossip=True,
options={'database-upgrade': True})
last_txs = [x['last_tx'] for x in l2.db_query('SELECT last_tx FROM channels ORDER BY id;')]

Expand All @@ -215,12 +221,6 @@ def test_last_tx_psbt_upgrade(node_factory, bitcoind):

bitcoind.rpc.decoderawtransaction(last_txs[1].hex())

# FIXME: gossipd gets upset, since it seems like the db with remote announcement_sigs was
# actually from l2, not l1. But if we make this l1, then last_tx changes, so we just
# filter out gossipd messages here (we will still detect other broken msgs!)
l1.daemon.logs = [l for l in l1.daemon.logs if 'gossipd' not in l]
l2.daemon.logs = [l for l in l2.daemon.logs if 'gossipd' not in l]


@pytest.mark.slow_test
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "This test is based on a sqlite3 snapshot")
Expand Down

0 comments on commit 1c3312c

Please sign in to comment.