Skip to content

Commit 295ff37

Browse files
committed
Enforce block connection ordering in unit and functional tests
This expands the assertions on block ordering to apply to `#[cfg(test)]` builds in addition to normal builds, requiring that unit and functional tests have syntactically-valid (ie the previous block hash pointer and the heights match the blocks) blockchains. This requires a reasonably nontrivial diff in the functional tests however it is mostly straightforward changes.
1 parent 09c7a0b commit 295ff37

File tree

4 files changed

+188
-292
lines changed

4 files changed

+188
-292
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,16 +3262,10 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
32623262

32633263
let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
32643264

3265-
3266-
// This assertion should be enforced in tests, however we have a number of tests that
3267-
// were written before this requirement and do not meet it.
3268-
#[cfg(not(test))]
3269-
{
3270-
assert_eq!(*self.last_block_hash.read().unwrap(), header.prev_blockhash,
3271-
"Blocks must be connected in chain-order - the connected header must build on the last connected header");
3272-
assert_eq!(self.latest_block_height.load(Ordering::Acquire) as u64, height as u64 - 1,
3273-
"Blocks must be connected in chain-order - the connected header must build on the last connected header");
3274-
}
3265+
assert_eq!(*self.last_block_hash.read().unwrap(), header.prev_blockhash,
3266+
"Blocks must be connected in chain-order - the connected header must build on the last connected header");
3267+
assert_eq!(self.latest_block_height.load(Ordering::Acquire) as u64, height as u64 - 1,
3268+
"Blocks must be connected in chain-order - the connected header must build on the last connected header");
32753269
self.latest_block_height.store(height as usize, Ordering::Release);
32763270
*self.last_block_hash.write().unwrap() = block_hash;
32773271

0 commit comments

Comments
 (0)