From 2f70c8c9e362664859ce233cd7e05554d2c8893f Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 7 Aug 2024 14:31:02 +0200 Subject: [PATCH] feat: test targets --- Cargo.toml | 1 + console/Cargo.toml | 1 + console/network/Cargo.toml | 1 + console/network/src/canary_v0.rs | 7 +++++++ console/network/src/mainnet_v0.rs | 9 +++++---- console/network/src/testnet_v0.rs | 7 +++++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2140fafde8..d74a3ff2aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -149,6 +149,7 @@ parameters = [ "snarkvm-parameters" ] synthesizer = [ "snarkvm-synthesizer" ] utilities = [ "snarkvm-utilities" ] wasm = [ "snarkvm-wasm" ] +test_targets = [ "snarkvm-console/test_targets" ] [dependencies.snarkvm-algorithms] path = "./algorithms" diff --git a/console/Cargo.toml b/console/Cargo.toml index a860213836..765dbfb4ba 100644 --- a/console/Cargo.toml +++ b/console/Cargo.toml @@ -58,3 +58,4 @@ network = [ "collections", "snarkvm-console-network" ] program = [ "network", "snarkvm-console-program" ] serial = [ "snarkvm-console-collections/serial" ] types = [ "snarkvm-console-types" ] +test_targets = [ "snarkvm-console-network/test_targets" ] diff --git a/console/network/Cargo.toml b/console/network/Cargo.toml index 551bd13eee..7607af4cad 100644 --- a/console/network/Cargo.toml +++ b/console/network/Cargo.toml @@ -13,6 +13,7 @@ wasm = [ "snarkvm-parameters/wasm" ] test = [] +test_targets = [] [dependencies.snarkvm-algorithms] path = "../../algorithms" diff --git a/console/network/src/canary_v0.rs b/console/network/src/canary_v0.rs index e4b2cde267..04a8bc0b25 100644 --- a/console/network/src/canary_v0.rs +++ b/console/network/src/canary_v0.rs @@ -135,9 +135,15 @@ impl Network for CanaryV0 { /// The network edition. const EDITION: u16 = 0; /// The genesis block coinbase target. + #[cfg(not(feature = "test_targets"))] const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).saturating_sub(1); + #[cfg(feature = "test_targets")] + const GENESIS_COINBASE_TARGET: u64 = (1u64 << 5).saturating_sub(1); /// The genesis block proof target. + #[cfg(not(feature = "test_targets"))] const GENESIS_PROOF_TARGET: u64 = 1u64 << 27; + #[cfg(feature = "test_targets")] + const GENESIS_PROOF_TARGET: u64 = 1u64 << 3; /// The fixed timestamp of the genesis block. const GENESIS_TIMESTAMP: i64 = 1715776496 /* 2024-05-15 12:34:56 UTC */; /// The network ID. @@ -151,6 +157,7 @@ impl Network for CanaryV0 { /// Returns the genesis block bytes. fn genesis_bytes() -> &'static [u8] { + println!("genesis_bytes: target = {}/{}", Self::GENESIS_COINBASE_TARGET, Self::GENESIS_PROOF_TARGET); snarkvm_parameters::canary::GenesisBytes::load_bytes() } diff --git a/console/network/src/mainnet_v0.rs b/console/network/src/mainnet_v0.rs index 9ca0addd76..fb39f30af7 100644 --- a/console/network/src/mainnet_v0.rs +++ b/console/network/src/mainnet_v0.rs @@ -136,18 +136,18 @@ impl Network for MainnetV0 { /// The network edition. const EDITION: u16 = 0; /// The genesis block coinbase target. - #[cfg(not(feature = "test"))] + #[cfg(not(any(feature = "test", feature = "test_targets")))] const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).saturating_sub(1); /// The genesis block coinbase target. /// This is deliberately set to a low value (32) for testing purposes only. - #[cfg(feature = "test")] + #[cfg(any(feature = "test", feature = "test_targets"))] const GENESIS_COINBASE_TARGET: u64 = (1u64 << 5).saturating_sub(1); /// The genesis block proof target. - #[cfg(not(feature = "test"))] + #[cfg(not(any(feature = "test", feature = "test_targets")))] const GENESIS_PROOF_TARGET: u64 = 1u64 << 27; /// The genesis block proof target. /// This is deliberately set to a low value (8) for testing purposes only. - #[cfg(feature = "test")] + #[cfg(any(feature = "test", feature = "test_targets"))] const GENESIS_PROOF_TARGET: u64 = 1u64 << 3; /// The fixed timestamp of the genesis block. const GENESIS_TIMESTAMP: i64 = 1696118400 /* 2023-10-01 00:00:00 UTC */; @@ -162,6 +162,7 @@ impl Network for MainnetV0 { /// Returns the genesis block bytes. fn genesis_bytes() -> &'static [u8] { + println!("genesis_bytes: target = {}/{}", Self::GENESIS_COINBASE_TARGET, Self::GENESIS_PROOF_TARGET); snarkvm_parameters::mainnet::GenesisBytes::load_bytes() } diff --git a/console/network/src/testnet_v0.rs b/console/network/src/testnet_v0.rs index 0f52a1510b..2d575d325d 100644 --- a/console/network/src/testnet_v0.rs +++ b/console/network/src/testnet_v0.rs @@ -135,9 +135,15 @@ impl Network for TestnetV0 { /// The network edition. const EDITION: u16 = 0; /// The genesis block coinbase target. + #[cfg(not(feature = "test_targets"))] const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).saturating_sub(1); + #[cfg(feature = "test_targets")] + const GENESIS_COINBASE_TARGET: u64 = (1u64 << 5).saturating_sub(1); /// The genesis block proof target. + #[cfg(not(feature = "test_targets"))] const GENESIS_PROOF_TARGET: u64 = 1u64 << 27; + #[cfg(feature = "test_targets")] + const GENESIS_PROOF_TARGET: u64 = 1u64 << 3; /// The fixed timestamp of the genesis block. const GENESIS_TIMESTAMP: i64 = 1715776496 /* 2024-05-15 12:34:56 UTC */; /// The network ID. @@ -151,6 +157,7 @@ impl Network for TestnetV0 { /// Returns the genesis block bytes. fn genesis_bytes() -> &'static [u8] { + println!("genesis_bytes: target = {}/{}", Self::GENESIS_COINBASE_TARGET, Self::GENESIS_PROOF_TARGET); snarkvm_parameters::testnet::GenesisBytes::load_bytes() }