From 6249d48b788d54dd029856cd6e15c34a1e2dbf5e Mon Sep 17 00:00:00 2001 From: Mitch Turner Date: Thu, 17 Oct 2024 17:05:16 +0200 Subject: [PATCH] Add test for decreasing activity --- .../v1/tests/update_l2_block_data_tests.rs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/fuel-gas-price-algorithm/src/v1/tests/update_l2_block_data_tests.rs b/crates/fuel-gas-price-algorithm/src/v1/tests/update_l2_block_data_tests.rs index dab0be23dc..78df62d1a1 100644 --- a/crates/fuel-gas-price-algorithm/src/v1/tests/update_l2_block_data_tests.rs +++ b/crates/fuel-gas-price-algorithm/src/v1/tests/update_l2_block_data_tests.rs @@ -789,3 +789,35 @@ fn update_l2_block_data__above_threshold_increase_activity() { let actual = updater.l2_activity.current_activity(); assert_eq!(actual, expected); } + +#[test] +fn update_l2_block_data__below_threshold_decrease_activity() { + // given + let starting_exec_gas_price = 100; + let exec_gas_price_increase_percent = 10; + let threshold = 50; + let starting_activity = 2; + let activity = L2ActivityTracker::new(1, 1, 1, starting_activity, 50.into()); + let mut updater = UpdaterBuilder::new() + .with_starting_exec_gas_price(starting_exec_gas_price) + .with_exec_gas_price_change_percent(exec_gas_price_increase_percent) + .with_l2_block_capacity_threshold(threshold) + .with_activity(activity) + .build(); + + let height = 1; + let used = 40; + let capacity = 100.try_into().unwrap(); + let block_bytes = 1000; + let fee = 200; + + // when + updater + .update_l2_block_data(height, used, capacity, block_bytes, fee) + .unwrap(); + + // then + let expected = starting_activity - 1; + let actual = updater.l2_activity.current_activity(); + assert_eq!(actual, expected); +}