mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
add client updates and test updates
This commit is contained in:
@@ -1633,7 +1633,7 @@ impl ApiTester {
|
||||
for block_id in self.interesting_block_ids() {
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_blocks_attestations(block_id.0)
|
||||
.get_beacon_blocks_attestations_v2(block_id.0)
|
||||
.await
|
||||
.unwrap()
|
||||
.map(|res| res.data);
|
||||
@@ -1666,7 +1666,7 @@ impl ApiTester {
|
||||
|
||||
pub async fn test_post_beacon_pool_attestations_valid(mut self) -> Self {
|
||||
self.client
|
||||
.post_beacon_pool_attestations(self.attestations.as_slice())
|
||||
.post_beacon_pool_attestations_v1(self.attestations.as_slice())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -1675,6 +1675,20 @@ impl ApiTester {
|
||||
"valid attestation should be sent to network"
|
||||
);
|
||||
|
||||
let fork_name = self
|
||||
.attestations
|
||||
.first()
|
||||
.map(|att| self.chain.spec.fork_name_at_slot::<E>(att.data().slot))
|
||||
.unwrap();
|
||||
self.client
|
||||
.post_beacon_pool_attestations_v2(self.attestations.as_slice(), fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"valid attestation should be sent to network"
|
||||
);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -1691,7 +1705,7 @@ impl ApiTester {
|
||||
|
||||
let err = self
|
||||
.client
|
||||
.post_beacon_pool_attestations(attestations.as_slice())
|
||||
.post_beacon_pool_attestations_v1(attestations.as_slice())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
@@ -1712,6 +1726,35 @@ impl ApiTester {
|
||||
"if some attestations are valid, we should send them to the network"
|
||||
);
|
||||
|
||||
let fork_name = self
|
||||
.attestations
|
||||
.first()
|
||||
.map(|att| self.chain.spec.fork_name_at_slot::<E>(att.data().slot))
|
||||
.unwrap();
|
||||
|
||||
let err_v2 = self
|
||||
.client
|
||||
.post_beacon_pool_attestations_v2(attestations.as_slice(), fork_name)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
match err_v2 {
|
||||
Error::ServerIndexedMessage(IndexedErrorMessage {
|
||||
code,
|
||||
message: _,
|
||||
failures,
|
||||
}) => {
|
||||
assert_eq!(code, 400);
|
||||
assert_eq!(failures.len(), self.attestations.len());
|
||||
}
|
||||
_ => panic!("query did not fail correctly"),
|
||||
}
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"if some attestations are valid, we should send them to the network"
|
||||
);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -1777,7 +1820,7 @@ impl ApiTester {
|
||||
pub async fn test_get_beacon_pool_attestations(self) -> Self {
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_pool_attestations(None, None)
|
||||
.get_beacon_pool_attestations_v1(None, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
@@ -1787,12 +1830,34 @@ impl ApiTester {
|
||||
|
||||
assert_eq!(result, expected);
|
||||
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_pool_attestations_v2(None, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
assert_eq!(result, expected);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_post_beacon_pool_attester_slashings_valid(mut self) -> Self {
|
||||
self.client
|
||||
.post_beacon_pool_attester_slashings(&self.attester_slashing)
|
||||
.post_beacon_pool_attester_slashings_v1(&self.attester_slashing)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"valid attester slashing should be sent to network"
|
||||
);
|
||||
|
||||
let fork_name = self
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(self.attester_slashing.attestation_1().data().slot);
|
||||
self.client
|
||||
.post_beacon_pool_attester_slashings_v2(&self.attester_slashing, fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -1816,7 +1881,21 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
self.client
|
||||
.post_beacon_pool_attester_slashings(&slashing)
|
||||
.post_beacon_pool_attester_slashings_v1(&slashing)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().now_or_never().is_none(),
|
||||
"invalid attester slashing should not be sent to network"
|
||||
);
|
||||
|
||||
let fork_name = self
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(self.attester_slashing.attestation_1().data().slot);
|
||||
self.client
|
||||
.post_beacon_pool_attester_slashings_v2(&slashing, fork_name)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
@@ -1831,7 +1910,7 @@ impl ApiTester {
|
||||
pub async fn test_get_beacon_pool_attester_slashings(self) -> Self {
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_pool_attester_slashings()
|
||||
.get_beacon_pool_attester_slashings_v1()
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
@@ -1840,6 +1919,14 @@ impl ApiTester {
|
||||
|
||||
assert_eq!(result, expected);
|
||||
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_pool_attester_slashings_v2()
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
assert_eq!(result, expected);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -3210,7 +3297,7 @@ impl ApiTester {
|
||||
.get_validator_aggregate_attestation_v2(
|
||||
attestation.data().slot,
|
||||
attestation.data().tree_hash_root(),
|
||||
attestation.committee_index(),
|
||||
attestation.committee_index().unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -3346,7 +3433,18 @@ impl ApiTester {
|
||||
let aggregate = self.get_aggregate().await;
|
||||
|
||||
self.client
|
||||
.post_validator_aggregate_and_proof::<E>(&[aggregate])
|
||||
.post_validator_aggregate_and_proof_v1::<E>(&[aggregate.clone()])
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(self.network_rx.network_recv.recv().await.is_some());
|
||||
|
||||
let fork_name = self
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(aggregate.message().aggregate().data().slot);
|
||||
self.client
|
||||
.post_validator_aggregate_and_proof_v2::<E>(&[aggregate], fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -3367,12 +3465,22 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
self.client
|
||||
.post_validator_aggregate_and_proof::<E>(&[aggregate])
|
||||
.post_validator_aggregate_and_proof_v1::<E>(&[aggregate.clone()])
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert!(self.network_rx.network_recv.recv().now_or_never().is_none());
|
||||
|
||||
let fork_name = self
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(aggregate.message().aggregate().data().slot);
|
||||
self.client
|
||||
.post_validator_aggregate_and_proof_v2::<E>(&[aggregate], fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(self.network_rx.network_recv.recv().now_or_never().is_none());
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -3471,7 +3579,7 @@ impl ApiTester {
|
||||
pub async fn test_post_validator_register_validator_slashed(self) -> Self {
|
||||
// slash a validator
|
||||
self.client
|
||||
.post_beacon_pool_attester_slashings(&self.attester_slashing)
|
||||
.post_beacon_pool_attester_slashings_v1(&self.attester_slashing)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -3584,7 +3692,7 @@ impl ApiTester {
|
||||
|
||||
// Attest to the current slot
|
||||
self.client
|
||||
.post_beacon_pool_attestations(self.attestations.as_slice())
|
||||
.post_beacon_pool_attestations_v1(self.attestations.as_slice())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -5224,7 +5332,7 @@ impl ApiTester {
|
||||
|
||||
// Attest to the current slot
|
||||
self.client
|
||||
.post_beacon_pool_attestations(self.attestations.as_slice())
|
||||
.post_beacon_pool_attestations_v1(self.attestations.as_slice())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -5279,7 +5387,7 @@ impl ApiTester {
|
||||
let expected_attestation_len = self.attestations.len();
|
||||
|
||||
self.client
|
||||
.post_beacon_pool_attestations(self.attestations.as_slice())
|
||||
.post_beacon_pool_attestations_v1(self.attestations.as_slice())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user