Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Commit 25ba992

Browse files
committed
Fix stake delegate transaction unit test
1 parent 07c7d78 commit 25ba992

1 file changed

Lines changed: 7 additions & 35 deletions

File tree

crates/gem_evm/src/rpc/mapper.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -410,44 +410,16 @@ mod tests {
410410

411411
#[test]
412412
fn test_map_smartchain_staking_transaction() {
413-
let transaction = Transaction {
414-
hash: "0x21442c7c30a6c1d6be3b5681275adb1f1402cef066579c4f53ec4f1c8c056ab0".to_string(),
415-
from: "0xf1a3687303606a6fd48179ce503164cdcbabeab6".to_string(),
416-
to: Some("0x0000000000000000000000000000000000002002".to_string()),
417-
value: BigUint::parse_bytes(b"1158e460913d00000", 16).unwrap(),
418-
gas: 280395,
419-
input: "0x982ef0a7000000000000000000000000d34403249b2d82aaddb14e778422c966265e5fb50000000000000000000000000000000000000000000000000000000000000000".to_string(),
420-
block_number: BigUint::from(0x1234u32),
421-
};
422-
423-
let receipt = TransactionReciept {
424-
gas_used: BigUint::from(100000u32),
425-
effective_gas_price: BigUint::from(20000000000u64),
426-
l1_fee: None,
427-
logs: vec![Log {
428-
address: "0x0000000000000000000000000000000000002002".to_string(),
429-
topics: vec![
430-
"0x24d7bda8602b916d64417f0dbfe2e2e88ec9b1157bd9f596dfdb91ba26624e04".to_string(), // Delegated event
431-
"0x000000000000000000000000d34403249B2d82AAdDB14e778422c966265e5Fb5".to_string(), // operatorAddress
432-
"0x000000000000000000000000f1a3687303606a6fD48179Ce503164CDcBAbeaB6".to_string(), // delegator
433-
],
434-
data: "0x00000000000000000000000000000000000000000000000d5cc0065cf2d900aa0000000000000000000000000000000000000000000000001158e460913d00000".to_string(),
435-
transaction_hash: None,
436-
}],
437-
status: "0x1".to_string(),
438-
block_hash: "0x1111111111111111111111111111111111111111111111111111111111111111".to_string(),
439-
block_number: BigUint::from(0x1234u32),
440-
};
441-
442-
let result = EthereumMapper::map_transaction(Chain::SmartChain, &transaction, &receipt, None, &BigUint::from(1735671600u64), None);
413+
let transaction = load_json_rpc_result::<Transaction>(include_str!("../../testdata/smartchain/transaction_staking_delegate.json"));
414+
let receipt = load_json_rpc_result::<TransactionReciept>(include_str!("../../testdata/smartchain/transaction_staking_delegate_receipt.json"));
415+
let tx = EthereumMapper::map_transaction(Chain::SmartChain, &transaction, &receipt, None, &BigUint::from(1735671600u64), None).unwrap();
443416

444-
assert!(result.is_some());
445-
let tx = result.unwrap();
446417
assert_eq!(tx.transaction_type, TransactionType::StakeDelegate);
447-
assert_eq!(tx.from, "0xf1a3687303606a6fD48179Ce503164CDcBAbeaB6");
418+
assert_eq!(tx.from, "0x51eD60604637989d19D29e43c5D94B098A0d1Af7");
448419
assert_eq!(tx.to, "0xd34403249B2d82AAdDB14e778422c966265e5Fb5");
449-
assert_eq!(tx.contract.unwrap(), "0x0000000000000000000000000000000000002002");
450-
assert!(tx.metadata.is_none());
420+
assert_eq!(tx.contract.as_deref(), Some("0x0000000000000000000000000000000000002002"));
421+
assert_eq!(tx.value, "1000000000000000000");
422+
assert_eq!(tx.metadata, None);
451423
}
452424

453425
#[test]

0 commit comments

Comments
 (0)