From 63b876b87ee5644ab756b456e26c7644baf1ea21 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 21 Aug 2023 11:42:50 -0400 Subject: [PATCH] fix beacon chain tests (#4645) --- beacon_node/execution_layer/src/engine_api.rs | 9 +++---- beacon_node/execution_layer/src/lib.rs | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index 5fd0610b3..683e39a50 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -217,8 +217,7 @@ impl TryFrom> for ExecutionBlockWithTransactions .transactions .iter() .map(|tx| Transaction::decode(&Rlp::new(tx))) - .collect::, _>>() - .unwrap_or_else(|_| Vec::new()), + .collect::, _>>()?, }), ExecutionPayload::Capella(block) => { Self::Capella(ExecutionBlockWithTransactionsCapella { @@ -239,8 +238,7 @@ impl TryFrom> for ExecutionBlockWithTransactions .transactions .iter() .map(|tx| Transaction::decode(&Rlp::new(tx))) - .collect::, _>>() - .unwrap_or_else(|_| Vec::new()), + .collect::, _>>()?, withdrawals: Vec::from(block.withdrawals) .into_iter() .map(|withdrawal| withdrawal.into()) @@ -265,8 +263,7 @@ impl TryFrom> for ExecutionBlockWithTransactions .transactions .iter() .map(|tx| Transaction::decode(&Rlp::new(tx))) - .collect::, _>>() - .unwrap_or_else(|_| Vec::new()), + .collect::, _>>()?, withdrawals: Vec::from(block.withdrawals) .into_iter() .map(|withdrawal| withdrawal.into()) diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index a6c9465e1..f5c77a332 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -2145,10 +2145,27 @@ fn timestamp_now() -> u64 { fn static_valid_tx() -> Result, String> { // This is a real transaction hex encoded, but we don't care about the contents of the transaction. - let bytes = hex::decode( - "b87502f872041a8459682f008459682f0d8252089461815774383099e24810ab832a5b2a5425c154d58829a2241af62c000080c001a059e6b67f48fb32e7e570dfb11e042b5ad2e55e3ce3ce9cd989c7e06e07feeafda0016b83f4f980694ed2eee4d10667242b1f40dc406901b34125b008d334d47469" - ).map_err(|e| format!("Failed to decode transaction bytes: {:?}", e))?; - VariableList::new(bytes).map_err(|e| format!("Failed to convert transaction to SSZ: {:?}", e)) + let transaction: EthersTransaction = serde_json::from_str( + r#"{ + "blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2", + "blockNumber":"0x5daf3b", + "from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d", + "gas":"0xc350", + "gasPrice":"0x4a817c800", + "hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", + "input":"0x68656c6c6f21", + "nonce":"0x15", + "to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb", + "transactionIndex":"0x41", + "value":"0xf3dbb76162000", + "v":"0x25", + "r":"0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea", + "s":"0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c" + }"#, + ) + .unwrap(); + VariableList::new(transaction.rlp().to_vec()) + .map_err(|e| format!("Failed to convert transaction to SSZ: {:?}", e)) } fn noop(