From a04c1fa6820437306a6fcb225aaf45ba6d9d8e9c Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Mon, 6 May 2024 13:16:49 -0400 Subject: [PATCH] chore: add unit test --- stackslib/src/burnchains/tests/db.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stackslib/src/burnchains/tests/db.rs b/stackslib/src/burnchains/tests/db.rs index 9c3b5ee477..5a8d958f12 100644 --- a/stackslib/src/burnchains/tests/db.rs +++ b/stackslib/src/burnchains/tests/db.rs @@ -231,6 +231,15 @@ fn test_store_and_fetch() { } assert_eq!(&header, &non_canonical_block.header()); + // when we get a block header by its height, it's canonical + for (height, header) in headers.iter().enumerate() { + let hdr = BurnchainDB::get_burnchain_header(burnchain_db.conn(), &headers, height as u64) + .unwrap() + .unwrap(); + assert!(headers.iter().find(|h| **h == hdr).is_some()); + assert_ne!(hdr, non_canonical_block.header()); + } + let looked_up_canon = burnchain_db.get_canonical_chain_tip().unwrap(); assert_eq!(&looked_up_canon, &canonical_block.header());