Skip to content

Commit 129b64f

Browse files
authored
chore(fill): add 7702 fill test (#124)
* chore(fill): add 7702 fill test Small test as I noticed we didn't have a fill test for 7702 txs. * chore(fill): add more assertion to fill tests
1 parent 3da498e commit 129b64f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/fill/alloy.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl Block for alloy::rpc::types::BlockOverrides {
424424
mod tests {
425425
use crate::{test_utils::test_trevm, NoopBlock, NoopCfg};
426426
use alloy::{
427-
consensus::{Header, TxEnvelope, EMPTY_ROOT_HASH},
427+
consensus::{Header, TxEnvelope, TxType, EMPTY_ROOT_HASH},
428428
rlp::Decodable,
429429
};
430430

@@ -434,7 +434,8 @@ mod tests {
434434
let raw_tx = alloy::primitives::hex::decode("02f86f0102843b9aca0085029e7822d68298f094d9e1459a7a482635700cbc20bbaf52d495ab9c9680841b55ba3ac080a0c199674fcb29f353693dd779c017823b954b3c69dffa3cd6b2a6ff7888798039a028ca912de909e7e6cdef9cdcaf24c54dd8c1032946dfa1d85c206b32a9064fe8").unwrap();
435435
let tx = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
436436

437-
let _ = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
437+
let trevm = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
438+
assert_eq!(trevm.tx().tx_type, TxType::Eip1559 as u8);
438439
}
439440

440441
#[test]
@@ -443,7 +444,8 @@ mod tests {
443444
let raw_tx = alloy::primitives::hex::decode("f9015482078b8505d21dba0083022ef1947a250d5630b4cf539739df2c5dacb4c659f2488d880c46549a521b13d8b8e47ff36ab50000000000000000000000000000000000000000000066ab5a608bd00a23f2fe000000000000000000000000000000000000000000000000000000000000008000000000000000000000000048c04ed5691981c42154c6167398f95e8f38a7ff00000000000000000000000000000000000000000000000000000000632ceac70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006c6ee5e31d828de241282b9606c8e98ea48526e225a0c9077369501641a92ef7399ff81c21639ed4fd8fc69cb793cfa1dbfab342e10aa0615facb2f1bcf3274a354cfe384a38d0cc008a11c2dd23a69111bc6930ba27a8").unwrap();
444445
let tx = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
445446

446-
let _ = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
447+
let trevm = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
448+
assert_eq!(trevm.tx().tx_type, TxType::Legacy as u8);
447449
}
448450

449451
#[test]
@@ -453,7 +455,22 @@ mod tests {
453455
let raw_tx = alloy::primitives::hex::decode("0x03f9011d83aa36a7820fa28477359400852e90edd0008252089411e9ca82a3a762b4b5bd264d4173a242e7a770648080c08504a817c800f8a5a0012ec3d6f66766bedb002a190126b3549fce0047de0d4c25cffce0dc1c57921aa00152d8e24762ff22b1cfd9f8c0683786a7ca63ba49973818b3d1e9512cd2cec4a0013b98c6c83e066d5b14af2b85199e3d4fc7d1e778dd53130d180f5077e2d1c7a001148b495d6e859114e670ca54fb6e2657f0cbae5b08063605093a4b3dc9f8f1a0011ac212f13c5dff2b2c6b600a79635103d6f580a4221079951181b25c7e654901a0c8de4cced43169f9aa3d36506363b2d2c44f6c49fc1fd91ea114c86f3757077ea01e11fdd0d1934eda0492606ee0bb80a7bf8f35cc5f86ec60fe5031ba48bfd544").unwrap();
454456
let tx = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
455457

456-
let _ = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
458+
let trevm = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
459+
assert_eq!(trevm.tx().tx_type, TxType::Eip4844 as u8);
460+
assert_eq!(trevm.tx().blob_hashes.len(), 5);
461+
}
462+
463+
#[test]
464+
// Test vector from https://etherscan.io/tx/0xe2db5fcc4b559a4a1910b713b53859bd93cff712a9091ed49f4713c3b5d0ee2d
465+
fn test_live_tx_7702_fill() {
466+
let raw_tx = alloy::primitives::hex::decode("0x04f908b101821ed6845ee49865845ee498658308bc44944337084d9e255ff0702461cf8895ce9e3b5ff10880b907e4765e827f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000004337012eaf1f862b8dbdc6b62a01782ae01ef0380000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000028041edf52dc5e0a4f7df9a83be94ebc61b6021900000000000000000000000000000000000001994efed1d00000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000f0910000000000000000000000000005ce570000000000000000000000000000000000000000000000000000000000014a3a0000000000000000000000003ee205c000000000000000000000000074b0fb4900000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000000006e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054434fcd5be0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000e58d634420595bb818aa7e7c190faf92c162efd4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000000000000000000000000000000392a3b5844100000000000000000000000000000000000000000000000000000000000000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000104791ac947000000000000000000000000000000000000000000000000000392a3b58441000000000000000000000000000000000000000000000000000085be0b72a29ccf00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000028041edf52dc5e0a4f7df9a83be94ebc61b602190000000000000000000000000000000000000000000000000000000068c8738d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000e58d634420595bb818aa7e7c190faf92c162efd4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000008680ac8095b0247dd5b37bd2a55a8fd5ab6c2d600000000000000000000000000000000000000000000000000001131e22bab01800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c1ef31f0332bb81d3d7c8c95382655bf027f43f30000000000000000000000000000000000000000000000000001131e22bab01800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e58d634420595bb818aa7e7c190faf92c162efd4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000418a97eb8eecb55209dc0a774f9973793c7e624b7463123d52104e2632f26041605e6be06a831a5d964aa62ab403bcb5319ff91911d9d5ed1abbcaee31e90cd7041b00000000000000000000000000000000000000000000000000000000000000c0f85cf85a0194e6cae83bde06e4c305530e199d7217f42808555b0401a0139fbb722809e42ea15e67ff69799cbade6572bd15dc56de804743c1bb19e85ea069b4219fb13385fbdc316ce90aa9b9ad84eda4596ff1ab38ec80f01e4b0c4e5501a028a1198ab1a6d09f51bce44012e8905e2654c0652721c3cbef6bb7f6f321c1c1a01e2325bc62df6a8f4a04ad3b34381b8748103f53b9aed2ead3c63fe93587915b").unwrap();
467+
let tx = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
468+
469+
let trevm = test_trevm().fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx);
470+
let authorization_list = &trevm.tx().authorization_list;
471+
// See: https://etherscan.io/tx/0xe2db5fcc4b559a4a1910b713b53859bd93cff712a9091ed49f4713c3b5d0ee2d#authorizationlist
472+
assert_eq!(authorization_list.len(), 1);
473+
assert_eq!(trevm.tx().tx_type, TxType::Eip7702 as u8);
457474
}
458475

459476
#[test]

0 commit comments

Comments
 (0)