From 3a3dddc5fbe9a554eab937afd263c571271fdd1d Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 23 Sep 2022 03:52:43 +0000 Subject: [PATCH] Fix ee integration tests (#3592) ## Issue Addressed Resolves #3573 ## Proposed Changes Fix the bytecode for the deposit contract deployment transaction and value for deposit transaction in the execution engine integration tests. Also verify that all published transaction make it to the execution payload and have a valid status. --- .../src/test_rig.rs | 19 +++++++++++++--- .../src/transactions.rs | 22 ++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/testing/execution_engine_integration/src/test_rig.rs b/testing/execution_engine_integration/src/test_rig.rs index 0aa960bc4..515e238e9 100644 --- a/testing/execution_engine_integration/src/test_rig.rs +++ b/testing/execution_engine_integration/src/test_rig.rs @@ -239,13 +239,16 @@ impl TestRig { // Submit transactions before getting payload let txs = transactions::(account1, account2); + let mut pending_txs = Vec::new(); for tx in txs.clone().into_iter() { - self.ee_a + let pending_tx = self + .ee_a .execution_engine .provider .send_transaction(tx, None) .await .unwrap(); + pending_txs.push(pending_tx); } /* @@ -328,8 +331,6 @@ impl TestRig { .unwrap() .execution_payload; - assert_eq!(valid_payload.transactions.len(), txs.len()); - /* * Execution Engine A: * @@ -393,6 +394,18 @@ impl TestRig { .await .unwrap(); assert_eq!(status, PayloadStatus::Valid); + assert_eq!(valid_payload.transactions.len(), pending_txs.len()); + + // Verify that all submitted txs were successful + for pending_tx in pending_txs { + let tx_receipt = pending_tx.await.unwrap().unwrap(); + assert_eq!( + tx_receipt.status, + Some(1.into()), + "Tx index {} has invalid status ", + tx_receipt.transaction_index + ); + } /* * Execution Engine A: diff --git a/testing/execution_engine_integration/src/transactions.rs b/testing/execution_engine_integration/src/transactions.rs index 144946682..a8c0ab3c1 100644 --- a/testing/execution_engine_integration/src/transactions.rs +++ b/testing/execution_engine_integration/src/transactions.rs @@ -1,7 +1,7 @@ use deposit_contract::{encode_eth1_tx_data, BYTECODE, CONTRACT_DEPLOY_GAS, DEPOSIT_GAS}; use ethers_core::types::{ transaction::{eip2718::TypedTransaction, eip2930::AccessList}, - Address, Bytes, Eip1559TransactionRequest, TransactionRequest, + Address, Bytes, Eip1559TransactionRequest, TransactionRequest, U256, }; use types::{DepositData, EthSpec, Hash256, Keypair, Signature}; @@ -56,30 +56,36 @@ impl Transaction { .value(1) .with_access_list(AccessList::default()) .into(), - Self::DeployDepositContract(addr) => TransactionRequest::new() - .from(*addr) - .data(Bytes::from(BYTECODE.to_vec())) - .gas(CONTRACT_DEPLOY_GAS) - .into(), + Self::DeployDepositContract(addr) => { + let mut bytecode = String::from_utf8(BYTECODE.to_vec()).unwrap(); + bytecode.retain(|c| c.is_ascii_hexdigit()); + let bytecode = hex::decode(&bytecode[1..]).unwrap(); + TransactionRequest::new() + .from(*addr) + .data(Bytes::from(bytecode)) + .gas(CONTRACT_DEPLOY_GAS) + .into() + } Self::DepositDepositContract { sender, deposit_contract_address, } => { let keypair = Keypair::random(); + let amount: u64 = 32_000_000_000; let mut deposit = DepositData { pubkey: keypair.pk.into(), withdrawal_credentials: Hash256::zero(), - amount: 32_000_000_000, + amount, signature: Signature::empty().into(), }; - deposit.signature = deposit.create_signature(&keypair.sk, &E::default_spec()); TransactionRequest::new() .from(*sender) .to(*deposit_contract_address) .data(Bytes::from(encode_eth1_tx_data(&deposit).unwrap())) .gas(DEPOSIT_GAS) + .value(U256::from(amount) * U256::exp10(9)) .into() } }