Skip to content

Commit

Permalink
Adds a test for lockbox_input_value()
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Jul 24, 2024
1 parent d81b209 commit 2664d03
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions zebra-consensus/src/block/subsidy/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<NonNegative>::zero(),
lockbox_input_value(&network, Height::MIN)
);

let expected_lockbox_value: Amount<NonNegative> = 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<NonNegative> = 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(())
}
}

0 comments on commit 2664d03

Please sign in to comment.