@@ -7957,10 +7957,27 @@ mod canonical_bitcoin_blockchain {
79577957 . unwrap ( ) ;
79587958 assert_eq ! ( fork_2_is_canonical, None ) ;
79597959
7960- // These new blocks aren't part of the canonical chain, so they
7961- // should be marked as non-canonical. In order to make sure that
7962- // they get marked as such, we need to clear the is_canonical
7963- // column from some of the blocks in the table.
7960+ // Let's set the canonical chain again and verity that the new
7961+ // blocks are still not marked as canonical. Note that the
7962+ // guarantees of the set_canonical_bitcoin_blockchaion function is
7963+ // that non-canonical blocks are not marked as canonical, not that
7964+ // they are definitively marked as non-canonical.
7965+ db. set_canonical_bitcoin_blockchain ( & chain_tip) . await . unwrap ( ) ;
7966+ let fork_1_is_canonical = db
7967+ . is_block_canonical ( & fork_block_1. block_hash )
7968+ . await
7969+ . unwrap ( ) ;
7970+ assert_ne ! ( fork_1_is_canonical, Some ( true ) ) ;
7971+
7972+ let fork_2_is_canonical = db
7973+ . is_block_canonical ( & fork_block_2. block_hash )
7974+ . await
7975+ . unwrap ( ) ;
7976+ assert_ne ! ( fork_2_is_canonical, Some ( true ) ) ;
7977+
7978+ // In order to make sure that non-canonical blocks get marked as
7979+ // such, we need to clear the is_canonical column from some of the
7980+ // blocks in the table.
79647981 clear_is_canonical_bitcoin_blocks ( & db) . await ;
79657982 db. set_canonical_bitcoin_blockchain ( & chain_tip)
79667983 . await
0 commit comments