From 6ed54dd34efac0ffd925ef0bcd309d195ce12ae2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Feb 2019 14:22:41 +1030 Subject: [PATCH] db: fix dangling peers on db upgrade. Signed-off-by: Rusty Russell --- tests/test_db.py | 3 --- wallet/db.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_db.py b/tests/test_db.py index 315fdd7ce..692581a73 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -1,9 +1,6 @@ from fixtures import * # noqa: F401,F403 -import pytest - -@pytest.mark.xfail(strict=True) def test_db_dangling_peer_fix(node_factory): # This was taken from test_fail_unconfirmed() node. l1 = node_factory.get_node(dbfile='dangling-peer.sqlite3.xz') diff --git a/wallet/db.c b/wallet/db.c index 2b48a4afa..25d1756d0 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -356,6 +356,8 @@ char *dbmigrations[] = { ");", /* Add a direction for failed payments. */ "ALTER TABLE payments ADD faildirection INTEGER;", /* erring_direction */ + /* Fix dangling peers with no channels. */ + "DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);", NULL, };