@@ -1172,12 +1172,12 @@ fn pos_rewards() -> Result<()> {
11721172 genesis. parameters . parameters . max_expected_time_per_block = 1 ;
11731173 genesis. parameters . pos_params . pipeline_len = 2 ;
11741174 genesis. parameters . pos_params . unbonding_len = 4 ;
1175- setup:: set_validators ( 3 , genesis, base_dir, default_port_offset)
1175+ setup:: set_validators ( 1 , genesis, base_dir, default_port_offset)
11761176 } ,
11771177 None ,
11781178 ) ?;
11791179
1180- for i in 0 ..3 {
1180+ for i in 0 ..1 {
11811181 set_ethereum_bridge_mode (
11821182 & test,
11831183 & test. net . chain_id ,
@@ -1188,158 +1188,87 @@ fn pos_rewards() -> Result<()> {
11881188 }
11891189
11901190 // 1. Run 3 genesis validator ledger nodes
1191- let bg_validator_0 =
1191+ let _bg_validator_0 =
11921192 start_namada_ledger_node_wait_wasm ( & test, Some ( 0 ) , Some ( 40 ) ) ?
11931193 . background ( ) ;
1194- let bg_validator_1 =
1195- start_namada_ledger_node_wait_wasm ( & test, Some ( 1 ) , Some ( 40 ) ) ?
1196- . background ( ) ;
1197- let bg_validator_2 =
1198- start_namada_ledger_node_wait_wasm ( & test, Some ( 2 ) , Some ( 40 ) ) ?
1199- . background ( ) ;
1200-
1201- let validator_zero_rpc = get_actor_rpc ( & test, & Who :: Validator ( 0 ) ) ;
1202- let validator_one_rpc = get_actor_rpc ( & test, & Who :: Validator ( 1 ) ) ;
12031194
1204- // Submit a delegation from Bertha to validator-0
1205- let tx_args = vec ! [
1206- "bond" ,
1207- "--validator" ,
1208- "validator-0" ,
1209- "--source" ,
1210- BERTHA ,
1211- "--amount" ,
1212- "10000.0" ,
1213- "--gas-amount" ,
1214- "0" ,
1215- "--gas-token" ,
1216- NAM ,
1217- "--signing-keys" ,
1218- BERTHA_KEY ,
1219- "--ledger-address" ,
1220- & validator_zero_rpc,
1221- ] ;
1222-
1223- let mut client = run ! ( test, Bin :: Client , tx_args, Some ( 40 ) ) ?;
1224- client. exp_string ( "Transaction applied with result:" ) ?;
1225- client. exp_string ( "Transaction is valid." ) ?;
1226- client. assert_success ( ) ;
1227-
1228- // Check that all validator nodes processed the tx with same result
1229- let validator_0 = bg_validator_0. foreground ( ) ;
1230- let validator_1 = bg_validator_1. foreground ( ) ;
1231- let validator_2 = bg_validator_2. foreground ( ) ;
1232-
1233- // let expected_result = "all VPs accepted transaction";
1234- // validator_0.exp_string(expected_result)?;
1235- // validator_1.exp_string(expected_result)?;
1236- // validator_2.exp_string(expected_result)?;
1195+ let validator_0_rpc = get_actor_rpc ( & test, & Who :: Validator ( 0 ) ) ;
12371196
1238- let _bg_validator_0 = validator_0. background ( ) ;
1239- let _bg_validator_1 = validator_1. background ( ) ;
1240- let _bg_validator_2 = validator_2. background ( ) ;
1241- // put money in the validator account from its balance account so that it
1242- // can self-bond
1197+ // Put money in the validator account from its balance account so that it
1198+ // can pay gas fees
12431199 let tx_args = vec ! [
12441200 "transfer" ,
12451201 "--source" ,
1246- "validator-1 -balance-key" ,
1202+ "validator-0 -balance-key" ,
12471203 "--target" ,
1248- "validator-1 -validator-key" ,
1204+ "validator-0 -validator-key" ,
12491205 "--amount" ,
12501206 "100.0" ,
12511207 "--token" ,
12521208 "NAM" ,
12531209 "--node" ,
1254- & validator_one_rpc ,
1210+ & validator_0_rpc ,
12551211 ] ;
12561212 let mut client =
1257- run_as ! ( test, Who :: Validator ( 1 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
1258- client. exp_string ( "Transaction applied with result:" ) ?;
1213+ run_as ! ( test, Who :: Validator ( 0 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
12591214 client. exp_string ( "Transaction is valid." ) ?;
12601215 client. assert_success ( ) ;
1261- // Let validator-1 self-bond
1262- let tx_args = vec ! [
1263- "bond" ,
1264- "--validator" ,
1265- "validator-1" ,
1266- "--amount" ,
1267- "30000.0" ,
1268- "--gas-amount" ,
1269- "0" ,
1270- "--gas-token" ,
1216+
1217+ // Wait some epochs
1218+ let epoch = get_epoch ( & test, & validator_0_rpc) ?;
1219+ let wait_epoch = epoch + 4_u64 ;
1220+
1221+ let start = Instant :: now ( ) ;
1222+ let loop_timeout = Duration :: new ( 40 , 0 ) ;
1223+ loop {
1224+ if Instant :: now ( ) . duration_since ( start) > loop_timeout {
1225+ panic ! ( "Timed out waiting for epoch: {}" , wait_epoch) ;
1226+ }
1227+ let epoch = epoch_sleep ( & test, & validator_0_rpc, 40 ) ?;
1228+ if dbg ! ( epoch) >= wait_epoch {
1229+ break ;
1230+ }
1231+ }
1232+
1233+ let query_balance_args = vec ! [
1234+ "balance" ,
1235+ "--owner" ,
1236+ "validator-0" ,
1237+ "--token" ,
12711238 NAM ,
1272- "--signing-keys" ,
1273- "validator-1-validator-key" ,
1274- "--ledger-address" ,
1275- & validator_one_rpc,
1239+ "--node" ,
1240+ & validator_0_rpc,
12761241 ] ;
1277- let mut client =
1278- run_as ! ( test, Who :: Validator ( 1 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
1279- client. exp_string ( "Transaction applied with result:" ) ?;
1280- client. exp_string ( "Transaction is valid." ) ?;
1242+ let mut client = run ! ( test, Bin :: Client , query_balance_args, Some ( 40 ) ) ?;
12811243 client. assert_success ( ) ;
1282- // put money in the validator account from its balance account so that it
1283- // can self-bond
1244+
12841245 let tx_args = vec ! [
1285- "transfer" ,
1286- "--source" ,
1287- "validator-2-balance-key" ,
1288- "--target" ,
1289- "validator-2-validator-key" ,
1290- "--amount" ,
1291- "100.0" ,
1292- "--token" ,
1293- "NAM" ,
1246+ "claim-rewards" ,
1247+ "--validator" ,
1248+ "validator-0" ,
1249+ "--signing-keys" ,
1250+ "validator-0-validator-key" ,
12941251 "--node" ,
1295- & validator_one_rpc ,
1252+ & validator_0_rpc ,
12961253 ] ;
12971254 let mut client =
1298- run_as ! ( test, Who :: Validator ( 2 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
1255+ run_as ! ( test, Who :: Validator ( 0 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
12991256 client. exp_string ( "Transaction applied with result:" ) ?;
13001257 client. exp_string ( "Transaction is valid." ) ?;
13011258 client. assert_success ( ) ;
13021259
1303- // Let validator-2 self-bond
1304- let tx_args = vec ! [
1305- "bond" ,
1306- "--validator" ,
1307- "validator-2" ,
1308- "--amount" ,
1309- "25000.0" ,
1310- "--gas-amount" ,
1311- "0" ,
1312- "--gas-token" ,
1260+ let query_balance_args = vec ! [
1261+ "balance" ,
1262+ "--owner" ,
1263+ "validator-0" ,
1264+ "--token" ,
13131265 NAM ,
1314- "--signing-keys" ,
1315- "validator-2-validator-key" ,
1316- "--ledger-address" ,
1317- & validator_zero_rpc,
1266+ "--node" ,
1267+ & validator_0_rpc,
13181268 ] ;
1319- let mut client =
1320- run_as ! ( test, Who :: Validator ( 2 ) , Bin :: Client , tx_args, Some ( 40 ) ) ?;
1321- client. exp_string ( "Transaction is valid." ) ?;
1269+ let mut client = run ! ( test, Bin :: Client , query_balance_args, Some ( 40 ) ) ?;
13221270 client. assert_success ( ) ;
13231271
1324- // Wait some epochs
1325- let epoch = get_epoch ( & test, & validator_zero_rpc) ?;
1326- let wait_epoch = epoch + 4_u64 ;
1327- println ! (
1328- "Current epoch: {}, earliest epoch for withdrawal: {}" ,
1329- epoch, wait_epoch
1330- ) ;
1331-
1332- let start = Instant :: now ( ) ;
1333- let loop_timeout = Duration :: new ( 40 , 0 ) ;
1334- loop {
1335- if Instant :: now ( ) . duration_since ( start) > loop_timeout {
1336- panic ! ( "Timed out waiting for epoch: {}" , wait_epoch) ;
1337- }
1338- let epoch = epoch_sleep ( & test, & validator_zero_rpc, 40 ) ?;
1339- if dbg ! ( epoch) >= wait_epoch {
1340- break ;
1341- }
1342- }
13431272 Ok ( ( ) )
13441273}
13451274
0 commit comments