Implement POST validators/validator_balances APIs (#4872)

* Add POST for fetching validators from state

* Implement POST for balances

* Tests
This commit is contained in:
Michael Sproul
2023-12-08 12:09:36 +11:00
committed by GitHub
parent e02adbf7bf
commit b882519d2f
5 changed files with 305 additions and 108 deletions

View File

@@ -850,6 +850,18 @@ impl ApiTester {
.await
.unwrap()
.map(|res| res.data);
let result_post_index_ids = self
.client
.post_beacon_states_validator_balances(state_id.0, validator_index_ids)
.await
.unwrap()
.map(|res| res.data);
let result_post_pubkey_ids = self
.client
.post_beacon_states_validator_balances(state_id.0, validator_pubkey_ids)
.await
.unwrap()
.map(|res| res.data);
let expected = state_opt.map(|(state, _execution_optimistic, _finalized)| {
let mut validators = Vec::with_capacity(validator_indices.len());
@@ -868,6 +880,8 @@ impl ApiTester {
assert_eq!(result_index_ids, expected, "{:?}", state_id);
assert_eq!(result_pubkey_ids, expected, "{:?}", state_id);
assert_eq!(result_post_index_ids, expected, "{:?}", state_id);
assert_eq!(result_post_pubkey_ids, expected, "{:?}", state_id);
}
}
@@ -913,7 +927,6 @@ impl ApiTester {
.await
.unwrap()
.map(|res| res.data);
let result_pubkey_ids = self
.client
.get_beacon_states_validators(
@@ -924,6 +937,18 @@ impl ApiTester {
.await
.unwrap()
.map(|res| res.data);
let post_result_index_ids = self
.client
.post_beacon_states_validators(state_id.0, Some(validator_index_ids), None)
.await
.unwrap()
.map(|res| res.data);
let post_result_pubkey_ids = self
.client
.post_beacon_states_validators(state_id.0, Some(validator_pubkey_ids), None)
.await
.unwrap()
.map(|res| res.data);
let expected = state_opt.map(|state| {
let epoch = state.current_epoch();
@@ -959,6 +984,8 @@ impl ApiTester {
assert_eq!(result_index_ids, expected, "{:?}", state_id);
assert_eq!(result_pubkey_ids, expected, "{:?}", state_id);
assert_eq!(post_result_index_ids, expected, "{:?}", state_id);
assert_eq!(post_result_pubkey_ids, expected, "{:?}", state_id);
}
}
}