From bef750e07f20a086d40bdf7f79232f01a7a05d73 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Wed, 3 Jul 2024 11:04:14 +0200 Subject: [PATCH] node-data: move faker methods to relevant modules --- node-data/src/ledger.rs | 15 --------------- node-data/src/ledger/block.rs | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/node-data/src/ledger.rs b/node-data/src/ledger.rs index eba2584324..42b2155379 100644 --- a/node-data/src/ledger.rs +++ b/node-data/src/ledger.rs @@ -154,21 +154,6 @@ pub mod faker { use super::*; use crate::bls::PublicKeyBytes; use rand::Rng; - use transaction::faker::gen_dummy_tx; - - impl Dummy for Block { - /// Creates a block with 3 transactions and random header. - fn dummy_with_rng(_config: &T, rng: &mut R) -> Self { - let txs = vec![ - gen_dummy_tx(rng.gen()), - gen_dummy_tx(rng.gen()), - gen_dummy_tx(rng.gen()), - ]; - let header: Header = Faker.fake(); - - Block::new(header, txs).expect("valid hash") - } - } impl Dummy for PublicKeyBytes { fn dummy_with_rng(_config: &T, rng: &mut R) -> Self { diff --git a/node-data/src/ledger/block.rs b/node-data/src/ledger/block.rs index 5eddcbb3ea..85e1dde63d 100644 --- a/node-data/src/ledger/block.rs +++ b/node-data/src/ledger/block.rs @@ -84,3 +84,24 @@ impl BlockWithLabel { matches!(self.label(), Label::Final(_)) || self.blk.header().height == 0 } } + +#[cfg(any(feature = "faker", test))] +pub mod faker { + use super::*; + use rand::Rng; + use transaction::faker::gen_dummy_tx; + + impl Dummy for Block { + /// Creates a block with 3 transactions and random header. + fn dummy_with_rng(_config: &T, rng: &mut R) -> Self { + let txs = vec![ + gen_dummy_tx(rng.gen()), + gen_dummy_tx(rng.gen()), + gen_dummy_tx(rng.gen()), + ]; + let header: Header = Faker.fake(); + + Block::new(header, txs).expect("valid hash") + } + } +}