@@ -16,6 +16,7 @@ use iota_rosetta::{
1616use iota_sdk:: rpc_types:: { IotaExecutionStatus , IotaTransactionBlockEffectsAPI } ;
1717use iota_swarm_config:: genesis_config:: { DEFAULT_GAS_AMOUNT , DEFAULT_NUMBER_OF_OBJECT_PER_ACCOUNT } ;
1818use iota_types:: {
19+ iota_system_state:: iota_system_state_summary:: IotaSystemStateSummary ,
1920 quorum_driver_types:: ExecuteTransactionRequestType , utils:: to_sender_signed_transaction,
2021} ;
2122use rosetta_client:: start_rosetta_test_server;
@@ -78,13 +79,17 @@ async fn test_get_staked_iota() {
7879 assert_eq ! ( response. balances[ 0 ] . value, 0 ) ;
7980
8081 // Stake some iota
81- let validator = client
82+ let system_state = client
8283 . governance_api ( )
8384 . get_latest_iota_system_state ( )
8485 . await
85- . unwrap ( )
86- . active_validators [ 0 ]
87- . iota_address ;
86+ . unwrap ( ) ;
87+ let active_validators = match system_state {
88+ IotaSystemStateSummary :: V1 ( v1) => v1. active_validators ,
89+ IotaSystemStateSummary :: V2 ( v2) => v2. active_validators ,
90+ _ => panic ! ( "unsupported IotaSystemStateSummary" ) ,
91+ } ;
92+ let validator = active_validators[ 0 ] . iota_address ;
8893 let coins = client
8994 . coin_read_api ( )
9095 . get_coins ( address, None , None , None )
@@ -136,13 +141,17 @@ async fn test_stake() {
136141
137142 let ( rosetta_client, _handle) = start_rosetta_test_server ( client. clone ( ) ) . await ;
138143
139- let validator = client
144+ let system_state = client
140145 . governance_api ( )
141146 . get_latest_iota_system_state ( )
142147 . await
143- . unwrap ( )
144- . active_validators [ 0 ]
145- . iota_address ;
148+ . unwrap ( ) ;
149+ let active_validators = match system_state {
150+ IotaSystemStateSummary :: V1 ( v1) => v1. active_validators ,
151+ IotaSystemStateSummary :: V2 ( v2) => v2. active_validators ,
152+ _ => panic ! ( "unsupported IotaSystemStateSummary" ) ,
153+ } ;
154+ let validator = active_validators[ 0 ] . iota_address ;
146155
147156 let ops = serde_json:: from_value ( json ! (
148157 [ {
@@ -197,13 +206,17 @@ async fn test_stake_all() {
197206
198207 let ( rosetta_client, _handle) = start_rosetta_test_server ( client. clone ( ) ) . await ;
199208
200- let validator = client
209+ let system_state = client
201210 . governance_api ( )
202211 . get_latest_iota_system_state ( )
203212 . await
204- . unwrap ( )
205- . active_validators [ 0 ]
206- . iota_address ;
213+ . unwrap ( ) ;
214+ let active_validators = match system_state {
215+ IotaSystemStateSummary :: V1 ( v1) => v1. active_validators ,
216+ IotaSystemStateSummary :: V2 ( v2) => v2. active_validators ,
217+ _ => panic ! ( "unsupported IotaSystemStateSummary" ) ,
218+ } ;
219+ let validator = active_validators[ 0 ] . iota_address ;
207220
208221 let ops = serde_json:: from_value ( json ! (
209222 [ {
@@ -263,13 +276,17 @@ async fn test_withdraw_stake() {
263276 let ( rosetta_client, _handle) = start_rosetta_test_server ( client. clone ( ) ) . await ;
264277
265278 // First add some stakes
266- let validator = client
279+ let system_state = client
267280 . governance_api ( )
268281 . get_latest_iota_system_state ( )
269282 . await
270- . unwrap ( )
271- . active_validators [ 0 ]
272- . iota_address ;
283+ . unwrap ( ) ;
284+ let active_validators = match system_state {
285+ IotaSystemStateSummary :: V1 ( v1) => v1. active_validators ,
286+ IotaSystemStateSummary :: V2 ( v2) => v2. active_validators ,
287+ _ => panic ! ( "unsupported IotaSystemStateSummary" ) ,
288+ } ;
289+ let validator = active_validators[ 0 ] . iota_address ;
273290
274291 let ops = serde_json:: from_value ( json ! (
275292 [ {
0 commit comments