diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 204fbb98..4e5f53e8 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -979,18 +979,14 @@ class Chain extends AsyncEmitter { tip.height - fork.height ); - // mark invalid_child from tip of fork to second block of fork - while (competitor.height > fork.height + 2) { + // mark invalid_child from tip of fork to first block of fork + while (competitor.height !== fork.height + 1) { const previous = await this.getPrevious(competitor) await this.invalidate(previous.hash) } - // mark invalid first block of fork - const previous = await this.getPrevious(competitor) - await this.invalidate(previous.hash) - // check - assert.equal(this.getPrevious(previous), fork, 'nlr invalidation down to the fork') + assert.equal(await this.getPrevious(competitor), fork, 'nlr invalidation down to the fork') return true }