|
1 | 1 | //! Mock Block definition and builder related methods.
|
2 | 2 |
|
3 |
| -use crate::{MockTransaction, MOCK_BASEFEE, MOCK_CHAIN_ID, MOCK_DIFFICULTY, MOCK_GASLIMIT}; |
| 3 | +use crate::{ |
| 4 | + withdrawal::MockWithdrawal, MockTransaction, MOCK_BASEFEE, MOCK_CHAIN_ID, MOCK_DIFFICULTY, |
| 5 | + MOCK_GASLIMIT, |
| 6 | +}; |
4 | 7 | use eth_types::{Address, Block, Bytes, Hash, Transaction, Word, H64, U64};
|
5 | 8 | use ethers_core::{
|
6 | 9 | types::{Bloom, OtherFields},
|
@@ -37,6 +40,7 @@ pub struct MockBlock {
|
37 | 40 | seal_fields: Vec<Bytes>,
|
38 | 41 | uncles: Vec<Hash>,
|
39 | 42 | pub(crate) transactions: Vec<MockTransaction>,
|
| 43 | + pub(crate) withdrawals: Vec<MockWithdrawal>, |
40 | 44 | size: Word,
|
41 | 45 | // This field is handled here as we assume that all block txs have the same ChainId.
|
42 | 46 | // Also, the field is stored in the block_table since we don't have a chain_config
|
@@ -71,6 +75,7 @@ impl Default for MockBlock {
|
71 | 75 | seal_fields: Vec::new(),
|
72 | 76 | uncles: Vec::new(),
|
73 | 77 | transactions: Vec::new(),
|
| 78 | + withdrawals: Vec::new(), |
74 | 79 | size: Word::zero(),
|
75 | 80 | chain_id: *MOCK_CHAIN_ID,
|
76 | 81 | }
|
@@ -109,8 +114,13 @@ impl From<MockBlock> for Block<Transaction> {
|
109 | 114 | .collect::<Vec<Transaction>>(),
|
110 | 115 | size: Some(mock.size),
|
111 | 116 | other: OtherFields::default(),
|
112 |
| - withdrawals_root: None, |
113 |
| - withdrawals: None, |
| 117 | + withdrawals_root: mock.withdrawal_hash, |
| 118 | + withdrawals: Some( |
| 119 | + mock.withdrawals |
| 120 | + .iter_mut() |
| 121 | + .map(|mock_wd| mock_wd.to_owned().into()) |
| 122 | + .collect(), |
| 123 | + ), |
114 | 124 | }
|
115 | 125 | }
|
116 | 126 | }
|
@@ -143,8 +153,13 @@ impl From<MockBlock> for Block<()> {
|
143 | 153 | transactions: vec![],
|
144 | 154 | size: Some(mock.size),
|
145 | 155 | other: OtherFields::default(),
|
146 |
| - withdrawals_root: None, |
147 |
| - withdrawals: None, |
| 156 | + withdrawals_root: mock.withdrawal_hash, |
| 157 | + withdrawals: Some( |
| 158 | + mock.withdrawals |
| 159 | + .iter() |
| 160 | + .map(|mock_wd| mock_wd.to_owned().into()) |
| 161 | + .collect(), |
| 162 | + ), |
148 | 163 | }
|
149 | 164 | }
|
150 | 165 | }
|
|
0 commit comments