@@ -7,48 +7,79 @@ use lazy_static::lazy_static;
77
88/// Represents a serialized block and its validity status.
99pub struct OrchardWorkflowBlock {
10+ /// Block height.
11+ pub height : u32 ,
1012 /// Serialized byte data of the block.
11- pub bytes : Vec < u8 > ,
13+ pub bytes : & ' static [ u8 ] ,
1214 /// Indicates whether the block is valid.
1315 pub is_valid : bool ,
1416}
1517
1618fn decode_bytes ( hex : & str ) -> Vec < u8 > {
17- <Vec < u8 > >:: from_hex ( ( hex) . trim ( ) ) . expect ( "Block bytes are in valid hex representation" )
19+ <Vec < u8 > >:: from_hex ( hex. trim ( ) ) . expect ( "Block bytes are in valid hex representation" )
1820}
1921
2022lazy_static ! {
23+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_0_BYTES : Vec <u8 > =
24+ decode_bytes( include_str!( "orchard-zsa-workflow-block-0-genesis.txt" ) ) ;
25+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_1_BYTES : Vec <u8 > =
26+ decode_bytes( include_str!( "orchard-zsa-workflow-block-1.txt" ) ) ;
27+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_2_BYTES : Vec <u8 > =
28+ decode_bytes( include_str!( "orchard-zsa-workflow-block-2.txt" ) ) ;
29+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_3_BYTES : Vec <u8 > =
30+ decode_bytes( include_str!( "orchard-zsa-workflow-block-3.txt" ) ) ;
31+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_4_BYTES : Vec <u8 > =
32+ decode_bytes( include_str!( "orchard-zsa-workflow-block-4.txt" ) ) ;
33+ pub static ref ORCHARD_ZSA_WORKFLOW_BLOCK_5_BYTES : Vec <u8 > =
34+ decode_bytes( include_str!( "orchard-zsa-workflow-block-5.txt" ) ) ;
35+
2136 /// Test blocks for a Zcash Shielded Assets (ZSA) workflow.
22- /// The sequence demonstrates issuing, transferring and burning a custom
23- /// asset, then finalising the issuance and attempting an extra issue.
37+ /// The sequence demonstrates issuing, transferring, and burning a custom
38+ /// asset, then finalizing the issuance and attempting an extra issue.
39+ ///
40+ /// Block 0 is the Regtest genesis block, copied from
41+ /// `zebra-chain/src/block/genesis/block-regtest-0-000-000.txt`.
42+ /// The remaining workflow blocks were generated using `zcash_tx_tool`
2443 pub static ref ORCHARD_ZSA_WORKFLOW_BLOCKS : Vec <OrchardWorkflowBlock > = vec![
44+ // Genesis
45+ OrchardWorkflowBlock {
46+ height: 0 ,
47+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_0_BYTES . as_slice( ) ,
48+ is_valid: true
49+ } ,
50+
2551 // Issue: 1000
2652 OrchardWorkflowBlock {
27- bytes: decode_bytes( include_str!( "orchard-zsa-workflow-block-1.txt" ) ) ,
53+ height: 1 ,
54+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_1_BYTES . as_slice( ) ,
2855 is_valid: true
2956 } ,
3057
3158 // Transfer
3259 OrchardWorkflowBlock {
33- bytes: decode_bytes( include_str!( "orchard-zsa-workflow-block-2.txt" ) ) ,
60+ height: 2 ,
61+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_2_BYTES . as_slice( ) ,
3462 is_valid: true
3563 } ,
3664
3765 // Burn: 7, Burn: 2
3866 OrchardWorkflowBlock {
39- bytes: decode_bytes( include_str!( "orchard-zsa-workflow-block-3.txt" ) ) ,
67+ height: 3 ,
68+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_3_BYTES . as_slice( ) ,
4069 is_valid: true
4170 } ,
4271
4372 // Issue: finalize
4473 OrchardWorkflowBlock {
45- bytes: decode_bytes( include_str!( "orchard-zsa-workflow-block-4.txt" ) ) ,
74+ height: 4 ,
75+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_4_BYTES . as_slice( ) ,
4676 is_valid: true
4777 } ,
4878
4979 // Try to issue: 2000
5080 OrchardWorkflowBlock {
51- bytes: decode_bytes( include_str!( "orchard-zsa-workflow-block-5.txt" ) ) ,
81+ height: 5 ,
82+ bytes: ORCHARD_ZSA_WORKFLOW_BLOCK_5_BYTES . as_slice( ) ,
5283 is_valid: false
5384 } ,
5485 ] ;
0 commit comments