diff --git a/src/eth/primitives/external_block.rs b/src/eth/primitives/external_block.rs index b07cc315d..c6e2952eb 100644 --- a/src/eth/primitives/external_block.rs +++ b/src/eth/primitives/external_block.rs @@ -1,14 +1,24 @@ +use alloy_eips::eip4895::Withdrawals; +use alloy_primitives::Bloom; +use alloy_primitives::Bytes; +use alloy_primitives::B256; +use alloy_primitives::B64; +use alloy_primitives::U256; +use fake::Dummy; +use fake::Fake; +use fake::Faker; use serde::Deserialize; use crate::alias::AlloyBlockExternalTransaction; use crate::alias::JsonValue; +use crate::eth::primitives::external_transaction::ExternalTransaction; use crate::eth::primitives::Address; use crate::eth::primitives::BlockNumber; use crate::eth::primitives::Hash; use crate::eth::primitives::UnixTime; use crate::log_and_err; -#[derive(Debug, Clone, derive_more::Deref, derive_more::DerefMut, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Clone, PartialEq, derive_more::Deref, derive_more::DerefMut, serde::Deserialize, serde::Serialize)] #[serde(transparent)] pub struct ExternalBlock(#[deref] pub AlloyBlockExternalTransaction); @@ -36,9 +46,59 @@ impl ExternalBlock { } } +impl Dummy for ExternalBlock { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + let mut addr_bytes = [0u8; 20]; + let mut hash_bytes = [0u8; 32]; + let mut nonce_bytes = [0u8; 8]; + rng.fill_bytes(&mut addr_bytes); + rng.fill_bytes(&mut hash_bytes); + rng.fill_bytes(&mut nonce_bytes); + + let transaction: ExternalTransaction = faker.fake_with_rng(rng); + + let block = alloy_rpc_types_eth::Block { + header: alloy_rpc_types_eth::Header { + hash: B256::from_slice(&hash_bytes), + inner: alloy_consensus::Header { + parent_hash: B256::from_slice(&hash_bytes), + ommers_hash: B256::from_slice(&hash_bytes), + beneficiary: alloy_primitives::Address::from_slice(&addr_bytes), + state_root: B256::from_slice(&hash_bytes), + transactions_root: B256::from_slice(&hash_bytes), + receipts_root: B256::from_slice(&hash_bytes), + withdrawals_root: Some(B256::from_slice(&hash_bytes)), + number: rng.next_u64(), + gas_used: rng.next_u64(), + gas_limit: rng.next_u64(), + extra_data: Bytes::default(), + logs_bloom: Bloom::default(), + timestamp: rng.next_u64(), + difficulty: U256::from(rng.next_u64()), + mix_hash: B256::from_slice(&hash_bytes), + nonce: B64::from_slice(&nonce_bytes), + base_fee_per_gas: Some(rng.next_u64()), + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + requests_hash: None, + }, + total_difficulty: Some(U256::from(rng.next_u64())), + size: Some(U256::from(rng.next_u64())), + }, + uncles: vec![B256::from_slice(&hash_bytes)], + transactions: alloy_rpc_types_eth::BlockTransactions::Full(vec![transaction]), + withdrawals: Some(Withdrawals::default()), + }; + + ExternalBlock(block) + } +} + // ----------------------------------------------------------------------------- // Conversions: Other -> Self // ----------------------------------------------------------------------------- + impl TryFrom for ExternalBlock { type Error = anyhow::Error; diff --git a/src/eth/primitives/external_block_with_receipts.rs b/src/eth/primitives/external_block_with_receipts.rs index adfee6540..bd350776b 100644 --- a/src/eth/primitives/external_block_with_receipts.rs +++ b/src/eth/primitives/external_block_with_receipts.rs @@ -1,16 +1,33 @@ +use fake::Dummy; +use fake::Faker; use serde::Deserialize; +use serde::Serialize; use crate::alias::JsonValue; use crate::eth::primitives::ExternalBlock; use crate::eth::primitives::ExternalReceipt; use crate::log_and_err; -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct ExternalBlockWithReceipts { pub block: ExternalBlock, pub receipts: Vec, } +impl Dummy for ExternalBlockWithReceipts { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + let block = ExternalBlock::dummy_with_rng(faker, rng); + + let receipts = match &block.transactions { + alloy_rpc_types_eth::BlockTransactions::Full(txs) => txs.iter().map(|_| ExternalReceipt::dummy_with_rng(faker, rng)).collect(), + alloy_rpc_types_eth::BlockTransactions::Hashes(_) => Vec::new(), + alloy_rpc_types_eth::BlockTransactions::Uncle => Vec::new(), + }; + + Self { block, receipts } + } +} + // ----------------------------------------------------------------------------- // Conversions: Other -> Self // ----------------------------------------------------------------------------- diff --git a/src/eth/primitives/external_receipt.rs b/src/eth/primitives/external_receipt.rs index 442f82813..474eab28b 100644 --- a/src/eth/primitives/external_receipt.rs +++ b/src/eth/primitives/external_receipt.rs @@ -1,4 +1,10 @@ +use alloy_consensus::ReceiptEnvelope; +use alloy_primitives::Bloom; +use alloy_primitives::Bytes; +use alloy_primitives::B256; use ethereum_types::U256; +use fake::Dummy; +use fake::Faker; use serde::Deserialize; use crate::alias::AlloyReceipt; @@ -8,7 +14,7 @@ use crate::eth::primitives::Hash; use crate::eth::primitives::Wei; use crate::log_and_err; -#[derive(Debug, Clone, derive_more::Deref, serde::Serialize)] +#[derive(Debug, Clone, PartialEq, derive_more::Deref, serde::Serialize)] #[serde(transparent)] pub struct ExternalReceipt(#[deref] pub AlloyReceipt); @@ -43,6 +49,58 @@ impl ExternalReceipt { } } +impl Dummy for ExternalReceipt { + fn dummy_with_rng(_faker: &Faker, rng: &mut R) -> Self { + let mut addr_bytes = [0u8; 20]; + let mut hash_bytes = [0u8; 32]; + rng.fill_bytes(&mut addr_bytes); + rng.fill_bytes(&mut hash_bytes); + + let log = alloy_rpc_types_eth::Log { + inner: alloy_primitives::Log { + address: alloy_primitives::Address::from_slice(&addr_bytes), + data: alloy_primitives::LogData::new_unchecked(vec![B256::from_slice(&hash_bytes)], Bytes::default()), + }, + block_hash: Some(B256::from_slice(&hash_bytes)), + block_number: Some(rng.next_u64()), + transaction_hash: Some(B256::from_slice(&hash_bytes)), + transaction_index: Some(rng.next_u64()), + log_index: Some(rng.next_u64()), + removed: false, + block_timestamp: Some(rng.next_u64()), + }; + + let receipt = alloy_consensus::Receipt { + status: alloy_consensus::Eip658Value::Eip658(true), + cumulative_gas_used: rng.next_u64(), + logs: vec![log], + }; + + let receipt_envelope = ReceiptEnvelope::Legacy(alloy_consensus::ReceiptWithBloom { + receipt, + logs_bloom: Bloom::default(), + }); + + let receipt = alloy_rpc_types_eth::TransactionReceipt { + inner: receipt_envelope, + transaction_hash: B256::from_slice(&hash_bytes), + transaction_index: Some(rng.next_u64()), + block_hash: Some(B256::from_slice(&hash_bytes)), + block_number: Some(rng.next_u64()), + from: alloy_primitives::Address::from_slice(&addr_bytes), + to: Some(alloy_primitives::Address::from_slice(&addr_bytes)), + contract_address: None, + gas_used: rng.next_u64(), + effective_gas_price: rng.next_u64() as u128, + blob_gas_used: None, + blob_gas_price: None, + authorization_list: None, + }; + + ExternalReceipt(receipt) + } +} + // ----------------------------------------------------------------------------- // Serialization / Deserialization // ----------------------------------------------------------------------------- @@ -91,6 +149,7 @@ impl TryFrom for ExternalReceipt { #[cfg(test)] mod tests { + use alloy_consensus::TxType; use super::*; diff --git a/src/eth/primitives/external_receipts.rs b/src/eth/primitives/external_receipts.rs index 8f53daaa9..ff9c05ced 100644 --- a/src/eth/primitives/external_receipts.rs +++ b/src/eth/primitives/external_receipts.rs @@ -1,12 +1,14 @@ use std::collections::HashMap; use anyhow::anyhow; +use fake::Dummy; +use fake::Faker; use crate::eth::primitives::ExternalReceipt; use crate::eth::primitives::Hash; /// A collection of [`ExternalReceipt`]. -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ExternalReceipts(HashMap); impl ExternalReceipts { @@ -22,6 +24,19 @@ impl ExternalReceipts { } } +impl Dummy for ExternalReceipts { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + let count = (rng.next_u32() % 5 + 1) as usize; + let receipts = (0..count).map(|_| ExternalReceipt::dummy_with_rng(faker, rng)).collect::>(); + + Self::from(receipts) + } +} + +// ----------------------------------------------------------------------------- +// Conversions: Other -> Self +// ----------------------------------------------------------------------------- + impl From> for ExternalReceipts { fn from(receipts: Vec) -> Self { let mut receipts_by_hash = HashMap::with_capacity(receipts.len()); diff --git a/src/eth/primitives/external_transaction.rs b/src/eth/primitives/external_transaction.rs index 39249d444..4ef5248ff 100644 --- a/src/eth/primitives/external_transaction.rs +++ b/src/eth/primitives/external_transaction.rs @@ -1,10 +1,24 @@ +use alloy_consensus::Signed; +use alloy_consensus::TxEnvelope; +use alloy_consensus::TxLegacy; +use alloy_primitives::Bytes; +use alloy_primitives::PrimitiveSignature; +use alloy_primitives::TxKind; use anyhow::Context; use anyhow::Result; +use ethereum_types::U256; +use fake::Dummy; +use fake::Fake; +use fake::Faker; use crate::alias::AlloyTransaction; +use crate::eth::primitives::signature_component::SignatureComponent; +use crate::eth::primitives::Address; use crate::eth::primitives::BlockNumber; use crate::eth::primitives::Hash; -#[derive(Debug, Clone, derive_more::Deref, serde::Deserialize, serde::Serialize)] +use crate::eth::primitives::Wei; + +#[derive(Debug, Clone, PartialEq, derive_more::Deref, serde::Deserialize, serde::Serialize)] #[serde(transparent)] pub struct ExternalTransaction(#[deref] pub AlloyTransaction); @@ -20,6 +34,45 @@ impl ExternalTransaction { } } +impl Dummy for ExternalTransaction { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + let from: Address = faker.fake_with_rng(rng); + let block_hash: Hash = faker.fake_with_rng(rng); + + let gas_price: Wei = Wei::from(rng.next_u64()); + let value: Wei = Wei::from(rng.next_u64()); + + let tx = TxLegacy { + chain_id: Some(1), + nonce: rng.next_u64(), + gas_price: gas_price.into(), + gas_limit: rng.next_u64(), + to: TxKind::Call(from.into()), + value: value.into(), + input: Bytes::default(), + }; + + let r = U256::from(rng.next_u64()); + let s = U256::from(rng.next_u64()); + let v = rng.next_u64() % 2 == 0; + let signature = PrimitiveSignature::new(SignatureComponent(r).into(), SignatureComponent(s).into(), v); + + let hash: Hash = faker.fake_with_rng(rng); + let inner_tx = TxEnvelope::Legacy(Signed::new_unchecked(tx, signature, hash.into())); + + let inner = alloy_rpc_types_eth::Transaction { + inner: inner_tx, + block_hash: Some(block_hash.into()), + block_number: Some(rng.next_u64()), + transaction_index: Some(rng.next_u64()), + from: from.into(), + effective_gas_price: Some(gas_price.as_u128()), + }; + + ExternalTransaction(inner) + } +} + // ----------------------------------------------------------------------------- // Conversions: Other -> Self // ----------------------------------------------------------------------------- diff --git a/src/eth/primitives/mod.rs b/src/eth/primitives/mod.rs index a47e4f5a1..db75a142e 100644 --- a/src/eth/primitives/mod.rs +++ b/src/eth/primitives/mod.rs @@ -122,6 +122,7 @@ pub use wei::Wei; #[cfg(test)] mod tests { use super::*; + use crate::gen_test_json; use crate::gen_test_serde; type TransactionExecutionValueChangeBytes = ExecutionValueChange; @@ -142,6 +143,12 @@ mod tests { // gen_test_serde!(TransactionExecution); // gen_test_serde!(TransactionStage); + gen_test_json!(ExternalBlock); + gen_test_json!(ExternalBlockWithReceipts); + gen_test_json!(ExternalReceipt); + gen_test_json!(ExternalReceipts); + gen_test_json!(ExternalTransaction); + gen_test_serde!(Account); gen_test_serde!(Address); gen_test_serde!(Block); diff --git a/src/ext.rs b/src/ext.rs index f9c703ffc..b6a789c1b 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -346,6 +346,58 @@ macro_rules! gen_test_serde { }; } +/// Generates a unit test that verifies JSON serialization/deserialization compatibility using snapshots. +#[macro_export] +macro_rules! gen_test_json { + ($type:ty) => { + paste::paste! { + #[test] + fn []() -> anyhow::Result<()> { + use anyhow::bail; + use std::path::Path; + use std::{env, fs}; + + let expected: $type = $crate::utils::test_utils::fake_first::<$type>(); + let expected_json = serde_json::to_string_pretty(&expected)?; + let snapshot_parent_path = "tests/fixtures/primitives"; + let snapshot_name = format!("{}.json", stringify!($type)); + let snapshot_path = format!("{}/{}", snapshot_parent_path, snapshot_name); + + // WARNING: If you need to update snapshots (DANGEROUS_UPDATE_SNAPSHOTS=1), you have likely + // broken backwards compatibility! Make sure this is intentional. + if !Path::new(&snapshot_path).exists() { + if env::var("DANGEROUS_UPDATE_SNAPSHOTS").is_ok() { + fs::create_dir_all(snapshot_parent_path)?; + fs::write(&snapshot_path, &expected_json)?; + } else { + bail!("snapshot file at '{snapshot_path}' doesn't exist and DANGEROUS_UPDATE_SNAPSHOTS is not set"); + } + } + + // Read and attempt to deserialize the snapshot + let snapshot_content = fs::read_to_string(&snapshot_path)?; + let deserialized = match serde_json::from_str::<$type>(&snapshot_content) { + Ok(value) => value, + Err(e) => { + bail!("Failed to deserialize snapshot:\nError: {}\n\nExpected JSON:\n{}\n\nActual JSON from snapshot:\n{}", + e, expected_json, snapshot_content); + } + }; + + // Compare the values + assert_eq!( + expected, deserialized, + "\nDeserialized value doesn't match expected:\n\nExpected JSON:\n{}\n\nDeserialized JSON:\n{}", + expected_json, + serde_json::to_string_pretty(&deserialized)? + ); + + Ok(()) + } + } + }; +} + /// Generates unit test that checks that bincode's serialization and deserialization are compatible #[macro_export] macro_rules! gen_test_bincode { diff --git a/tests/fixtures/primitives/ExternalBlock.json b/tests/fixtures/primitives/ExternalBlock.json new file mode 100644 index 000000000..14004c16a --- /dev/null +++ b/tests/fixtures/primitives/ExternalBlock.json @@ -0,0 +1,46 @@ +{ + "hash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "parentHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "sha3Uncles": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "miner": "0x8c189668c9e4837237bf31e02d7f6b70a16ed9fa", + "stateRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "transactionsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "receiptsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x74d179ca212255e7", + "number": "0xba967e5ca42d2153", + "gasLimit": "0x9968df5b7e4c1bb0", + "gasUsed": "0x6299412107856171", + "timestamp": "0x17f7d41cc86dece4", + "extraData": "0x", + "mixHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "nonce": "0xa5c2578f11cbd474", + "baseFeePerGas": "0x24657777b372efc3", + "withdrawalsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "totalDifficulty": "0x386e5b388f9744bc", + "size": "0x8bba32eabb281ad1", + "uncles": [ + "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096" + ], + "transactions": [ + { + "type": "0x0", + "chainId": "0x1", + "nonce": "0x8168631a04e380c2", + "gasPrice": "0x2d2641599a19b586", + "gas": "0x9bce862efd9d20b8", + "to": "0x0a2c1d39560cac6351280b72b98afe0ebf1ca1cc", + "value": "0xf5e9bd258891902b", + "input": "0x", + "r": "0x9ed7f75a141f03af", + "s": "0x7d573a9c522c2b5f", + "v": "0x26", + "hash": "0x5056febf57455bc67911121cd4a15bc2f66febd9f18bc980ceb240e5ef0feb85", + "blockHash": "0x86468427a5d57e7ad429748075696fe6c6a086aed4de8f1a2f390645f58ea027", + "blockNumber": "0xc921fc1fa507d6e0", + "transactionIndex": "0xb0c0c8b972c987bb", + "from": "0x0a2c1d39560cac6351280b72b98afe0ebf1ca1cc" + } + ], + "withdrawals": [] +} \ No newline at end of file diff --git a/tests/fixtures/primitives/ExternalBlockWithReceipts.json b/tests/fixtures/primitives/ExternalBlockWithReceipts.json new file mode 100644 index 000000000..1dd41357b --- /dev/null +++ b/tests/fixtures/primitives/ExternalBlockWithReceipts.json @@ -0,0 +1,81 @@ +{ + "block": { + "hash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "parentHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "sha3Uncles": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "miner": "0x8c189668c9e4837237bf31e02d7f6b70a16ed9fa", + "stateRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "transactionsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "receiptsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x74d179ca212255e7", + "number": "0xba967e5ca42d2153", + "gasLimit": "0x9968df5b7e4c1bb0", + "gasUsed": "0x6299412107856171", + "timestamp": "0x17f7d41cc86dece4", + "extraData": "0x", + "mixHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "nonce": "0xa5c2578f11cbd474", + "baseFeePerGas": "0x24657777b372efc3", + "withdrawalsRoot": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "totalDifficulty": "0x386e5b388f9744bc", + "size": "0x8bba32eabb281ad1", + "uncles": [ + "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096" + ], + "transactions": [ + { + "type": "0x0", + "chainId": "0x1", + "nonce": "0x8168631a04e380c2", + "gasPrice": "0x2d2641599a19b586", + "gas": "0x9bce862efd9d20b8", + "to": "0x0a2c1d39560cac6351280b72b98afe0ebf1ca1cc", + "value": "0xf5e9bd258891902b", + "input": "0x", + "r": "0x9ed7f75a141f03af", + "s": "0x7d573a9c522c2b5f", + "v": "0x26", + "hash": "0x5056febf57455bc67911121cd4a15bc2f66febd9f18bc980ceb240e5ef0feb85", + "blockHash": "0x86468427a5d57e7ad429748075696fe6c6a086aed4de8f1a2f390645f58ea027", + "blockNumber": "0xc921fc1fa507d6e0", + "transactionIndex": "0xb0c0c8b972c987bb", + "from": "0x0a2c1d39560cac6351280b72b98afe0ebf1ca1cc" + } + ], + "withdrawals": [] + }, + "receipts": [ + { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0xf2579cb7048e7668", + "logs": [ + { + "address": "0x8ce3c3e2f932b74ecef5bf9d6eb5ec21617926fc", + "topics": [ + "0x172f65ccf6a5d1c745f61d6e1afe8bdf154390f9186aca84faf4f2ce4aecfe27" + ], + "data": "0x", + "blockHash": "0x172f65ccf6a5d1c745f61d6e1afe8bdf154390f9186aca84faf4f2ce4aecfe27", + "blockNumber": "0x36b5f7cc49b129a9", + "blockTimestamp": "0x7e7c127e65f23ea0", + "transactionHash": "0x172f65ccf6a5d1c745f61d6e1afe8bdf154390f9186aca84faf4f2ce4aecfe27", + "transactionIndex": "0xa0f32d0cc5bc6a2f", + "logIndex": "0xf14e47d54bbcd8f5", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x172f65ccf6a5d1c745f61d6e1afe8bdf154390f9186aca84faf4f2ce4aecfe27", + "transactionIndex": "0x823f0dda5b7b7e27", + "blockHash": "0x172f65ccf6a5d1c745f61d6e1afe8bdf154390f9186aca84faf4f2ce4aecfe27", + "blockNumber": "0x1690dfe42e67136c", + "gasUsed": "0xa769090124fd2337", + "effectiveGasPrice": "0x6647bfa416a042e4", + "from": "0x8ce3c3e2f932b74ecef5bf9d6eb5ec21617926fc", + "to": "0x8ce3c3e2f932b74ecef5bf9d6eb5ec21617926fc", + "contractAddress": null + } + ] +} \ No newline at end of file diff --git a/tests/fixtures/primitives/ExternalReceipt.json b/tests/fixtures/primitives/ExternalReceipt.json new file mode 100644 index 000000000..8c3c5af7f --- /dev/null +++ b/tests/fixtures/primitives/ExternalReceipt.json @@ -0,0 +1,31 @@ +{ + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0xf9f42a39293c9190", + "logs": [ + { + "address": "0x8c189668c9e4837237bf31e02d7f6b70a16ed9fa", + "topics": [ + "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096" + ], + "data": "0x", + "blockHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "blockNumber": "0x74d4cb118f57c2a5", + "blockTimestamp": "0x3dac1b1d3add1987", + "transactionHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "transactionIndex": "0x65282b0a08ebb2ec", + "logIndex": "0xd1a0372c789578cd", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "transactionIndex": "0xa4ff0d56382d1243", + "blockHash": "0x73632e8066975076350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096", + "blockNumber": "0xdfadd0cd921aba0", + "gasUsed": "0xebec27ac83bd6464", + "effectiveGasPrice": "0x39a0a563e5a54560", + "from": "0x8c189668c9e4837237bf31e02d7f6b70a16ed9fa", + "to": "0x8c189668c9e4837237bf31e02d7f6b70a16ed9fa", + "contractAddress": null +} \ No newline at end of file diff --git a/tests/fixtures/primitives/ExternalReceipts.json b/tests/fixtures/primitives/ExternalReceipts.json new file mode 100644 index 000000000..b9b7829a3 --- /dev/null +++ b/tests/fixtures/primitives/ExternalReceipts.json @@ -0,0 +1,157 @@ +{ + "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474": { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0xa4ff0d56382d1243", + "logs": [ + { + "address": "0x37bf31e02d7f6b70120e0d18a16ed9fa66975076", + "topics": [ + "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474" + ], + "data": "0x", + "blockHash": "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474", + "blockNumber": "0x65282b0a08ebb2ec", + "blockTimestamp": "0xf9f42a39293c9190", + "transactionHash": "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474", + "transactionIndex": "0xd1a0372c789578cd", + "logIndex": "0x3dac1b1d3add1987", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474", + "transactionIndex": "0xdfadd0cd921aba0", + "blockHash": "0x350fb49e86f8a6e575e9ac4aff2865f1e05fa3f7c2d59096a5c2578f11cbd474", + "blockNumber": "0xebec27ac83bd6464", + "gasUsed": "0x39a0a563e5a54560", + "effectiveGasPrice": "0x3b6a9e51e98ee1dc", + "from": "0x37bf31e02d7f6b70120e0d18a16ed9fa66975076", + "to": "0x37bf31e02d7f6b70120e0d18a16ed9fa66975076", + "contractAddress": null + }, + "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da": { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0xc881571160f04b5f", + "logs": [ + { + "address": "0x5f2b2c529c3a577d3656f97ebf558d09508c421d", + "topics": [ + "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da" + ], + "data": "0x", + "blockHash": "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da", + "blockNumber": "0xd32f4045b5f4625a", + "blockTimestamp": "0xdb3503797d39a334", + "transactionHash": "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da", + "transactionIndex": "0x66abca5b5ded4b32", + "logIndex": "0x6e8fa9c60f39843e", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da", + "transactionIndex": "0xf23dfc1251d1765a", + "blockHash": "0xee0c7db356555e65eab11f29fec397a5b5bab015bf96080ecd26b06c57b150da", + "blockNumber": "0xf354001c444699fe", + "gasUsed": "0x9cfc61d426bbe3f4", + "effectiveGasPrice": "0xffb8a0a18e0bc8df", + "from": "0x5f2b2c529c3a577d3656f97ebf558d09508c421d", + "to": "0x5f2b2c529c3a577d3656f97ebf558d09508c421d", + "contractAddress": null + }, + "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05": { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0x7356e1c6018c988b", + "logs": [ + { + "address": "0xa239d936d547b5ee590750387efc834b7a5e875c", + "topics": [ + "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05" + ], + "data": "0x", + "blockHash": "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05", + "blockNumber": "0xabb0f875035452de", + "blockTimestamp": "0x2354dce615df1881", + "transactionHash": "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05", + "transactionIndex": "0xc932266904344e48", + "logIndex": "0x580e686facb6a687", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05", + "transactionIndex": "0xb13bb8a040a2c9e8", + "blockHash": "0x10e738d3d494ca48e3a067e52916e9af10f321137437ef68c32d1670803b7d05", + "blockNumber": "0x5b573e8657c21f4c", + "gasUsed": "0x542330ae0401147a", + "effectiveGasPrice": "0x6cc454d49cb06205", + "from": "0xa239d936d547b5ee590750387efc834b7a5e875c", + "to": "0xa239d936d547b5ee590750387efc834b7a5e875c", + "contractAddress": null + }, + "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25": { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0x2d2641599a19b586", + "logs": [ + { + "address": "0x3ee602cfdef533d15766faf48fc309a11a8bfc19", + "topics": [ + "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25" + ], + "data": "0x", + "blockHash": "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25", + "blockNumber": "0xbf6bf8f50caba52d", + "blockTimestamp": "0x24762a272240e3f8", + "transactionHash": "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25", + "transactionIndex": "0xbde8e48e1e1e8a3f", + "logIndex": "0x2e5343a0ff03b21c", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25", + "transactionIndex": "0xf5e9bd258891902b", + "blockHash": "0x0450613e2f90db17c9536954395fdbed3c65d830065b8430254647da455a0b25", + "blockNumber": "0x8168631a04e380c2", + "gasUsed": "0x9bce862efd9d20b8", + "effectiveGasPrice": "0x9ed7f75a141f03af", + "from": "0x3ee602cfdef533d15766faf48fc309a11a8bfc19", + "to": "0x3ee602cfdef533d15766faf48fc309a11a8bfc19", + "contractAddress": null + }, + "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd": { + "type": "0x0", + "status": "0x1", + "cumulativeGasUsed": "0xd157a686cccad263", + "logs": [ + { + "address": "0x92c7fd952883064c80c1c6670bc5afc972346bb9", + "topics": [ + "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd" + ], + "data": "0x", + "blockHash": "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd", + "blockNumber": "0x63ed18bf633dbce0", + "blockTimestamp": "0x90765cca6bdae99", + "transactionHash": "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd", + "transactionIndex": "0xe68adf1c4dbf1fd6", + "logIndex": "0xf8a1baa1355ebec3", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "transactionHash": "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd", + "transactionIndex": "0x6f7d04460b4d0672", + "blockHash": "0x449d0b8db95907958f8313e98af7b82fc90644e5fe4b0141d97eea540e9e55dd", + "blockNumber": "0xd93c30843c3fdb27", + "gasUsed": "0x3a5c127454f3448", + "effectiveGasPrice": "0x589393a53b87f730", + "from": "0x92c7fd952883064c80c1c6670bc5afc972346bb9", + "to": "0x92c7fd952883064c80c1c6670bc5afc972346bb9", + "contractAddress": null + } +} \ No newline at end of file diff --git a/tests/fixtures/primitives/ExternalTransaction.json b/tests/fixtures/primitives/ExternalTransaction.json new file mode 100644 index 000000000..ae39df2c0 --- /dev/null +++ b/tests/fixtures/primitives/ExternalTransaction.json @@ -0,0 +1,18 @@ +{ + "type": "0x0", + "chainId": "0x1", + "nonce": "0x30845b0630d8653c", + "gasPrice": "0x17db902f3e615004", + "gas": "0x250b5a45da474625", + "to": "0xc92da16686ffc2110a2c1d39560cac6351280b72", + "value": "0xeddb5f39546953c9", + "input": "0x", + "r": "0xbf6bf8f50caba52d", + "s": "0xbde8e48e1e1e8a3f", + "v": "0x26", + "hash": "0x2759251a2e5a9cbf5056febf57455bc67911121cd4a15bc2f66febd9f18bc980", + "blockHash": "0xb98afe0ebf1ca1cc86468427a5d57e7ad429748075696fe6c6a086aed4de8f1a", + "blockNumber": "0xc4ddc8ce16e242f9", + "transactionIndex": "0x5eba7cb290ff59b0", + "from": "0xc92da16686ffc2110a2c1d39560cac6351280b72" +} \ No newline at end of file