Skip to content

Commit

Permalink
Return misdeleted dispatch_claiming_fails_when_eth_signature_invalid …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
dmitrylavrenov committed Aug 30, 2022
1 parent 462a6e5 commit d4d234e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions crates/humanode-runtime/src/tests/claims_and_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,44 @@ fn dispatch_unlock_partial_balance_works() {
})
}

/// This test verifies that dispatch claiming fails if ethereum_address
/// doesn't correspond to submitted ethereum_signature.
#[test]
fn dispatch_claiming_fails_when_eth_signature_invalid() {
// Build the state from the config.
new_test_ext().execute_with(move || {
// Prepare token claim data that are used to validate and apply `CheckedExtrinsic`.
let (checked_extrinsic, normal_dispatch_info, len) = prepare_applyable_data(
Call::TokenClaims(pallet_token_claims::Call::claim {
ethereum_address: EthereumAddress::default(),
ethereum_signature: EcdsaSignature::default(),
}),
account_id("Alice"),
);

// Validate already checked extrinsic.
assert_noop!(
Applyable::validate::<Runtime>(
&checked_extrinsic,
sp_runtime::transaction_validity::TransactionSource::Local,
&normal_dispatch_info,
len,
),
TransactionValidityError::Invalid(InvalidTransaction::BadProof)
);
// Apply already checked extrinsic.
//
// We don't use assert_noop as apply invokes pre_dispatch that uses fee.
// As a result state is changed.
assert_eq!(
Applyable::apply::<Runtime>(checked_extrinsic, &normal_dispatch_info, len),
Err(TransactionValidityError::Invalid(
InvalidTransaction::BadProof
))
);
})
}

/// This test verifies that dispatch claiming fails in case not existing claim.
#[test]
fn dispatch_claiming_fails_when_no_claim() {
Expand Down

0 comments on commit d4d234e

Please sign in to comment.