Add more V6 tests to zebra-chain, refactor OrchardZSA tests in zebra-test#62
Add more V6 tests to zebra-chain, refactor OrchardZSA tests in zebra-test#62
Conversation
… structs and consts declardd there
…ors to zebra-chain
| #[cfg(not(feature = "tx-v6"))] | ||
| panic!("Zebra only uses librustzcash for V5 transactions"); | ||
|
|
||
| #[cfg(feature = "tx-v6")] | ||
| panic!("Zebra only uses librustzcash for V5/V6 transactions"); |
There was a problem hiding this comment.
I don't see the advantage of this over the original no flag option.
Prefer simplicity when it is only about the error msg.
| .expect("V5/V6 txs have branch IDs"), | ||
| ); | ||
|
|
||
| result |
There was a problem hiding this comment.
let's just go with .expect("V5/V6 txs have branch IDs"), for both to avoid the flag compexity.
| fn empty_v6_round_trip() { | ||
| tx_round_trip(&EMPTY_V6_TX) | ||
| } | ||
|
|
There was a problem hiding this comment.
the order should be
fn empty_v4_round_trip() {
..
}
..
fn empty_v5_round_trip() {
..
}
..
fn empty_v6_round_trip() {
..
}
``| } | ||
|
|
||
| // test full blocks | ||
|
|
| } | ||
|
|
||
| #[cfg(feature = "tx-v6")] | ||
| /// Do a round-trip test on v6 transactions created from the block |
There was a problem hiding this comment.
Please mention that this is a serialization round-trip test.
There was a problem hiding this comment.
Done: change it to:
/// Do a serialization round-trip test on v6 transactions ... .
Also added via librustzcast to the comment for v6_librustzcash_round_trip:
/// Do a round-trip test via librustzcash on v6 transactions ...
| let block_bytes2 = block | ||
| .zcash_serialize_to_vec() | ||
| .expect("vec serialization is infallible"); | ||
|
|
||
| assert_eq!( | ||
| block_bytes, &block_bytes2, | ||
| "data must be equal if structs are equal" | ||
| ); |
There was a problem hiding this comment.
let's move it right under
let block = block_bytes
.zcash_deserialize_into::<Block>()
| /// Do a round-trip test on v6 transactions created from the block | ||
| /// test vectors. | ||
| #[test] | ||
| fn v6_librustzcash_round_trip() { |
There was a problem hiding this comment.
I don't see round trip, just a one way trip. Make the trip to be round or adjust the name
There was a problem hiding this comment.
Done: added serialization after deserialization.
It proves that librustzcash can deserialize transactions serialized by zebra, which is important to test:
let _alt_tx: zcash_primitives::transaction::Transaction = tx
.as_ref()
.try_into()
.expect("librustzcash deserialization must work for zebra serialized transactions");
| @@ -0,0 +1,34 @@ | |||
| //! OrchardZSA shielded data (with Actions) test vectors | |||
| //! | |||
| //! Generated by `zebra_chain::primitives::halo2::tests::generate_test_vectors()` | |||
There was a problem hiding this comment.
remove // FIXME: Where is this function called from? in halo2::tests::generate_test_vectors()
Add more V6 tests to zebra-chain, refactor OrchardZSA tests in zebra-test