diff --git a/tests/test_misc.py b/tests/test_misc.py index 7b67fba49..cfb6977be 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2605,3 +2605,13 @@ def test_datastore_keylist(node_factory): 'string': 'ab2val2', 'generation': 1, 'hex': b'ab2val2'.hex()}]} + + +@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', + "This test requires sqlite3") +def test_torv2_in_db(node_factory): + l1, l2 = node_factory.line_graph(2, wait_for_announce=True) + + l1.stop() + l1.db_manip("UPDATE peers SET address='3fyb44wdhnd2ghhl.onion:1234';") + l1.start() diff --git a/wallet/wallet.c b/wallet/wallet.c index ff9506299..346ae90b2 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -836,10 +836,15 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid) db_col_node_id(stmt, "node_id", &id); + /* This can happen for peers last seen on Torv2! */ addrstr = db_col_strdup(tmpctx, stmt, "address"); if (!parse_wireaddr_internal(addrstr, &addr, DEFAULT_PORT, - false, false, true, true, NULL)) - goto done; + false, false, true, true, NULL)) { + log_unusual(w->log, "Unparsable peer address %s: replacing", + addrstr); + parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT, + false, false, true, true, NULL); + } /* FIXME: save incoming in db! */ peer = new_peer(w->ld, db_col_u64(stmt, "id"), &id, &addr, false);