|
1 | 1 | //! The test driver handles the compilation and execution of the test cases. |
2 | 2 |
|
3 | 3 | use alloy::json_abi::JsonAbi; |
4 | | -use alloy::primitives::Bytes; |
| 4 | +use alloy::network::TransactionBuilder; |
| 5 | +use alloy::rpc::types::TransactionReceipt; |
5 | 6 | use alloy::rpc::types::trace::geth::GethTrace; |
6 | | -use alloy::rpc::types::{TransactionInput, TransactionReceipt}; |
7 | 7 | use alloy::{ |
8 | | - primitives::{Address, TxKind, map::HashMap}, |
| 8 | + primitives::{Address, map::HashMap}, |
9 | 9 | rpc::types::{ |
10 | 10 | TransactionRequest, |
11 | 11 | trace::geth::{AccountState, DiffMode}, |
@@ -135,21 +135,17 @@ where |
135 | 135 | std::any::type_name::<T>() |
136 | 136 | ); |
137 | 137 |
|
138 | | - let tx = match input.legacy_transaction( |
139 | | - self.config.network_id, |
140 | | - nonce, |
141 | | - &self.deployed_contracts, |
142 | | - &self.deployed_abis, |
143 | | - ) { |
144 | | - Ok(tx) => { |
145 | | - tracing::debug!("Legacy transaction data: {tx:#?}"); |
146 | | - tx |
147 | | - } |
148 | | - Err(err) => { |
149 | | - tracing::error!("Failed to construct legacy transaction: {err:?}"); |
150 | | - return Err(err); |
151 | | - } |
152 | | - }; |
| 138 | + let tx = |
| 139 | + match input.legacy_transaction(nonce, &self.deployed_contracts, &self.deployed_abis) { |
| 140 | + Ok(tx) => { |
| 141 | + tracing::debug!("Legacy transaction data: {tx:#?}"); |
| 142 | + tx |
| 143 | + } |
| 144 | + Err(err) => { |
| 145 | + tracing::error!("Failed to construct legacy transaction: {err:?}"); |
| 146 | + return Err(err); |
| 147 | + } |
| 148 | + }; |
153 | 149 |
|
154 | 150 | tracing::trace!("Executing transaction for input: {input:?}"); |
155 | 151 |
|
@@ -201,6 +197,9 @@ where |
201 | 197 |
|
202 | 198 | for contracts in contract_map.values() { |
203 | 199 | for (contract_name, contract) in contracts { |
| 200 | + let tracing_span = tracing::info_span!("Deploying contract", contract_name); |
| 201 | + let _guard = tracing_span.enter(); |
| 202 | + |
204 | 203 | tracing::debug!( |
205 | 204 | "Contract name is: {:?} and the input name is: {:?}", |
206 | 205 | &contract_name, |
@@ -228,16 +227,14 @@ where |
228 | 227 | std::any::type_name::<T>() |
229 | 228 | ); |
230 | 229 |
|
231 | | - let tx = TransactionRequest { |
232 | | - from: Some(input.caller), |
233 | | - to: Some(TxKind::Create), |
234 | | - gas_price: Some(5_000_000), |
235 | | - gas: Some(5_000_000), |
236 | | - chain_id: Some(self.config.network_id), |
237 | | - nonce: Some(nonce), |
238 | | - input: TransactionInput::new(Bytes::from(code.into_bytes())), |
239 | | - ..Default::default() |
240 | | - }; |
| 230 | + // We are using alloy for building and submitting the transactions and it will |
| 231 | + // automatically fill in all of the missing fields from the provider that we |
| 232 | + // are using. |
| 233 | + let code = alloy::hex::decode(&code)?; |
| 234 | + let tx = TransactionRequest::default() |
| 235 | + .nonce(nonce) |
| 236 | + .from(input.caller) |
| 237 | + .with_deploy_code(code); |
241 | 238 |
|
242 | 239 | let receipt = match node.execute_transaction(tx) { |
243 | 240 | Ok(receipt) => receipt, |
|
0 commit comments