diff --git a/Cargo.lock b/Cargo.lock
index 1e45818a6..eb0a236c3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1467,6 +1467,7 @@ version = "2.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c25829bde82205da46e1823b2259db6273379f626fc211f126f65654a2669be"
dependencies = [
+ "chrono",
"deunicode",
"dummy",
"rand",
diff --git a/Cargo.toml b/Cargo.toml
index 9118f0ff5..fd222dda1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -104,7 +104,7 @@ testcontainers = "=0.15.0"
testcontainers-modules = { version = "=0.3.5", features = ["postgres"] }
# test
-fake = { version = "=2.9.2", features = ["derive"] }
+fake = { version = "=2.9.2", features = ["chrono", "derive"] }
# ------------------------------------------------------------------------------
# Platform specific dependencies
diff --git a/src/eth/primitives/call_input.rs b/src/eth/primitives/call_input.rs
index 2d315706e..ad383735d 100644
--- a/src/eth/primitives/call_input.rs
+++ b/src/eth/primitives/call_input.rs
@@ -2,14 +2,17 @@ use crate::eth::primitives::Address;
use crate::eth::primitives::Bytes;
use crate::eth::primitives::Wei;
-#[derive(Debug, Clone, serde::Deserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, fake::Dummy, serde::Serialize, serde::Deserialize)]
pub struct CallInput {
+ #[serde(rename = "from")]
pub from: Option
,
+
+ #[serde(rename = "to")]
pub to: Option,
- #[serde(default)]
+ #[serde(rename = "value", default)]
pub value: Wei,
- #[serde(alias = "input", default)]
+ #[serde(rename = "data", alias = "input", default)]
pub data: Bytes,
}
diff --git a/src/eth/primitives/ecdsa_rs.rs b/src/eth/primitives/ecdsa_rs.rs
index c7bd47d92..ba50bf1cf 100644
--- a/src/eth/primitives/ecdsa_rs.rs
+++ b/src/eth/primitives/ecdsa_rs.rs
@@ -1,10 +1,12 @@
+use display_json::DebugAsJson;
use ethereum_types::U256;
+use fake::Dummy;
+use fake::Faker;
use crate::gen_newtype_from;
-// Type representing `r` and `s` variables
-// from the ECDSA signature
-#[derive(Clone, Copy)]
+// Type representing `r` and `s` variables from the ECDSA signature.
+#[derive(DebugAsJson, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct EcdsaRs(U256);
impl From for U256 {
@@ -13,7 +15,13 @@ impl From for U256 {
}
}
+impl Dummy for EcdsaRs {
+ fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self {
+ Self(U256([rng.next_u64(), rng.next_u64(), rng.next_u64(), rng.next_u64()]))
+ }
+}
+
// -----------------------------------------------------------------------------
// Conversions: Self -> Other
// -----------------------------------------------------------------------------
-gen_newtype_from!(self = EcdsaRs, other = i64, [u8; 32]);
+gen_newtype_from!(self = EcdsaRs, other = u8, u16, u32, u64, u128, U256, i8, i16, i32, i64, i128, [u8; 32]);
diff --git a/src/eth/primitives/ecdsa_v.rs b/src/eth/primitives/ecdsa_v.rs
index 4d39150e1..d58699ba6 100644
--- a/src/eth/primitives/ecdsa_v.rs
+++ b/src/eth/primitives/ecdsa_v.rs
@@ -1,10 +1,12 @@
+use display_json::DebugAsJson;
use ethereum_types::U64;
+use fake::Dummy;
+use fake::Faker;
use crate::gen_newtype_from;
-// Type representing `v` variable
-// from the ECDSA signature
-#[derive(Clone, Copy)]
+// Type representing `v` variable from the ECDSA signature.
+#[derive(DebugAsJson, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct EcdsaV(U64);
impl From for U64 {
@@ -13,7 +15,13 @@ impl From for U64 {
}
}
+impl Dummy for EcdsaV {
+ fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self {
+ Self::from(rng.next_u64())
+ }
+}
+
// -----------------------------------------------------------------------------
// Conversions: Self -> Other
// -----------------------------------------------------------------------------
-gen_newtype_from!(self = EcdsaV, other = i32, [u8; 8]);
+gen_newtype_from!(self = EcdsaV, other = u8, u16, u32, u64, U64, i8, i16, i32, [u8; 8]);
diff --git a/src/eth/primitives/execution_metrics.rs b/src/eth/primitives/execution_metrics.rs
index 23006718b..2e497c97b 100644
--- a/src/eth/primitives/execution_metrics.rs
+++ b/src/eth/primitives/execution_metrics.rs
@@ -1,6 +1,6 @@
use display_json::DebugAsJson;
-#[derive(DebugAsJson, Clone, Copy, Default, derive_more::Add, derive_more::AddAssign, serde::Serialize)]
+#[derive(DebugAsJson, Clone, Copy, Default, PartialEq, Eq, derive_more::Add, derive_more::AddAssign, fake::Dummy, serde::Serialize, serde::Deserialize)]
pub struct EvmExecutionMetrics {
/// Number of account reads during EVM execution.
pub account_reads: usize,
diff --git a/src/eth/primitives/mod.rs b/src/eth/primitives/mod.rs
index 6cc37fc33..66b7cd218 100644
--- a/src/eth/primitives/mod.rs
+++ b/src/eth/primitives/mod.rs
@@ -120,11 +120,6 @@ mod tests {
// FIX: gen_test_serde!(ExecutionChanges);
// FIX: gen_test_serde!(TransactionMined);
// TODO: gen_test_serde!(BlockFilter);
- // TODO: gen_test_serde!(CallInput);
- // TODO: gen_test_serde!(DateTimeNow);
- // TODO: gen_test_serde!(EcdsaRs);
- // TODO: gen_test_serde!(EcdsaV);
- // TODO: gen_test_serde!(EvmExecutionMetrics);
// TODO: gen_test_serde!(ExecutionConflict);
// TODO: gen_test_serde!(ExecutionConflicts);
// TODO: gen_test_serde!(ExecutionConflictsBuilder);
@@ -141,15 +136,19 @@ mod tests {
// TODO: gen_test_serde!(StratusError);
// TODO: gen_test_serde!(TransactionExecution);
// TODO: gen_test_serde!(TransactionStage);
- // Type aliases
gen_test_serde!(Account);
gen_test_serde!(Address);
gen_test_serde!(BlockHeader);
gen_test_serde!(BlockNumber);
gen_test_serde!(Bytes);
+ gen_test_serde!(CallInput);
gen_test_serde!(ChainId);
gen_test_serde!(CodeHash);
+ gen_test_serde!(DateTimeNow);
gen_test_serde!(Difficulty);
+ gen_test_serde!(EcdsaRs);
+ gen_test_serde!(EcdsaV);
+ gen_test_serde!(EvmExecutionMetrics);
gen_test_serde!(ExecutionResult);
gen_test_serde!(Gas);
gen_test_serde!(Hash);
diff --git a/src/eth/primitives/now.rs b/src/eth/primitives/now.rs
index 4eae248f1..d02763c65 100644
--- a/src/eth/primitives/now.rs
+++ b/src/eth/primitives/now.rs
@@ -1,8 +1,9 @@
use chrono::DateTime;
use chrono::Utc;
+use display_json::DebugAsJson;
/// DateTime that automatically sets the current time when created.
-#[derive(Debug, Clone, derive_more::Deref, serde::Serialize)]
+#[derive(DebugAsJson, Clone, PartialEq, Eq, derive_more::Deref, fake::Dummy, serde::Serialize, serde::Deserialize)]
pub struct DateTimeNow(#[deref] DateTime);
impl Default for DateTimeNow {