Skip to content

Commit 39d04d1

Browse files
authored
chore: move the Seismic tx test helpers into their own crate (#483)
Fixes SEI-343 reth-seismic-primitives exported 458 lines of test helpers as `pub mod test_utils` — transaction builders, client-side encryption, signing fixtures with hardcoded private keys — from the default public API of a crate every consumer depends on, the production node included. They now live in crates/seismic/test-utils (`reth-seismic-test-utils`), reached only through a `[dev-dependencies]` line. `[dev-dependencies]` are in scope for the listing crate's test, bench, and example targets, so `use reth_seismic_test_utils::…` from a crate's `src/` does not resolve. Nothing marks a crate dev-only workspace-wide — someone can always move the line into `[dependencies]` — but that is one visible line in the manifest of the crate doing it, caught in review. What a dev-dependency rules out is the leak a feature cannot avoid: features unify across a build and dev-dependency features fold in whenever test targets are built, so under a `test-utils` feature on the primitives crate, one crate's dev-dependency would turn the module on for every crate in the same `cargo test --workspace`. Production code in reth-seismic-node could import the helpers, compile clean in CI's test job, and break only in a later `cargo build` of the binary — an error in a crate nobody touched. The file moves verbatim. reth-seismic-primitives drops the module and the ten dependencies only those helpers used: seismic-crypto, seismic-alloy-network, seismic-alloy-rpc-types, alloy-signer-local, alloy-rpc-types, alloy-dyn-abi, alloy-network, enr, k256, and anyhow. Its manifest now lists what the primitives actually need. secp256k1 is the one that stays: the rest of the crate reaches it only from the `arbitrary` impl, so it becomes optional under the `arbitrary` feature and a dev-dependency for the crate's own tests, the shape rand_08 already has there. Call sites take the new import path with a dev-dependency: primitives/src/transaction/signed.rs, rpc/src/eth/receipt.rs, rpc/src/eth/utils.rs, txpool/src/transaction.rs, and txpool/benches/eviction_scan.rs. reth-seismic-node's `utils::test_utils` re-export goes away — its only consumers are that crate's own e2e tests, which depend on the new crate directly — and the module keeps `get_nonce` behind the node's `test-utils` feature. primitives dev-depends on a crate that depends on primitives. Cargo allows dev-dependency cycles: dev edges do not participate in the lib build graph, and this repo already leans on the self-cycle reth-seismic-node dev-depending on itself with `features = ["test-utils"]`.
1 parent bd9676b commit 39d04d1

18 files changed

Lines changed: 104 additions & 76 deletions

File tree

Cargo.lock

Lines changed: 26 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ members = [
2121
"crates/seismic/primitives/",
2222
"crates/seismic/reth/",
2323
"crates/seismic/rpc/",
24+
"crates/seismic/test-utils/",
2425
"crates/seismic/txpool/",
2526
"crates/seismic/hardforks",
2627
"crates/seismic/fuzz",
@@ -358,6 +359,7 @@ reth-seismic-payload-builder = { path = "crates/seismic/payload" }
358359
reth-seismic-primitives = { path = "crates/seismic/primitives" }
359360
reth-seismic-reth = { path = "crates/seismic/reth" }
360361
reth-seismic-rpc = { path = "crates/seismic/rpc" }
362+
reth-seismic-test-utils = { path = "crates/seismic/test-utils" }
361363
reth-seismic-txpool = { path = "crates/seismic/txpool" }
362364
reth-seismic-forks = { path = "crates/seismic/hardforks", default-features = false }
363365
reth-seismic-fuzz = { path = "crates/seismic/fuzz" }

crates/seismic/node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ reth-e2e-test-utils = { workspace = true }
9595
reth-rpc-e2e-tests.workspace = true
9696
reth-seismic-evm.workspace = true
9797
reth-seismic-chainspec.workspace = true
98+
reth-seismic-test-utils.workspace = true
9899
alloy-network = { workspace = true }
99100
alloy-chains.workspace = true
100101
alloy-signer-local = { workspace = true }

crates/seismic/node/src/utils.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,14 @@ pub mod e2e {
9494
}
9595
}
9696

97-
/// RPC test utilities: nonce helpers, re-exported test helpers.
97+
/// RPC test utilities: nonce helpers.
9898
pub mod test_utils {
9999
use alloy_primitives::Address;
100100
use alloy_rpc_types::{Block, Header, Transaction, TransactionReceipt};
101101
use jsonrpsee::http_client::HttpClient;
102102
use reth_rpc_eth_api::EthApiClient;
103103
use seismic_alloy_rpc_types::SeismicTransactionRequest;
104104

105-
pub use reth_seismic_primitives::test_utils::{
106-
client_decrypt, client_encrypt, get_ciphertext, get_client_io_sk, get_encryption_nonce,
107-
get_network_public_key, get_plaintext, get_seismic_elements, get_seismic_metadata,
108-
get_seismic_tx, get_signed_read_seismic_metadata, get_signed_seismic_call_bytes,
109-
get_signed_seismic_call_typed_data, get_signed_seismic_tx, get_signed_seismic_tx_bytes,
110-
get_signed_seismic_tx_encoding, get_signed_seismic_tx_typed_data, get_signing_private_key,
111-
get_unsigned_seismic_call_request, get_unsigned_seismic_tx_request,
112-
get_unsigned_seismic_tx_typed_data, get_wrong_private_key, sign_seismic_tx, sign_tx,
113-
};
114-
115105
/// Get the nonce from the client
116106
pub async fn get_nonce(client: &HttpClient, address: Address) -> u64 {
117107
let nonce = EthApiClient::<

crates/seismic/node/tests/e2e/fuzz.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_param
1616
use rand::{rngs::SmallRng, Rng, SeedableRng};
1717
use reth_seismic_node::utils::{
1818
e2e::{ensure_mock_purpose_keys, setup},
19-
test_utils::{get_nonce, get_signed_seismic_tx_bytes},
19+
test_utils::get_nonce,
2020
};
2121
use reth_seismic_rpc::ext::EthApiOverrideClient;
22+
use reth_seismic_test_utils::get_signed_seismic_tx_bytes;
2223
use tracing::{info, trace};
2324

2425
/// Number of random payloads per fuzz batch

crates/seismic/node/tests/e2e/integration.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,16 @@ use reth_e2e_test_utils::wallet::Wallet;
3131
use reth_rpc_eth_api::EthApiClient;
3232
use reth_seismic_node::utils::{
3333
e2e::{ensure_mock_purpose_keys, setup, SeismicTestNode},
34-
test_utils::{
35-
client_decrypt, get_nonce, get_plaintext, get_signed_read_seismic_metadata,
36-
get_signed_seismic_call_bytes, get_signed_seismic_call_typed_data,
37-
get_signed_seismic_tx_bytes, get_unsigned_seismic_call_request,
38-
get_unsigned_seismic_tx_request,
39-
},
40-
};
41-
use reth_seismic_primitives::{
42-
test_utils::{get_unsigned_legacy_tx_request, sign_tx},
43-
SeismicBlock, SeismicTransactionSigned,
34+
test_utils::get_nonce,
4435
};
36+
use reth_seismic_primitives::{SeismicBlock, SeismicTransactionSigned};
4537
use reth_seismic_rpc::ext::EthApiOverrideClient;
38+
use reth_seismic_test_utils::{
39+
client_decrypt, get_plaintext, get_signed_read_seismic_metadata, get_signed_seismic_call_bytes,
40+
get_signed_seismic_call_typed_data, get_signed_seismic_tx_bytes,
41+
get_unsigned_legacy_tx_request, get_unsigned_seismic_call_request,
42+
get_unsigned_seismic_tx_request, sign_tx,
43+
};
4644
use seismic_alloy_consensus::SeismicTxEnvelope;
4745
use seismic_alloy_network::{
4846
reth::builder::seismic_reth_tx_builder, wallet::SeismicWallet, SeismicReth,

crates/seismic/node/tests/e2e/wrong_chain_import.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ use reth_seismic_node::{
1919
engine::SeismicPayloadTypes,
2020
utils::e2e::{ensure_mock_purpose_keys, setup},
2121
};
22-
use reth_seismic_primitives::{
23-
test_utils::{get_unsigned_legacy_tx_request, sign_tx},
24-
SeismicBlock, SeismicTransactionSigned,
25-
};
22+
use reth_seismic_primitives::{SeismicBlock, SeismicTransactionSigned};
23+
use reth_seismic_test_utils::{get_unsigned_legacy_tx_request, sign_tx};
2624
use std::time::Duration;
2725

2826
/// A block containing a transaction signed for a different chain must be rejected by

crates/seismic/primitives/Cargo.toml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ description = "Seismic primitive types"
1212
workspace = true
1313

1414
[dependencies]
15-
seismic-crypto.workspace = true
16-
1715
# reth
1816
reth-primitives-traits = { workspace = true, features = ["serde"] }
1917
reth-codecs = { workspace = true, optional = true }
@@ -26,11 +24,9 @@ alloy-primitives = { workspace = true, features = ["serde"] }
2624
alloy-consensus.workspace = true
2725
alloy-rlp.workspace = true
2826
alloy-eips = { workspace = true, features = ["k256"] }
29-
alloy-network = { workspace = true }
3027

3128
# seismic
3229
seismic-alloy-consensus.workspace = true
33-
seismic-alloy-network = { workspace = true }
3430
seismic-revm.workspace = true
3531

3632
# codec
@@ -41,31 +37,24 @@ serde_with = { workspace = true, optional = true }
4137

4238
# misc
4339
derive_more = { workspace = true, features = ["deref", "from", "into", "constructor"] }
44-
secp256k1 = { workspace = true, features = ["rand", "std", "global-context", "recovery"] }
45-
anyhow.workspace = true
40+
secp256k1 = { workspace = true, features = ["rand", "std", "global-context", "recovery"], optional = true }
4641
tracing.workspace = true
4742

4843
# test
4944
arbitrary = { workspace = true, features = ["derive"], optional = true }
5045
rand_08 = { workspace = true, optional = true }
5146
proptest = { workspace = true, optional = true }
5247

53-
# test utils
54-
alloy-signer-local.workspace = true
55-
alloy-rpc-types.workspace = true
56-
k256.workspace = true
57-
enr = { workspace = true, features = ["rust-secp256k1"] }
58-
alloy-dyn-abi.workspace = true
59-
seismic-alloy-rpc-types.workspace = true
60-
6148
[dev-dependencies]
6249
arbitrary.workspace = true
6350
proptest-arbitrary-interop.workspace = true
6451
proptest.workspace = true
6552
rand.workspace = true
6653
rand_08.workspace = true
6754
reth-codecs = { workspace = true, features = ["test-utils"] }
55+
reth-seismic-test-utils.workspace = true
6856
rstest.workspace = true
57+
secp256k1 = { workspace = true, features = ["rand", "std", "global-context", "recovery"] }
6958
serde_json.workspace = true
7059
bincode.workspace = true
7160

@@ -81,17 +70,14 @@ std = [
8170
"serde?/std",
8271
"bytes?/std",
8372
"derive_more/std",
84-
"secp256k1/std",
73+
"secp256k1?/std",
8574
"alloy-rlp/std",
8675
"reth-zstd-compressors?/std",
8776
"seismic-alloy-consensus/std",
8877
"revm-context/std",
8978
"serde_json/std",
9079
"alloy-evm/std",
9180
"serde_with?/std",
92-
"k256/std",
93-
"seismic-alloy-network/std",
94-
"seismic-alloy-rpc-types/std",
9581
"tracing/std",
9682
]
9783
reth-codec = [
@@ -114,13 +100,9 @@ serde = [
114100
"reth-codecs?/serde",
115101
"seismic-alloy-consensus/serde",
116102
"rand/serde",
117-
"secp256k1/serde",
103+
"secp256k1?/serde",
118104
"revm-context/serde",
119-
"enr/serde",
120-
"k256/serde",
121105
"rand_08?/serde",
122-
"seismic-alloy-network/serde",
123-
"seismic-alloy-rpc-types/serde",
124106
"seismic-revm/serde",
125107
]
126108
serde-bincode-compat = [
@@ -134,7 +116,7 @@ serde-bincode-compat = [
134116
arbitrary = [
135117
"std",
136118
"dep:arbitrary",
137-
# "dep:secp256k1",
119+
"dep:secp256k1",
138120
"secp256k1/rand",
139121
"reth-primitives-traits/arbitrary",
140122
"reth-codecs?/arbitrary",
@@ -143,7 +125,4 @@ arbitrary = [
143125
"alloy-eips/arbitrary",
144126
"alloy-primitives/arbitrary",
145127
"rand_08",
146-
"alloy-dyn-abi/arbitrary",
147-
"alloy-rpc-types/arbitrary",
148-
"seismic-alloy-rpc-types/arbitrary",
149128
]

crates/seismic/primitives/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub use transaction::{
1818

1919
mod receipt;
2020
pub use receipt::SeismicReceipt;
21-
pub mod test_utils;
2221

2322
/// Seismic-specific block type.
2423
pub type SeismicBlock = alloy_consensus::Block<SeismicTransactionSigned>;

crates/seismic/primitives/src/transaction/signed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ pub mod serde_bincode_compat {
724724
mod tests {
725725
use core::str::FromStr;
726726

727-
use crate::test_utils::{get_signed_seismic_tx, get_signing_private_key};
727+
use reth_seismic_test_utils::{get_signed_seismic_tx, get_signing_private_key};
728728

729729
use super::*;
730730
use alloy_primitives::{aliases::U96, hex, U256};

0 commit comments

Comments
 (0)