Skip to content

Commit

Permalink
feat: test targets
Browse files Browse the repository at this point in the history
  • Loading branch information
joske committed Aug 7, 2024
1 parent be171ce commit 2f70c8c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
1 change: 1 addition & 0 deletions console/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ wasm = [
"snarkvm-parameters/wasm"
]
test = []
test_targets = []

[dependencies.snarkvm-algorithms]
path = "../../algorithms"
Expand Down
7 changes: 7 additions & 0 deletions console/network/src/canary_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
}

Expand Down
9 changes: 5 additions & 4 deletions console/network/src/mainnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
Expand All @@ -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()
}

Expand Down
7 changes: 7 additions & 0 deletions console/network/src/testnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
}

Expand Down

0 comments on commit 2f70c8c

Please sign in to comment.