@@ -149,42 +149,43 @@ impl<T> CapsuleArray<T> {
149149}
150150
151151mod test {
152- use crate::protocol::address::AztecAddress ;
153152 use crate::test::helpers::test_environment::TestEnvironment ;
154153 use super::CapsuleArray ;
155154
156155 global SLOT : Field = 1230 ;
157- global SCOPE : AztecAddress = AztecAddress { inner : 0xface };
158156
159157 #[test]
160158 unconstrained fn empty_array () {
161- let env = TestEnvironment ::new ();
159+ let mut env = TestEnvironment ::new ();
160+ let scope = env .create_light_account ();
162161 env .private_context (|context | {
163162 let contract_address = context .this_address ();
164163
165- let array : CapsuleArray <Field > = CapsuleArray ::at (contract_address , SLOT , SCOPE );
164+ let array : CapsuleArray <Field > = CapsuleArray ::at (contract_address , SLOT , scope );
166165 assert_eq (array .len (), 0 );
167166 });
168167 }
169168
170169 #[test(should_fail_with = "Attempted to read past the length of a CapsuleArray")]
171170 unconstrained fn empty_array_read () {
172- let env = TestEnvironment ::new ();
171+ let mut env = TestEnvironment ::new ();
172+ let scope = env .create_light_account ();
173173 env .private_context (|context | {
174174 let contract_address = context .this_address ();
175175
176- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
176+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
177177 let _ : Field = array .get (0 );
178178 });
179179 }
180180
181181 #[test]
182182 unconstrained fn array_push () {
183- let env = TestEnvironment ::new ();
183+ let mut env = TestEnvironment ::new ();
184+ let scope = env .create_light_account ();
184185 env .private_context (|context | {
185186 let contract_address = context .this_address ();
186187
187- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
188+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
188189 array .push (5 );
189190
190191 assert_eq (array .len (), 1 );
@@ -194,11 +195,12 @@ mod test {
194195
195196 #[test(should_fail_with = "Attempted to read past the length of a CapsuleArray")]
196197 unconstrained fn read_past_len () {
197- let env = TestEnvironment ::new ();
198+ let mut env = TestEnvironment ::new ();
199+ let scope = env .create_light_account ();
198200 env .private_context (|context | {
199201 let contract_address = context .this_address ();
200202
201- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
203+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
202204 array .push (5 );
203205
204206 let _ = array .get (1 );
@@ -207,11 +209,12 @@ mod test {
207209
208210 #[test]
209211 unconstrained fn array_remove_last () {
210- let env = TestEnvironment ::new ();
212+ let mut env = TestEnvironment ::new ();
213+ let scope = env .create_light_account ();
211214 env .private_context (|context | {
212215 let contract_address = context .this_address ();
213216
214- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
217+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
215218
216219 array .push (5 );
217220 array .remove (0 );
@@ -222,11 +225,12 @@ mod test {
222225
223226 #[test]
224227 unconstrained fn array_remove_some () {
225- let env = TestEnvironment ::new ();
228+ let mut env = TestEnvironment ::new ();
229+ let scope = env .create_light_account ();
226230 env .private_context (|context | {
227231 let contract_address = context .this_address ();
228232
229- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
233+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
230234
231235 array .push (7 );
232236 array .push (8 );
@@ -247,11 +251,12 @@ mod test {
247251
248252 #[test]
249253 unconstrained fn array_remove_all () {
250- let env = TestEnvironment ::new ();
254+ let mut env = TestEnvironment ::new ();
255+ let scope = env .create_light_account ();
251256 env .private_context (|context | {
252257 let contract_address = context .this_address ();
253258
254- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
259+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
255260
256261 array .push (7 );
257262 array .push (8 );
@@ -267,10 +272,11 @@ mod test {
267272
268273 #[test]
269274 unconstrained fn for_each_called_with_all_elements () {
270- let env = TestEnvironment ::new ();
275+ let mut env = TestEnvironment ::new ();
276+ let scope = env .create_light_account ();
271277 env .private_context (|context | {
272278 let contract_address = context .this_address ();
273- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
279+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
274280
275281 array .push (4 );
276282 array .push (5 );
@@ -290,10 +296,11 @@ mod test {
290296
291297 #[test]
292298 unconstrained fn for_each_remove_some () {
293- let env = TestEnvironment ::new ();
299+ let mut env = TestEnvironment ::new ();
300+ let scope = env .create_light_account ();
294301 env .private_context (|context | {
295302 let contract_address = context .this_address ();
296- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
303+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
297304
298305 array .push (4 );
299306 array .push (5 );
@@ -313,10 +320,11 @@ mod test {
313320
314321 #[test]
315322 unconstrained fn for_each_remove_all () {
316- let env = TestEnvironment ::new ();
323+ let mut env = TestEnvironment ::new ();
324+ let scope = env .create_light_account ();
317325 env .private_context (|context | {
318326 let contract_address = context .this_address ();
319- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
327+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
320328
321329 array .push (4 );
322330 array .push (5 );
@@ -330,10 +338,11 @@ mod test {
330338
331339 #[test]
332340 unconstrained fn for_each_remove_all_no_copy () {
333- let env = TestEnvironment ::new ();
341+ let mut env = TestEnvironment ::new ();
342+ let scope = env .create_light_account ();
334343 env .private_context (|context | {
335344 let contract_address = context .this_address ();
336- let array = CapsuleArray ::at (contract_address , SLOT , SCOPE );
345+ let array = CapsuleArray ::at (contract_address , SLOT , scope );
337346
338347 array .push (4 );
339348 array .push (5 );
@@ -351,11 +360,11 @@ mod test {
351360
352361 #[test]
353362 unconstrained fn different_scopes_are_isolated () {
354- let env = TestEnvironment ::new ();
363+ let mut env = TestEnvironment ::new ();
364+ let scope_a = env .create_light_account ();
365+ let scope_b = env .create_light_account ();
355366 env .private_context (|context | {
356367 let contract_address = context .this_address ();
357- let scope_a = AztecAddress { inner : 0xaaa };
358- let scope_b = AztecAddress { inner : 0xbbb };
359368
360369 let array_a = CapsuleArray ::at (contract_address , SLOT , scope_a );
361370 let array_b = CapsuleArray ::at (contract_address , SLOT , scope_b );
0 commit comments