@@ -63,9 +63,6 @@ const MAINNET_BRIDGE_FIXTURE: &str = concat!(
6363 "/tests/fixtures/wormhole_core_bridge_solana_mainnet.so"
6464) ;
6565
66- /// Guardian set index mainnet is at today, and therefore the highest index this test creates.
67- const CURRENT_MAINNET_GUARDIAN_SET_INDEX : u32 = 7 ;
68-
6966fn loader_account ( state : & UpgradeableLoaderState , elf : Option < & [ u8 ] > ) -> Account {
7067 let mut data = bincode:: serialize ( state) . unwrap ( ) ;
7168 if let Some ( elf) = elf {
@@ -186,6 +183,7 @@ fn close_guardian_set_instruction(recipient: Pubkey, guardian_set_index: u32) ->
186183 program_id : BRIDGE_ID ,
187184 accounts : vec ! [
188185 AccountMeta :: new( recipient, false ) ,
186+ AccountMeta :: new( bridge_address( ) , false ) ,
189187 AccountMeta :: new(
190188 get_guardian_set_address( BRIDGE_ID , guardian_set_index) ,
191189 false ,
@@ -239,8 +237,12 @@ async fn post_encoded_vaa(
239237 encoded_vaa. pubkey ( )
240238}
241239
240+ fn bridge_address ( ) -> Pubkey {
241+ Pubkey :: find_program_address ( & [ BridgeConfig :: SEED_PREFIX ] , & BRIDGE_ID ) . 0
242+ }
243+
242244async fn bridge_config ( program_simulator : & mut ProgramSimulator ) -> BridgeConfig {
243- let address = Pubkey :: find_program_address ( & [ BridgeConfig :: SEED_PREFIX ] , & BRIDGE_ID ) . 0 ;
245+ let address = bridge_address ( ) ;
244246 let account = program_simulator
245247 . get_account ( address)
246248 . await
@@ -361,15 +363,12 @@ async fn test_migrate_guardian_set_from_mainnet_bridge() {
361363 . unwrap ( ) ;
362364 }
363365
366+ let current_guardian_set_index = bridge_config ( & mut program_simulator)
367+ . await
368+ . guardian_set_index ;
369+
364370 assert_eq ! (
365- bridge_config( & mut program_simulator)
366- . await
367- . guardian_set_index,
368- CURRENT_MAINNET_GUARDIAN_SET_INDEX ,
369- "the bridge tracks mainnet's current guardian set index"
370- ) ;
371- assert_eq ! (
372- guardian_set( & mut program_simulator, CURRENT_MAINNET_GUARDIAN_SET_INDEX )
371+ guardian_set( & mut program_simulator, current_guardian_set_index)
373372 . await
374373 . unwrap( )
375374 . keys
@@ -455,7 +454,7 @@ async fn test_migrate_guardian_set_from_mainnet_bridge() {
455454 // in, so nothing below would dispatch to the new code without this.
456455 program_simulator. advance_slot ( ) . await . unwrap ( ) ;
457456
458- for guardian_set_index in 0 ..=CURRENT_MAINNET_GUARDIAN_SET_INDEX {
457+ for guardian_set_index in ( 0 ..=current_guardian_set_index ) . rev ( ) {
459458 program_simulator
460459 . process_ix_with_default_compute_limit (
461460 close_guardian_set_instruction ( payer. pubkey ( ) , guardian_set_index) ,
@@ -466,7 +465,7 @@ async fn test_migrate_guardian_set_from_mainnet_bridge() {
466465 . unwrap ( ) ;
467466 }
468467
469- for guardian_set_index in 0 ..=CURRENT_MAINNET_GUARDIAN_SET_INDEX {
468+ for guardian_set_index in 0 ..=current_guardian_set_index {
470469 assert ! (
471470 program_simulator
472471 . get_account( get_guardian_set_address( BRIDGE_ID , guardian_set_index) )
0 commit comments