Skip to content

Commit

Permalink
test: assert
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Dec 10, 2024
1 parent 40db3e0 commit 7f3e8ab
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions crates/wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,33 +441,37 @@ mod tests {
use crate::{validate_tx_request, OdysseyWalletError};
use alloy_primitives::{Address, U256};
use alloy_rpc_types::TransactionRequest;

#[test]
fn no_value_allowed() {
matches!(
assert!(matches!(
validate_tx_request(&TransactionRequest::default().value(U256::from(1))),
Err(OdysseyWalletError::ValueNotZero)
);
));

matches!(validate_tx_request(&TransactionRequest::default().value(U256::from(0))), Ok(()));
assert!(matches!(
validate_tx_request(&TransactionRequest::default().value(U256::from(0))),
Ok(())
));
}

#[test]
fn no_from_allowed() {
matches!(
assert!(matches!(
validate_tx_request(&TransactionRequest::default().from(Address::ZERO)),
Err(OdysseyWalletError::FromSet)
);
));

matches!(validate_tx_request(&TransactionRequest::default()), Ok(()));
assert!(matches!(validate_tx_request(&TransactionRequest::default()), Ok(())));
}

#[test]
fn no_nonce_allowed() {
matches!(
assert!(matches!(
validate_tx_request(&TransactionRequest::default().nonce(1)),
Err(OdysseyWalletError::NonceSet)
);
));

matches!(validate_tx_request(&TransactionRequest::default()), Ok(()));
assert!(matches!(validate_tx_request(&TransactionRequest::default()), Ok(())));
}
}

0 comments on commit 7f3e8ab

Please sign in to comment.