Skip to content

Commit

Permalink
eip4895: add unit test for amount_wei Withdrawal (#1551)
Browse files Browse the repository at this point in the history
eip4895: add unit test for amount_wei Withdrawal
  • Loading branch information
tcoratger authored Oct 23, 2024
1 parent 7d49bc6 commit 3cc3830
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/eips/src/eip4895.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl<'a> IntoIterator for &'a mut Withdrawals {
#[cfg(all(test, feature = "serde"))]
mod tests {
use super::*;
use core::str::FromStr;

// <https://github.com/paradigmxyz/reth/issues/1614>
#[test]
Expand All @@ -129,4 +130,13 @@ mod tests {
let s = serde_json::to_string(&withdrawals).unwrap();
assert_eq!(input, s);
}

#[test]
fn test_withdrawal_amount_wei() {
let withdrawal =
Withdrawal { index: 1, validator_index: 2, address: Address::random(), amount: 454456 };

// Assert that the amount_wei method returns the correct value
assert_eq!(withdrawal.amount_wei(), U256::from_str("0x19d5348723000").unwrap());
}
}

0 comments on commit 3cc3830

Please sign in to comment.