@@ -16,6 +16,7 @@ use starkware_utils_testing::test_utils::{
1616    assert_expected_event_emitted, assert_panic_with_error, assert_panic_with_felt_error,
1717    cheat_caller_address_once,
1818};
19+ use  usdc_migration :: errors :: Errors ;
1920use  usdc_migration :: events :: USDCMigrationEvents :: USDCMigrated ;
2021use  usdc_migration :: interface :: {
2122    IUSDCMigrationAdminDispatcher , IUSDCMigrationAdminDispatcherTrait ,
@@ -30,6 +31,8 @@ use usdc_migration::tests::test_utils::{
3031    deploy_usdc_migration, generic_test_fixture, load_contract_address, load_u256 , new_user,
3132    supply_contract,
3233};
34+ use  usdc_migration :: usdc_migration :: USDCMigration :: {LARGE_BATCH_SIZE , SMALL_BATCH_SIZE };
35+ 
3336#[test]
3437fn  test_constructor () {
3538    let  cfg  =  deploy_usdc_migration ();
@@ -56,6 +59,7 @@ fn test_constructor() {
5659        load_contract_address (usdc_migration_contract , selector! (" starkgate_address"  )),
5760    );
5861    assert_eq! (LEGACY_THRESHOLD , load_u256 (usdc_migration_contract , selector! (" legacy_threshold"  )));
62+     assert_eq! (LARGE_BATCH_SIZE , load_u256 (usdc_migration_contract , selector! (" batch_size"  )));
5963    //  Assert owner is set correctly.
6064    let  ownable_dispatcher  =  IOwnableDispatcher  { contract_address :  usdc_migration_contract  };
6165    assert_eq! (ownable_dispatcher . owner (), cfg . owner);
@@ -73,6 +77,19 @@ fn test_set_legacy_threshold() {
7377    cheat_caller_address_once (contract_address :  usdc_migration_contract , caller_address :  cfg . owner);
7478    usdc_migration_admin_dispatcher . set_legacy_threshold (threshold :  new_threshold );
7579    assert_eq! (new_threshold , load_u256 (usdc_migration_contract , selector! (" legacy_threshold"  )));
80+     assert_eq! (LARGE_BATCH_SIZE , load_u256 (usdc_migration_contract , selector! (" batch_size"  )));
81+     //  Set the threshold to a new value that is less than the current transfer unit.
82+     let  new_threshold  =  LARGE_BATCH_SIZE  -  1 ;
83+     cheat_caller_address_once (contract_address :  usdc_migration_contract , caller_address :  cfg . owner);
84+     usdc_migration_admin_dispatcher . set_legacy_threshold (threshold :  new_threshold );
85+     assert_eq! (new_threshold , load_u256 (usdc_migration_contract , selector! (" legacy_threshold"  )));
86+     assert_eq! (SMALL_BATCH_SIZE , load_u256 (usdc_migration_contract , selector! (" batch_size"  )));
87+     //  Set the threshold to a new value that is greater than the current transfer unit.
88+     let  new_threshold  =  LEGACY_THRESHOLD ;
89+     cheat_caller_address_once (contract_address :  usdc_migration_contract , caller_address :  cfg . owner);
90+     usdc_migration_admin_dispatcher . set_legacy_threshold (threshold :  new_threshold );
91+     assert_eq! (new_threshold , load_u256 (usdc_migration_contract , selector! (" legacy_threshold"  )));
92+     assert_eq! (LARGE_BATCH_SIZE , load_u256 (usdc_migration_contract , selector! (" batch_size"  )));
7693}
7794
7895#[test]
@@ -87,6 +104,12 @@ fn test_set_legacy_threshold_assertions() {
87104    let  result  =  usdc_migration_admin_safe_dispatcher 
88105        . set_legacy_threshold (threshold :  LEGACY_THRESHOLD );
89106    assert_panic_with_felt_error (: result , expected_error :  OwnableErrors :: NOT_OWNER );
107+     //  Catch the invalid threshold error.
108+     let  invalid_threshold  =  1000 ;
109+     cheat_caller_address_once (contract_address :  usdc_migration_contract , caller_address :  cfg . owner);
110+     let  result  =  usdc_migration_admin_safe_dispatcher 
111+         . set_legacy_threshold (threshold :  invalid_threshold );
112+     assert_panic_with_felt_error (: result , expected_error :  Errors :: THRESHOLD_TOO_SMALL );
90113}
91114
92115#[test]
0 commit comments