Skip to content

Commit

Permalink
test: test exception
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed Sep 17, 2024
1 parent 8dfee10 commit fe35d86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions bins/revme/src/cmd/statetest/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ pub struct TestAuthorization {
impl TestAuthorization {
pub fn signature(&self) -> Signature {
let v = u64::try_from(self.v).unwrap_or(u64::MAX);
let parity = Parity::try_from(v).unwrap();
Signature::from_rs_and_parity(self.r, self.s, parity).unwrap()
let parity =
Parity::try_from(v).map_err(|_| TransactionException::Type4InvalidAuthoritySignature);
Signature::from_rs_and_parity(self.r, self.s, parity.unwrap()).unwrap()
}

pub fn into_recovered(self) -> Result<RecoveredAuthorization, TransactionException> {
pub fn into_recovered(self) -> RecoveredAuthorization {
let authorization = Authorization {
chain_id: self.chain_id,
address: self.address,
Expand All @@ -158,11 +159,11 @@ impl TestAuthorization {
let authority = self
.signature()
.recover_address_from_prehash(&authorization.signature_hash())
.map_err(|_| TransactionException::Type4InvalidAuthoritySignature);
Ok(RecoveredAuthorization::new_unchecked(
.ok();
RecoveredAuthorization::new_unchecked(
authorization.into_signed(self.signature()),
authority.ok(),
))
authority,
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub fn execute_test_suite(
unit.transaction
.authorization_list
.iter()
.filter_map(|auth| auth.into_recovered().ok())
.map(|auth| auth.into_recovered())
.collect(),
));

Expand Down

0 comments on commit fe35d86

Please sign in to comment.