Skip to content

Commit

Permalink
Update staking pallet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Dec 17, 2024
1 parent 02d0a61 commit 0456568
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pallets/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ impl entropy_shared::AttestationHandler<AccountId> for MockAttestationHandler {
_x25519_public_key: entropy_shared::X25519PublicKey,
quote: Vec<u8>,
_context: QuoteContext,
) -> Result<entropy_shared::BoundedVecEncodedVerifyingKey, sp_runtime::DispatchError> {
) -> Result<entropy_shared::BoundedVecEncodedVerifyingKey, entropy_shared::VerifyQuoteError>
{
let quote: Result<[u8; 32], _> = quote.try_into();
match quote {
Ok(q) if q == VALID_QUOTE => Ok([0; 33].to_vec().try_into().unwrap()),
Ok(q) if q == INVALID_QUOTE => Err(sp_runtime::DispatchError::Other("Invalid quote")),
Ok(q) if q == INVALID_QUOTE => Err(entropy_shared::VerifyQuoteError::BadQuote),
_ => {
// We don't really want to verify quotes for tests in this pallet, so if we get
// something else we'll just accept it.
Expand Down
6 changes: 3 additions & 3 deletions pallets/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn it_doesnt_change_endpoint_with_invalid_quote() {

assert_noop!(
Staking::change_endpoint(RuntimeOrigin::signed(1), endpoint, INVALID_QUOTE.to_vec()),
Error::<Test>::FailedAttestationCheck
Error::<Test>::BadQuote
);
})
}
Expand Down Expand Up @@ -338,7 +338,7 @@ fn it_doesnt_allow_changing_threshold_account_with_invalid_quote() {
NULL_ARR,
INVALID_QUOTE.to_vec()
),
Error::<Test>::FailedAttestationCheck
Error::<Test>::BadQuote
);
})
}
Expand Down Expand Up @@ -711,7 +711,7 @@ fn it_requires_attestation_before_validate_is_succesful() {
joining_server_info.clone(),
INVALID_QUOTE.to_vec(),
),
Error::<Test>::FailedAttestationCheck
Error::<Test>::BadQuote
);

assert_eq!(Staking::threshold_server(bob), None);
Expand Down

0 comments on commit 0456568

Please sign in to comment.