diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index 0999f31f1..1c50688d4 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -468,6 +468,13 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount, if (blockcount < topo->first_blocknum) topo->first_blocknum = blockcount; + /* FIXME: Because we don't handle our root disappearing, we go + * 100 blocks back */ + if (topo->first_blocknum < 100) + topo->first_blocknum = 0; + else + topo->first_blocknum -= 100; + /* Get up to speed with topology. */ bitcoind_getblockhash(bitcoind, topo->first_blocknum, get_init_block, topo); diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 4c1bc2a10..a420b4385 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -224,6 +224,11 @@ class BaseLightningDTests(unittest.TestCase): if not ok: raise Exception("At least one lightning exited with unexpected non-zero return code") + @classmethod + def tearDownClass(cls): + """We need 100 blocks between runs, since otherwise they might see the txs from a previous run, and get very confused!""" + bitcoind.generate_block(100) + class LightningDTests(BaseLightningDTests): def connect(self): l1 = self.node_factory.get_node()