From 296f2ed82c638c121d9a24a8cbe45ddb85865994 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 6 Dec 2022 10:52:11 +1100 Subject: [PATCH] Make test panic instead of using code comment Currently we have a code comment that is supposed to assist devs in maintaining the `network::constants::Network` type by failing to build if a new variant is added. This plays havoc with the formatter because the comment is hanging at the bottom of a match block and the formatting thinks its for the proceeding line of code. Instead of using a code comment add a panic so the unit test fails if a new variant is added to `network::constants::Network`. --- bitcoin/src/blockdata/constants.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs index eb0534c8..0de5503c 100644 --- a/bitcoin/src/blockdata/constants.rs +++ b/bitcoin/src/blockdata/constants.rs @@ -271,12 +271,13 @@ mod test { // Compare strings because the spec specifically states how the chain hash must encode to hex. assert_eq!(got, want); + #[allow(unreachable_patterns)] // This is specifically trying to catch later added variants. match network { Network::Bitcoin => {}, Network::Testnet => {}, Network::Signet => {}, Network::Regtest => {}, - // Update ChainHash::using_genesis_block and chain_hash_genesis_block with new variants. + _ => panic!("Update ChainHash::using_genesis_block and chain_hash_genesis_block with new variants"), } }