Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests of match move #1

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9604b1a
added functions for fetching block vectors
idky137 Feb 20, 2024
878df92
inserted new network methods for vector fetching into zebra-chain
idky137 Feb 20, 2024
08863d2
changed tag back to test/feature=branch
idky137 Feb 21, 2024
be1da76
changed tag back to test/feature=branch
idky137 Feb 21, 2024
39886e9
changed tag back to test/feature=branch
idky137 Feb 21, 2024
d596ece
changed feature tag to proptest-impl, started implementing in zebra-c…
idky137 Feb 21, 2024
35b24fa
adding methods to zebra-consensus, lifetime error in src/transaction/…
idky137 Feb 22, 2024
fa4ebb9
finished adding methods to zebra-consensus
idky137 Feb 22, 2024
ed34829
finished adding new methods to zebrad
idky137 Feb 22, 2024
eb98722
added new methods to zebra-rpc and zebra-scan
idky137 Feb 22, 2024
8960c45
finished removing statements matching on Network from tests
idky137 Feb 22, 2024
fc17002
updated new error message
idky137 Feb 23, 2024
a57133c
forbid unsafe code in new file
zancas Feb 23, 2024
5c9707d
build(deps): bump the prod group with 3 updates (#8283)
dependabot[bot] Feb 19, 2024
542a5c3
add(scan): Test the `RegisterKeys` scan service call (#8281)
upbqdn Feb 19, 2024
7accfb7
fix(docker): set log rotation to avoid docker bugs (#8269)
chairulakmal Feb 20, 2024
385c36e
build(deps): bump the devops group with 1 update (#8270)
dependabot[bot] Feb 20, 2024
5570096
add(scan): Implement `scan` gRPC method (#8268)
arya2 Feb 20, 2024
b16aad3
tests(grpc): Unit tests (#8293)
oxarbitrage Feb 20, 2024
2cda29a
fix(ci): keep `gcloud` arguments consistency (#8305)
gustavovalverde Feb 21, 2024
b8fa5c1
build(deps): bump the devops group with 1 update (#8306)
dependabot[bot] Feb 21, 2024
1123c93
fix(scan): Fix minor concurrency bug in the `scan` gRPC method (#8303)
arya2 Feb 21, 2024
0aa56c8
ref(docker): publish less tags in Docker Hub (#8300)
gustavovalverde Feb 22, 2024
cd9702c
Update `Cargo.lock` (#8310)
upbqdn Feb 22, 2024
aaa6656
Update CONTRIBUTING.md (#8304)
mpguerra Feb 22, 2024
cc0c123
chore: Update Checkpoints (#8309)
upbqdn Feb 22, 2024
b00b55d
update dry-run release commands (#8298)
oxarbitrage Feb 22, 2024
59aecf6
add(scan): Adds gRPC reflection and documents how to use the zebra-sc…
arya2 Feb 22, 2024
66d9558
chore: allow crater runs (#8171)
bishopcheckmate Feb 23, 2024
a72fbae
chore: Update docs for building Zebra (#8315)
upbqdn Feb 23, 2024
88f2a33
updated to main, updated new grpc tests
idky137 Feb 23, 2024
5b48958
remove unused 'any(test' reduce complexity, and increase readability
zancas Feb 23, 2024
699fab7
reduce complexity, the whole mod is behind this feature
zancas Feb 23, 2024
f57d1ec
remove more unnecessary feature gating
zancas Feb 23, 2024
06724e2
make is_mainnet and is_default_testnet
zancas Feb 23, 2024
109b12f
add doc-comment simplify return type
zancas Feb 23, 2024
b4d6b24
add doc-comment and question
zancas Feb 23, 2024
e558ce9
add new error variants with more explicit names
zancas Feb 23, 2024
28f77a0
add "not yet tested!" references to received values
zancas Feb 23, 2024
1ce351b
chore: Release v1.6.0 (#8319)
upbqdn Feb 23, 2024
09d5052
added unit tests, added test flag to new code to fix testing within t…
idky137 Feb 26, 2024
fa37c50
updated unit tests.
idky137 Feb 26, 2024
380b4b8
updated unit tests.
idky137 Feb 26, 2024
ce45a5e
updated unit tests.
idky137 Feb 26, 2024
3eef5ff
fix lints
zancas Feb 27, 2024
93962af
fix clippy lint
zancas Feb 28, 2024
2300a5f
slightly more succinct version that leverage ubiquitous proptest fram…
zancas Feb 28, 2024
0a41e23
add network
zancas Feb 28, 2024
8826989
use standard proptest patterns, remove uneeded assert!
zancas Feb 28, 2024
79d4e83
rm more assert!
zancas Feb 28, 2024
0045efb
make number of cases explicit for readability
zancas Feb 28, 2024
6cdeaad
name mod for ease of reference, and start porting next test
zancas Feb 28, 2024
5984b87
slightly more succinct
zancas Feb 28, 2024
0eb7291
start leveraging proptests on get_block_tests
zancas Feb 28, 2024
50e3302
succinct element by element comparison for get_block_iter
zancas Feb 28, 2024
de4bc4c
extend get blocks test
zancas Feb 28, 2024
5bb6f05
readd zebra-grpc tests
zancas Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions zebra-chain/src/block/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,7 @@ fn block_test_vectors_height_testnet() {
/// Test that the block test vector indexes match the heights in the block data,
/// and that each post-sapling block has a corresponding final sapling root.
fn block_test_vectors_height(network: Network) {
let (block_iter, sapling_roots) = match network {
Mainnet => (
zebra_test::vectors::MAINNET_BLOCKS.iter(),
zebra_test::vectors::MAINNET_FINAL_SAPLING_ROOTS.clone(),
),
Testnet => (
zebra_test::vectors::TESTNET_BLOCKS.iter(),
zebra_test::vectors::TESTNET_FINAL_SAPLING_ROOTS.clone(),
),
};
let (block_iter, sapling_roots) = network.get_block_sapling_roots_iter();

for (&height, block) in block_iter {
let block = block
Expand Down Expand Up @@ -262,16 +253,7 @@ fn block_commitment_testnet() {
///
/// TODO: add chain history test vectors?
fn block_commitment(network: Network) {
let (block_iter, sapling_roots) = match network {
Mainnet => (
zebra_test::vectors::MAINNET_BLOCKS.iter(),
zebra_test::vectors::MAINNET_FINAL_SAPLING_ROOTS.clone(),
),
Testnet => (
zebra_test::vectors::TESTNET_BLOCKS.iter(),
zebra_test::vectors::TESTNET_FINAL_SAPLING_ROOTS.clone(),
),
};
let (block_iter, sapling_roots) = network.get_block_sapling_roots_iter();

for (height, block) in block_iter {
let block = block
Expand Down
15 changes: 4 additions & 11 deletions zebra-chain/src/history_tree/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ use crate::{

use color_eyre::eyre;
use eyre::Result;
use zebra_test::vectors::{
MAINNET_BLOCKS, MAINNET_FINAL_SAPLING_ROOTS, TESTNET_BLOCKS, TESTNET_FINAL_SAPLING_ROOTS,
};

/// Test the history tree using the activation block of a network upgrade
/// and its next block.
Expand All @@ -36,10 +33,8 @@ fn push_and_prune_for_network_upgrade(
network: Network,
network_upgrade: NetworkUpgrade,
) -> Result<()> {
let (blocks, sapling_roots) = match network {
Network::Mainnet => (&*MAINNET_BLOCKS, &*MAINNET_FINAL_SAPLING_ROOTS),
Network::Testnet => (&*TESTNET_BLOCKS, &*TESTNET_FINAL_SAPLING_ROOTS),
};
let (blocks, sapling_roots) = network.get_block_sapling_roots_map();

let height = network_upgrade.activation_height(network).unwrap().0;

// Load first block (activation block of the given network upgrade)
Expand Down Expand Up @@ -120,10 +115,8 @@ fn upgrade() -> Result<()> {
}

fn upgrade_for_network_upgrade(network: Network, network_upgrade: NetworkUpgrade) -> Result<()> {
let (blocks, sapling_roots) = match network {
Network::Mainnet => (&*MAINNET_BLOCKS, &*MAINNET_FINAL_SAPLING_ROOTS),
Network::Testnet => (&*TESTNET_BLOCKS, &*TESTNET_FINAL_SAPLING_ROOTS),
};
let (blocks, sapling_roots) = network.get_block_sapling_roots_map();

let height = network_upgrade.activation_height(network).unwrap().0;

// Load previous block (the block before the activation block of the given network upgrade)
Expand Down
3 changes: 3 additions & 0 deletions zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub mod work;
#[cfg(any(test, feature = "proptest-impl"))]
pub use block::LedgerState;

#[cfg(any(test, feature = "proptest-impl"))]
pub mod test_utils;

/// Error type alias to make working with generic errors easier.
///
/// Note: the 'static lifetime bound means that the *type* cannot have any
Expand Down
9 changes: 2 additions & 7 deletions zebra-chain/src/primitives/zcash_history/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ use crate::{
use crate::primitives::zcash_history::*;
use color_eyre::eyre;
use eyre::Result;
use zebra_test::vectors::{
MAINNET_BLOCKS, MAINNET_FINAL_SAPLING_ROOTS, TESTNET_BLOCKS, TESTNET_FINAL_SAPLING_ROOTS,
};

/// Test the MMR tree using the activation block of a network upgrade
/// and its next block.
Expand All @@ -22,10 +19,8 @@ fn tree() -> Result<()> {
}

fn tree_for_network_upgrade(network: Network, network_upgrade: NetworkUpgrade) -> Result<()> {
let (blocks, sapling_roots) = match network {
Network::Mainnet => (&*MAINNET_BLOCKS, &*MAINNET_FINAL_SAPLING_ROOTS),
Network::Testnet => (&*TESTNET_BLOCKS, &*TESTNET_FINAL_SAPLING_ROOTS),
};
let (blocks, sapling_roots) = network.get_block_sapling_roots_map();

let height = network_upgrade.activation_height(network).unwrap().0;

// Load Block 0 (activation block of the given network upgrade)
Expand Down
9 changes: 2 additions & 7 deletions zebra-chain/src/sapling/tests/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use crate::parameters::NetworkUpgrade;
use crate::sapling::{self, tree::*};
use crate::serialization::ZcashDeserializeInto;
use crate::{parameters::Network, sapling::tests::test_vectors};
use zebra_test::vectors::{
MAINNET_BLOCKS, MAINNET_FINAL_SAPLING_ROOTS, TESTNET_BLOCKS, TESTNET_FINAL_SAPLING_ROOTS,
};

#[test]
fn empty_roots() {
Expand Down Expand Up @@ -60,10 +57,8 @@ fn incremental_roots_with_blocks() -> Result<()> {
}

fn incremental_roots_with_blocks_for_network(network: Network) -> Result<()> {
let (blocks, sapling_roots) = match network {
Network::Mainnet => (&*MAINNET_BLOCKS, &*MAINNET_FINAL_SAPLING_ROOTS),
Network::Testnet => (&*TESTNET_BLOCKS, &*TESTNET_FINAL_SAPLING_ROOTS),
};
let (blocks, sapling_roots) = network.get_block_sapling_roots_map();

let height = NetworkUpgrade::Sapling
.activation_height(network)
.unwrap()
Expand Down
16 changes: 16 additions & 0 deletions zebra-chain/src/serialization/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,20 @@ pub enum SerializationError {
/// rule](https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus).
#[error("transaction balance is non-zero but doesn't have Sapling shielded spends or outputs")]
BadTransactionBalance,

/// Invalid height for BLOCK_MAINNET_******_BYTES
#[error("invalid mainnet height {{0}} requested, only 653_599 and 982_681 are available")]
NotACachedMainNetBlock(u32),

/// Invalid height for BLOCK_TESTNET_******_BYTES
#[error("invalid testnet height {{0}} requested, only 583_999 and 925_483 are available")]
NotACachedTestNetBlock(u32),

/// Invalid sapling root mainnet bytes
#[error("invalid mainnet height {{0}} requested, only 1_046_400 is available")]
NotACachedMainNetSaplingRootBytes(u32),

/// Invalid sapling root testnet bytes
#[error("invalid testnet height {{0}} requested, only 1_116_000 is available")]
NotACachedTestNetSaplingRootBytes(u32),
}
21 changes: 1 addition & 20 deletions zebra-chain/src/sprout/tests/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use color_eyre::eyre;
use eyre::Result;
use hex::FromHex;

use zebra_test::vectors;

use crate::{
block::Block,
parameters::{Network, NetworkUpgrade},
Expand Down Expand Up @@ -88,25 +86,8 @@ fn incremental_roots_with_blocks() -> Result<()> {
}

fn incremental_roots_with_blocks_for_network(network: Network) -> Result<()> {
// The mainnet block height at which the first JoinSplit occurred.
const MAINNET_FIRST_JOINSPLIT_HEIGHT: u32 = 396;

// The testnet block height at which the first JoinSplit occurred.
const TESTNET_FIRST_JOINSPLIT_HEIGHT: u32 = 2259;

// Load the test data.
let (blocks, sprout_roots, next_height) = match network {
Network::Mainnet => (
&*vectors::MAINNET_BLOCKS,
&*vectors::MAINNET_FINAL_SPROUT_ROOTS,
MAINNET_FIRST_JOINSPLIT_HEIGHT,
),
Network::Testnet => (
&*vectors::TESTNET_BLOCKS,
&*vectors::TESTNET_FINAL_SPROUT_ROOTS,
TESTNET_FIRST_JOINSPLIT_HEIGHT,
),
};
let (blocks, sprout_roots, next_height) = network.get_block_sprout_roots_height();

// Load the Genesis height.
let genesis_height = NetworkUpgrade::Genesis
Expand Down
3 changes: 3 additions & 0 deletions zebra-chain/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//!Chain functionality for fetching proptest vectors.
//!
mod vectors;
Loading
Loading