diff --git a/tests/data/oldstyle-scids.sqlite3.xz b/tests/data/oldstyle-scids.sqlite3.xz new file mode 100644 index 000000000..c6dd8c65a Binary files /dev/null and b/tests/data/oldstyle-scids.sqlite3.xz differ diff --git a/tests/test_db.py b/tests/test_db.py index 92b6c3634..9358519c0 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -1,5 +1,7 @@ from fixtures import * # noqa: F401,F403 -from utils import wait_for, sync_blockheight +from utils import wait_for, sync_blockheight, COMPAT + +import unittest def test_db_dangling_peer_fix(node_factory): @@ -111,3 +113,13 @@ def test_max_channel_id(node_factory, bitcoind): # Fundchannel again, should succeed. l1.rpc.fundchannel(l2.info['id'], 10**5) + + +@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete db") +def test_scid_upgrade(node_factory): + + # Created through the power of sed "s/X'\([0-9]*\)78\([0-9]*\)78\([0-9]*\)'/X'\13A\23A\3'/" + l1 = node_factory.get_node(dbfile='oldstyle-scids.sqlite3.xz') + + assert l1.db_query('SELECT short_channel_id from channels;') == [{'short_channel_id': '103x1x1'}] + assert l1.db_query('SELECT failchannel from payments;') == [{'failchannel': '103x1x1'}] diff --git a/tests/utils.py b/tests/utils.py index dfe56ace2..017b1d623 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -42,6 +42,7 @@ EXPERIMENTAL_FEATURES = os.getenv("EXPERIMENTAL_FEATURES", config['EXPERIMENTAL_ TIMEOUT = int(os.getenv("TIMEOUT", "60")) VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1" SLOW_MACHINE = os.getenv("SLOW_MACHINE", "0") == "1" +COMPAT = os.getenv("COMPAT", config['COMPAT']) == "1" def wait_for(success, timeout=TIMEOUT):