From 2664d03917fe5c22cbeb5e6756235ffa8755db08 Mon Sep 17 00:00:00 2001 From: ar Date: Wed, 24 Jul 2024 18:22:54 -0400 Subject: [PATCH] Adds a test for `lockbox_input_value()` --- zebra-consensus/src/block/subsidy/general.rs | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/zebra-consensus/src/block/subsidy/general.rs b/zebra-consensus/src/block/subsidy/general.rs index 57371c5d465..a962b599c7f 100644 --- a/zebra-consensus/src/block/subsidy/general.rs +++ b/zebra-consensus/src/block/subsidy/general.rs @@ -421,4 +421,42 @@ mod test { Ok(()) } + + #[test] + fn check_lockbox_input_value() -> Result<(), Report> { + let _init_guard = zebra_test::init(); + + let network = Network::Mainnet; + let nu6_height = Nu6.activation_height(&network).unwrap(); + let post_nu6_funding_streams = network.post_nu6_funding_streams(); + let height_range = post_nu6_funding_streams.height_range(); + + let last_funding_stream_height = post_nu6_funding_streams + .height_range() + .end + .previous() + .expect("the previous height should be valid"); + + assert_eq!( + Amount::::zero(), + lockbox_input_value(&network, Height::MIN) + ); + + let expected_lockbox_value: Amount = Amount::try_from(18_750_000)?; + assert_eq!( + expected_lockbox_value, + lockbox_input_value(&network, nu6_height) + ); + + let num_blocks_total = height_range.end.0 - height_range.start.0; + let expected_input_per_block: Amount = Amount::try_from(18_750_000)?; + let expected_lockbox_value = (expected_input_per_block * num_blocks_total.into())?; + + assert_eq!( + expected_lockbox_value, + lockbox_input_value(&network, last_funding_stream_height) + ); + + Ok(()) + } }