Skip to content

Commit

Permalink
fix test data
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-shashank committed Oct 15, 2024
1 parent c2cd796 commit 3743a68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
25 changes: 11 additions & 14 deletions src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,48 +915,45 @@ pub(crate) mod tests {
fn test_parse_eip1559_tx() {
// Raw transaction hex for the EIP-1559 transaction
let raw_tx = hex::decode(
"02f8740181f1843b9aca00851535cf027f82520894e0e5d2b4edcc473b988b44b4d13c3972cb6694cb8801ea8d467f558e1e80c001a07eb3335f4fd4de25ec3452c08882f28fb098b2eaa37a332941f918d869f5c2ada059b9d4aa997c7fa34f1b167f98a12432bb1a4a35660d723a9c19bb76b4cd025d"
"02f86282013a8080808094ff000000000000000000000000000000000003ec8080c080a0f411a73e33523b40c1a916e79e67746bd01a4a4fb4ecfa87b441375a215ddfb4a0551692c1553574fab4c227ca70cb1c121dc3a2ef82179a9c984bd7acc0880a38"
).expect("Invalid hex");

let result = parse_eip1559_tx(&raw_tx);
assert!(result.is_ok());

if let EthTx::Eip1559(tx) = result.unwrap() {
// Assert chain ID
assert_eq!(tx.chain_id, 1);
assert_eq!(tx.chain_id, 314);

// Assert nonce
assert_eq!(tx.nonce, 241);
assert_eq!(tx.nonce, 0);

// Assert max fee per gas
assert_eq!(tx.max_fee_per_gas, BigInt::from(91097072255u64));
assert_eq!(tx.max_fee_per_gas, BigInt::from(0u64));

// Assert max priority fee per gas
assert_eq!(tx.max_priority_fee_per_gas, BigInt::from(1000000000u64));
assert_eq!(tx.max_priority_fee_per_gas, BigInt::from(0u64));

// Assert gas limit
assert_eq!(tx.gas_limit, 21000);
assert_eq!(tx.gas_limit, 0);

// Assert recipient address
assert_eq!(
tx.to.unwrap(),
EthAddress::from_str("0xe0e5d2b4edcc473b988b44b4d13c3972cb6694cb").unwrap()
EthAddress::from_str("0xff000000000000000000000000000000000003ec").unwrap()
);

// Assert value
assert_eq!(tx.value, BigInt::from(138078072511761950u64));

// Assert input data (not explicitly given in your values, assuming it's empty for now)
assert!(tx.input.is_empty());
assert_eq!(tx.value, BigInt::from(0));

// Assert v, r, s
assert_eq!(tx.v, BigInt::from(1u8));
assert_eq!(tx.v, BigInt::from(00u8));
assert_eq!(
tx.r,
BigInt::from_bytes_be(
Sign::Plus,
&hex::decode(
"7eb3335f4fd4de25ec3452c08882f28fb098b2eaa37a332941f918d869f5c2ad"
"f411a73e33523b40c1a916e79e67746bd01a4a4fb4ecfa87b441375a215ddfb4"
)
.unwrap()
)
Expand All @@ -966,7 +963,7 @@ pub(crate) mod tests {
BigInt::from_bytes_be(
Sign::Plus,
&hex::decode(
"59b9d4aa997c7fa34f1b167f98a12432bb1a4a35660d723a9c19bb76b4cd025d"
"551692c1553574fab4c227ca70cb1c121dc3a2ef82179a9c984bd7acc0880a38"
)
.unwrap()
)
Expand Down
2 changes: 1 addition & 1 deletion src/tool/subcommands/api_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ fn eth_tests_with_tipset<DB: Blockstore>(store: &Arc<DB>, shared_tipset: &Tipset
),
RpcTest::identity(EthGetTransactionHashByCid::request((block_cid,)).unwrap()),
RpcTest::identity(
EthSendRawTransaction::request((EthBytes(hex::decode("02f8740181f1843b9aca00851535cf027f82520894e0e5d2b4edcc473b988b44b4d13c3972cb6694cb8801ea8d467f558e1e80c001a07eb3335f4fd4de25ec3452c08882f28fb098b2eaa37a332941f918d869f5c2ada059b9d4aa997c7fa34f1b167f98a12432bb1a4a35660d723a9c19bb76b4cd025d").unwrap()),))
EthSendRawTransaction::request((EthBytes(hex::decode("02f86282013a8080808094ff000000000000000000000000000000000003ec8080c080a0f411a73e33523b40c1a916e79e67746bd01a4a4fb4ecfa87b441375a215ddfb4a0551692c1553574fab4c227ca70cb1c121dc3a2ef82179a9c984bd7acc0880a38").unwrap()),))
.unwrap(),
),
];
Expand Down

0 comments on commit 3743a68

Please sign in to comment.