1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use snarkos_consensus::ConsensusParameters;
use snarkos_dpc::instantiated::Components;
use snarkos_errors::objects::TransactionError;
use snarkos_models::{algorithms::CRH, dpc::DPCComponents, objects::Transaction, parameters::Parameters};
use snarkos_objects::Network;
use snarkos_parameters::{InnerSNARKVKCRHParameters, InnerSNARKVKParameters};
use snarkos_posw::PoswMarlin;
use snarkos_utilities::{to_bytes, FromBytes, ToBytes};
use once_cell::sync::Lazy;
use std::io::{Read, Result as IoResult, Write};
mod e2e;
pub use e2e::*;
mod fixture;
pub use fixture::*;
pub static TEST_CONSENSUS: Lazy<ConsensusParameters> = Lazy::new(|| {
let inner_snark_verification_key_crh_parameters: <<Components as DPCComponents>::InnerSNARKVerificationKeyCRH as CRH>::Parameters = FromBytes::read(InnerSNARKVKCRHParameters::load_bytes().unwrap().as_slice()).unwrap();
let inner_snark_verification_key_crh: <Components as DPCComponents>::InnerSNARKVerificationKeyCRH =
From::from(inner_snark_verification_key_crh_parameters);
let inner_snark_id = to_bytes![
inner_snark_verification_key_crh
.hash(&InnerSNARKVKParameters::load_bytes().unwrap())
.unwrap()
]
.unwrap();
ConsensusParameters {
max_block_size: 1_000_000usize,
max_nonce: u32::max_value(),
target_block_time: 2i64,
network: Network::Mainnet,
verifier: PoswMarlin::verify_only().unwrap(),
authorized_inner_snark_ids: vec![inner_snark_id],
}
});
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TestTx;
impl Transaction for TestTx {
type Commitment = [u8; 32];
type Digest = [u8; 32];
type EncryptedRecord = [u8; 32];
type InnerSNARKID = [u8; 32];
type LocalDataRoot = [u8; 32];
type Memorandum = [u8; 32];
type ProgramCommitment = [u8; 32];
type SerialNumber = [u8; 32];
type ValueBalance = i64;
fn transaction_id(&self) -> Result<[u8; 32], TransactionError> {
Ok([0u8; 32])
}
fn network_id(&self) -> u8 {
0
}
fn ledger_digest(&self) -> &Self::Digest {
&[0u8; 32]
}
fn inner_snark_id(&self) -> &Self::InnerSNARKID {
&[0u8; 32]
}
fn old_serial_numbers(&self) -> &[Self::SerialNumber] {
&[[0u8; 32]]
}
fn new_commitments(&self) -> &[Self::Commitment] {
&[[0u8; 32]]
}
fn program_commitment(&self) -> &Self::ProgramCommitment {
&[0u8; 32]
}
fn local_data_root(&self) -> &Self::LocalDataRoot {
&[0u8; 32]
}
fn value_balance(&self) -> i64 {
0
}
fn memorandum(&self) -> &Self::Memorandum {
&[0u8; 32]
}
fn encrypted_records(&self) -> &[Self::EncryptedRecord] {
&[[0u8; 32]]
}
fn size(&self) -> usize {
0
}
}
impl ToBytes for TestTx {
#[inline]
fn write<W: Write>(&self, mut _writer: W) -> IoResult<()> {
Ok(())
}
}
impl FromBytes for TestTx {
#[inline]
fn read<R: Read>(mut _reader: R) -> IoResult<Self> {
Ok(Self)
}
}