@@ -260,76 +260,6 @@ fn migration_populates_precompile_mappings() {
260260 } ) ;
261261}
262262
263- /// Test that the migration is idempotent - running it twice produces the same result.
264- ///
265- /// Idempotency is critical: the second run should not modify any existing mappings.
266- #[ test]
267- fn migration_is_idempotent ( ) {
268- new_test_ext ( ) . execute_with ( || {
269- let owner = 1u64 ;
270-
271- let asset_location_1 = Location :: new ( 1 , [ Junction :: Parachain ( 1234 ) ] ) ;
272- let asset_location_2 = Location :: new ( 1 , [ Junction :: Parachain ( 5678 ) ] ) ;
273-
274- pallet_assets:: Asset :: < Test , ForeignAssetsInstance > :: insert (
275- asset_location_1. clone ( ) ,
276- create_asset_details ( owner) ,
277- ) ;
278- pallet_assets:: Asset :: < Test , ForeignAssetsInstance > :: insert (
279- asset_location_2. clone ( ) ,
280- create_asset_details ( owner) ,
281- ) ;
282-
283- // Verify mappings do not exist before migration
284- assert ! (
285- pallet:: Pallet :: <Test >:: asset_index_of( & asset_location_1) . is_none( ) ,
286- "Mapping 1 should NOT exist before migration"
287- ) ;
288- assert ! (
289- pallet:: Pallet :: <Test >:: asset_index_of( & asset_location_2) . is_none( ) ,
290- "Mapping 2 should NOT exist before migration"
291- ) ;
292-
293- run_migration_to_completion ( ) ;
294-
295- // Get the indices assigned during first run
296- let index_1 = pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_1) . unwrap ( ) ;
297- let index_2 = pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_2) . unwrap ( ) ;
298-
299- // Capture complete state after first run
300- let state_after_first = (
301- pallet:: Pallet :: < Test > :: asset_id_of ( index_1) ,
302- pallet:: Pallet :: < Test > :: asset_id_of ( index_2) ,
303- pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_1) ,
304- pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_2) ,
305- pallet:: Pallet :: < Test > :: next_asset_index ( ) ,
306- ) ;
307-
308- // Verify mappings were created correctly after first run
309- assert ! ( state_after_first. 0 . is_some( ) , "Forward mapping 1 should exist after first run" ) ;
310- assert ! ( state_after_first. 1 . is_some( ) , "Forward mapping 2 should exist after first run" ) ;
311- assert ! ( state_after_first. 2 . is_some( ) , "Reverse mapping 1 should exist after first run" ) ;
312- assert ! ( state_after_first. 3 . is_some( ) , "Reverse mapping 2 should exist after first run" ) ;
313-
314- run_migration_to_completion ( ) ;
315-
316- // Capture complete state after second run
317- let state_after_second = (
318- pallet:: Pallet :: < Test > :: asset_id_of ( index_1) ,
319- pallet:: Pallet :: < Test > :: asset_id_of ( index_2) ,
320- pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_1) ,
321- pallet:: Pallet :: < Test > :: asset_index_of ( & asset_location_2) ,
322- pallet:: Pallet :: < Test > :: next_asset_index ( ) ,
323- ) ;
324-
325- // State must be identical after second run
326- assert_eq ! (
327- state_after_first, state_after_second,
328- "Idempotency violation: migration modified mappings on second run"
329- ) ;
330- } ) ;
331- }
332-
333263/// Test that the migration handles the case with no foreign assets gracefully.
334264#[ test]
335265fn migration_handles_empty_foreign_assets ( ) {
0 commit comments