From 04565682a877d32c679992b4e7915ed765a2e569 Mon Sep 17 00:00:00 2001 From: peg Date: Tue, 17 Dec 2024 10:28:26 +0100 Subject: [PATCH] Update staking pallet tests --- pallets/staking/src/mock.rs | 5 +++-- pallets/staking/src/tests.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pallets/staking/src/mock.rs b/pallets/staking/src/mock.rs index 5760f7403..2713a8953 100644 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -400,11 +400,12 @@ impl entropy_shared::AttestationHandler for MockAttestationHandler { _x25519_public_key: entropy_shared::X25519PublicKey, quote: Vec, _context: QuoteContext, - ) -> Result { + ) -> Result + { 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. diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index 2351623aa..da33f7c29 100644 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -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::::FailedAttestationCheck + Error::::BadQuote ); }) } @@ -338,7 +338,7 @@ fn it_doesnt_allow_changing_threshold_account_with_invalid_quote() { NULL_ARR, INVALID_QUOTE.to_vec() ), - Error::::FailedAttestationCheck + Error::::BadQuote ); }) } @@ -711,7 +711,7 @@ fn it_requires_attestation_before_validate_is_succesful() { joining_server_info.clone(), INVALID_QUOTE.to_vec(), ), - Error::::FailedAttestationCheck + Error::::BadQuote ); assert_eq!(Staking::threshold_server(bob), None);