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`.
This commit is contained in:
Tobin C. Harding 2022-12-06 10:52:11 +11:00
parent 3ec8a12428
commit 296f2ed82c
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 2 additions and 1 deletions

View File

@ -271,12 +271,13 @@ mod test {
// Compare strings because the spec specifically states how the chain hash must encode to hex. // Compare strings because the spec specifically states how the chain hash must encode to hex.
assert_eq!(got, want); assert_eq!(got, want);
#[allow(unreachable_patterns)] // This is specifically trying to catch later added variants.
match network { match network {
Network::Bitcoin => {}, Network::Bitcoin => {},
Network::Testnet => {}, Network::Testnet => {},
Network::Signet => {}, Network::Signet => {},
Network::Regtest => {}, 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"),
} }
} }