Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from dannasessha/compiling_tests
Browse files Browse the repository at this point in the history
WIP: moving to new_transactiondata() in blaze
  • Loading branch information
zancas committed May 31, 2022
2 parents b66b0ca + f2bfe13 commit 5b36450
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
8 changes: 1 addition & 7 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zecwalletlitelib"
version = "0.1.0"
authors = ["Aditya Kulkarni <adityapk@gmail.com>", "Hazel OHearn <gygaxis@zingolabs.org>", "Za Wilcox <zancas@zingolabs.org>"]
authors = ["Aditya Kulkarni <adityapk@gmail.com>", "Hazel OHearn <gygaxis@zingolabs.org>", "Za Wilcox <zancas@zingolabs.org>", "Donna Sessha <sessha@zingolabs.com>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -10,7 +10,6 @@ edition = "2021"
default = ["embed_params"]
embed_params = []


[dependencies]
arr_macro = "0.1.3"
base64 = "0.13.0"
Expand All @@ -36,7 +35,6 @@ ring = "0.16.20"
dirs = "3.0.2"
json = "0.12.4"
webpki-roots = "0.21.0"

lazy_static = "1.4.0"
secp256k1 = "=0.21.3"
ripemd160 = "0.9.1"
Expand All @@ -45,21 +43,17 @@ base58 = "0.1.0"
tiny-bip39 = "0.8.2"
sodiumoxide = "0.2.5"
byteorder = "1"

pairing = "0.22"
ff = "0.12"
jubjub = "0.9.0"
bls12_381 = "0.7"
group = "0.12"

rust-embed = { version = "6.3.0", features = ["debug-embed"] }

zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["transparent-inputs", "test-dependencies"] }
zcash_client_backend = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
zcash_proofs = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["multicore"]}
zcash_encoding = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
zcash_note_encryption = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["pre-zip-212"]}
#tracing = "0.1.16"
tracing-subscriber = { version = "0.3", features = ["tracing-log"] }

[dev-dependencies]
Expand Down
9 changes: 7 additions & 2 deletions lib/src/blaze/fetch_taddr_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod test {
use zcash_primitives::consensus::BlockHeight;

use crate::compact_formats::RawTransaction;
use zcash_primitives::transaction::{Transaction, TransactionData};
use zcash_primitives::transaction::Transaction;

use crate::lightwallet::keys::Keys;
use crate::lightwallet::wallettkey::WalletTKey;
Expand Down Expand Up @@ -203,7 +203,12 @@ mod test {
raw_transaction.height = h;

let mut b = vec![];
TransactionData::new().freeze().unwrap().write(&mut b).unwrap();
use crate::lightclient::testmocks;
testmocks::new_transactiondata()
.freeze()
.unwrap()
.write(&mut b)
.unwrap();
raw_transaction.data = b;

raw_transaction
Expand Down
3 changes: 3 additions & 0 deletions lib/src/lightclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,3 +1633,6 @@ pub mod tests;

#[cfg(test)]
pub(crate) mod test_server;

#[cfg(test)]
pub(crate) mod testmocks;
27 changes: 27 additions & 0 deletions lib/src/lightclient/testmocks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use zcash_primitives::consensus::BranchId;
use zcash_primitives::sapling::redjubjub::Signature;
use zcash_primitives::transaction::components::{sapling, Amount};
use zcash_primitives::transaction::{TransactionData, TxVersion};
pub fn new_transactiondata() -> TransactionData<zcash_primitives::transaction::Authorized> {
let authorization = sapling::Authorized {
binding_sig: Signature::read(&vec![0u8; 64][..]).expect("Signature read error!"),
};
let sapling_bundle = sapling::Bundle {
shielded_spends: vec![],
shielded_outputs: vec![],
value_balance: Amount::zero(),
authorization,
};
let td: TransactionData<zcash_primitives::transaction::Authorized> = TransactionData::from_parts(
TxVersion::Sapling,
BranchId::Sapling,
0,
0u32.into(),
None,
None,
Some(sapling_bundle),
None,
);

td
}
32 changes: 7 additions & 25 deletions lib/src/lightclient/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ use zcash_primitives::consensus::{BlockHeight, BranchId, TestNetwork};
use zcash_primitives::memo::Memo;
use zcash_primitives::merkle_tree::{CommitmentTree, IncrementalWitness};
use zcash_primitives::sapling::note_encryption::sapling_note_encryption;
use zcash_primitives::sapling::{redjubjub::Signature, Node, Note, Rseed, ValueCommitment};
use zcash_primitives::sapling::{Node, Note, Rseed, ValueCommitment};
use zcash_primitives::transaction::components::amount::DEFAULT_FEE;
use zcash_primitives::transaction::components::{sapling, Amount, OutputDescription, GROTH_PROOF_SIZE};
use zcash_primitives::transaction::{Transaction, TransactionData, TxVersion};
use zcash_primitives::transaction::components::{OutputDescription, GROTH_PROOF_SIZE};
use zcash_primitives::transaction::Transaction;
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};

use crate::blaze::fetch_full_transaction::FetchFullTxns;
use crate::blaze::test_utils::{FakeCompactBlockList, FakeTransaction};
use crate::lightclient::testmocks;

use crate::compact_formats::{CompactOutput, CompactTx, Empty};
use crate::lightclient::test_server::{create_test_server, mine_pending_blocks, mine_random_blocks};
Expand Down Expand Up @@ -327,27 +328,8 @@ async fn multiple_incoming_same_transaction() {
let to = extfvk1.default_address().1;

// Create fake note for the account
let td = testmocks::new_transactiondata();
let mut compact_transaction = CompactTx::default();
let authorization = sapling::Authorized {
binding_sig: Signature::read(&vec![0u8; 64][..]).expect("Signature read error!"),
};
let sapling_bundle = sapling::Bundle {
shielded_spends: vec![],
shielded_outputs: vec![],
value_balance: Amount::zero(),
authorization,
};
let mut td: TransactionData<zcash_primitives::transaction::Authorized> = TransactionData::from_parts(
TxVersion::Sapling,
BranchId::Sapling,
0,
0u32.into(),
None,
None,
Some(sapling_bundle),
None,
);

// Add 4 outputs
for i in 0..4 {
let mut rng = OsRng;
Expand All @@ -359,7 +341,7 @@ async fn multiple_incoming_same_transaction() {
rseed: Rseed::BeforeZip212(jubjub::Fr::random(rng)),
};

let mut encryptor = sapling_note_encryption::<_, TestNetwork>(
let encryptor = sapling_note_encryption::<_, TestNetwork>(
None,
note.clone(),
to.clone(),
Expand All @@ -375,7 +357,7 @@ async fn multiple_incoming_same_transaction() {
};

let cmu = note.cmu();
let od = OutputDescription {
let _od = OutputDescription {
cv: cv.commitment().into(),
cmu: note.cmu(),
ephemeral_key: EphemeralKeyBytes::from(encryptor.epk().to_bytes()),
Expand Down

0 comments on commit 5b36450

Please sign in to comment.