11use starknet :: {ContractAddress , contract_address_const};
2- use snforge_std as snf;
3- use snforge_std :: {
4- ContractClassTrait , spy_events, EventSpy , start_cheat_caller_address, stop_cheat_caller_address,
5- EventSpyAssertionsTrait
6- };
2+ use snforge_std :: {start_cheat_caller_address};
73
84// Contracts
95use carbon_v3 :: components :: offsetter :: interface :: {
106 IOffsetHandlerDispatcher , IOffsetHandlerDispatcherTrait
117};
12- use carbon_v3 :: components :: offsetter :: OffsetComponent ;
138
149/// Utils for testing purposes
1510use super :: tests_lib :: {default_setup_and_deploy, deploy_offsetter};
1611
1712/// Utils to import mock data
1813use super :: tests_lib :: {
19- MERKLE_ROOT_FIRST_WAVE , MERKLE_ROOT_SECOND_WAVE , get_bob_first_wave_allocation ,
20- get_bob_second_wave_allocation, get_alice_second_wave_allocation, get_john_multiple_allocations
14+ MERKLE_ROOT_FIRST_WAVE , get_bob_first_wave_allocation, get_bob_second_wave_allocation ,
15+ get_alice_second_wave_allocation, get_john_multiple_allocations
2116};
2217
2318#[test]
@@ -66,7 +61,7 @@ fn test_bob_claims_single_allocation() {
6661 start_cheat_caller_address (offsetter_address , bob_address );
6762 assert_eq! (contract . get_merkle_root (), root );
6863
69- assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , id , proof ));
64+ assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , 1 , id , proof ));
7065}
7166
7267#[test]
@@ -81,9 +76,9 @@ fn test_claim_with_invalid_address() {
8176 start_cheat_caller_address (offsetter_address , owner_address );
8277 contract . set_merkle_root (root );
8378 let invalid_address = contract_address_const :: <' DUMMY' >();
84- assert! (! contract . check_claimed (invalid_address , timestamp , amount , id ));
79+ assert! (! contract . check_claimed (invalid_address , timestamp , amount , 1 , id ));
8580
86- assert! (! contract . confirm_for_merkle_tree (invalid_address , amount , timestamp , id , proof ));
81+ assert! (! contract . confirm_for_merkle_tree (invalid_address , amount , timestamp , 1 , id , proof ));
8782}
8883
8984#[test]
@@ -98,9 +93,11 @@ fn test_claim_with_invalid_amount() {
9893 start_cheat_caller_address (offsetter_address , owner_address );
9994 contract . set_merkle_root (root );
10095 let invalid_amount = 0 ;
101- assert! (! contract . check_claimed (bob_address , timestamp , invalid_amount , id ));
96+ assert! (! contract . check_claimed (bob_address , timestamp , invalid_amount , 1 , id ));
10297
103- assert! (! contract . confirm_for_merkle_tree (bob_address , invalid_amount , timestamp , id , proof ));
98+ assert! (
99+ ! contract . confirm_for_merkle_tree (bob_address , invalid_amount , timestamp , 1 , id , proof )
100+ );
104101}
105102
106103#[test]
@@ -115,9 +112,11 @@ fn test_claim_with_invalid_timestamp() {
115112 start_cheat_caller_address (offsetter_address , owner_address );
116113 contract . set_merkle_root (root );
117114 let invalid_timestamp = 0 ;
118- assert! (! contract . check_claimed (bob_address , invalid_timestamp , amount , id ));
115+ assert! (! contract . check_claimed (bob_address , invalid_timestamp , amount , 1 , id ));
119116
120- assert! (! contract . confirm_for_merkle_tree (bob_address , amount , invalid_timestamp , id , proof ));
117+ assert! (
118+ ! contract . confirm_for_merkle_tree (bob_address , amount , invalid_timestamp , 1 , id , proof )
119+ );
121120}
122121
123122#[test]
@@ -132,9 +131,11 @@ fn test_claim_with_invalid_proof() {
132131 start_cheat_caller_address (offsetter_address , owner_address );
133132 contract . set_merkle_root (root );
134133 let invalid_proof : Array <felt252 > = array! [0x123 , 0x1 ];
135- assert! (! contract . check_claimed (bob_address , timestamp , amount , id ));
134+ assert! (! contract . check_claimed (bob_address , timestamp , amount , 1 , id ));
136135
137- assert! (! contract . confirm_for_merkle_tree (bob_address , amount , timestamp , id , invalid_proof ));
136+ assert! (
137+ ! contract . confirm_for_merkle_tree (bob_address , amount , timestamp , 1 , id , invalid_proof )
138+ );
138139}
139140
140141#[test]
@@ -149,13 +150,13 @@ fn test_claim_after_root_update() {
149150
150151 start_cheat_caller_address (offsetter_address , owner_address );
151152 contract . set_merkle_root (root );
152- assert! (! contract . check_claimed (bob_address , timestamp , amount , id ));
153+ assert! (! contract . check_claimed (bob_address , timestamp , amount , 1 , id ));
153154
154155 let (new_root , _ , _ , _ , _ , new_proof ) = get_bob_second_wave_allocation ();
155156 contract . set_merkle_root (new_root );
156- assert! (! contract . check_claimed (bob_address , timestamp , amount , id ));
157+ assert! (! contract . check_claimed (bob_address , timestamp , amount , 1 , id ));
157158
158- assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , id , new_proof ));
159+ assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , 1 , id , new_proof ));
159160}
160161
161162#[test]
@@ -170,17 +171,17 @@ fn test_alice_claims_in_second_wave() {
170171
171172 start_cheat_caller_address (offsetter_address , owner_address );
172173 contract . set_merkle_root (root );
173- assert! (! contract . check_claimed (bob_address , timestamp , amount , id ));
174+ assert! (! contract . check_claimed (bob_address , timestamp , amount , 1 , id ));
174175
175- assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , id , proof ));
176+ assert! (contract . confirm_for_merkle_tree (bob_address , amount , timestamp , 1 , id , proof ));
176177
177178 let (new_root , alice_address , amount , timestamp , id , proof ) =
178179 get_alice_second_wave_allocation ();
179180 start_cheat_caller_address (offsetter_address , owner_address );
180181 contract . set_merkle_root (new_root );
181- assert! (! contract . check_claimed (alice_address , timestamp , amount , id ));
182+ assert! (! contract . check_claimed (alice_address , timestamp , amount , 1 , id ));
182183
183- assert! (contract . confirm_for_merkle_tree (alice_address , amount , timestamp , id , proof ));
184+ assert! (contract . confirm_for_merkle_tree (alice_address , amount , timestamp , 1 , id , proof ));
184185}
185186
186187#[test]
@@ -217,15 +218,15 @@ fn test_john_claims_multiple_allocations() {
217218
218219 start_cheat_caller_address (offsetter_address , owner_address );
219220 contract . set_merkle_root (root );
220- assert! (! contract . check_claimed (john_address , timestamp1 , amount1 , id_1 ));
221- assert! (! contract . check_claimed (john_address , timestamp2 , amount2 , id_2 ));
222- assert! (! contract . check_claimed (john_address , timestamp3 , amount3 , id_3 ));
221+ assert! (! contract . check_claimed (john_address , timestamp1 , amount1 , 1 , id_1 ));
222+ assert! (! contract . check_claimed (john_address , timestamp2 , amount2 , 1 , id_2 ));
223+ assert! (! contract . check_claimed (john_address , timestamp3 , amount3 , 1 , id_3 ));
223224
224- assert! (contract . confirm_for_merkle_tree (john_address , amount1 , timestamp1 , id_1 , proof1 ));
225- assert! (contract . confirm_for_merkle_tree (john_address , amount2 , timestamp2 , id_2 , proof2 ));
225+ assert! (contract . confirm_for_merkle_tree (john_address , amount1 , timestamp1 , 1 , id_1 , proof1 ));
226+ assert! (contract . confirm_for_merkle_tree (john_address , amount2 , timestamp2 , 1 , id_2 , proof2 ));
226227
227228 start_cheat_caller_address (offsetter_address , owner_address );
228229 contract . set_merkle_root (new_root );
229230
230- assert! (contract . confirm_for_merkle_tree (john_address , amount4 , timestamp4 , id_4 , proof4 ));
231+ assert! (contract . confirm_for_merkle_tree (john_address , amount4 , timestamp4 , 1 , id_4 , proof4 ));
231232}
0 commit comments