Skip to content

Commit

Permalink
pytest: add (failing) test for db with old Tor v2 address.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jun 24, 2022
1 parent a0c6447 commit 37403e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 7 additions & 2 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37403e4

Please sign in to comment.