diff --git a/zcash_client_sqlite/src/transact.rs b/zcash_client_sqlite/src/transact.rs index 1c8a524e3..c5e64c09d 100644 --- a/zcash_client_sqlite/src/transact.rs +++ b/zcash_client_sqlite/src/transact.rs @@ -505,7 +505,7 @@ mod tests { Ok(_) => panic!("Should have failed"), Err(e) => assert_eq!( e.to_string(), - "Insufficient balance (have 0, need 10001 including fee)" + "Insufficient balance (have 0, need 1001 including fee)" ), } } @@ -571,7 +571,7 @@ mod tests { Ok(_) => panic!("Should have failed"), Err(e) => assert_eq!( e.to_string(), - "Insufficient balance (have 50000, need 80000 including fee)" + "Insufficient balance (have 50000, need 71000 including fee)" ), } @@ -603,7 +603,7 @@ mod tests { Ok(_) => panic!("Should have failed"), Err(e) => assert_eq!( e.to_string(), - "Insufficient balance (have 50000, need 80000 including fee)" + "Insufficient balance (have 50000, need 71000 including fee)" ), } @@ -690,7 +690,7 @@ mod tests { Ok(_) => panic!("Should have failed"), Err(e) => assert_eq!( e.to_string(), - "Insufficient balance (have 0, need 12000 including fee)" + "Insufficient balance (have 0, need 3000 including fee)" ), } @@ -722,7 +722,7 @@ mod tests { Ok(_) => panic!("Should have failed"), Err(e) => assert_eq!( e.to_string(), - "Insufficient balance (have 0, need 12000 including fee)" + "Insufficient balance (have 0, need 3000 including fee)" ), } diff --git a/zcash_extensions/src/transparent/demo.rs b/zcash_extensions/src/transparent/demo.rs index ac991a82d..7dad127dd 100644 --- a/zcash_extensions/src/transparent/demo.rs +++ b/zcash_extensions/src/transparent/demo.rs @@ -475,7 +475,10 @@ mod tests { sapling::Node, transaction::{ builder::Builder, - components::{Amount, OutPoint, TzeIn, TzeOut}, + components::{ + amount::{Amount, DEFAULT_FEE}, + OutPoint, TzeIn, TzeOut, + }, Transaction, TransactionData, }, zip32::ExtendedSpendingKey, @@ -739,7 +742,7 @@ mod tests { extension_id: 0, }; let prevout_a = (OutPoint::new(tx_a.txid().0, 0), tx_a.tze_outputs[0].clone()); - let value_xfr = Amount::from_u64(90000).unwrap(); + let value_xfr = value - DEFAULT_FEE; db_b.demo_transfer_to_close(prevout_a, value_xfr, preimage_1, h2) .map_err(|e| format!("transfer failure: {:?}", e)) .unwrap(); @@ -765,7 +768,7 @@ mod tests { builder_c .add_transparent_output( &TransparentAddress::PublicKey([0; 20]), - Amount::from_u64(80000).unwrap(), + value_xfr - DEFAULT_FEE, ) .unwrap(); diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index 45a2e2e43..853e7b29d 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -870,7 +870,7 @@ mod tests { primitives::Rseed, prover::mock::MockTxProver, sapling::Node, - transaction::components::Amount, + transaction::components::{amount::Amount, amount::DEFAULT_FEE}, zip32::{ExtendedFullViewingKey, ExtendedSpendingKey}, }; @@ -990,7 +990,7 @@ mod tests { let builder = Builder::new(TEST_NETWORK, H0); assert_eq!( builder.build(consensus::BranchId::Sapling, &MockTxProver), - Err(Error::ChangeIsNegative(Amount::from_i64(-10000).unwrap())) + Err(Error::ChangeIsNegative(Amount::zero() - DEFAULT_FEE)) ); } @@ -999,7 +999,7 @@ mod tests { let to = extfvk.default_address().unwrap().1; // Fail if there is only a Sapling output - // 0.0005 z-ZEC out, 0.0001 t-ZEC fee + // 0.0005 z-ZEC out, 0.00001 t-ZEC fee { let mut builder = Builder::new(TEST_NETWORK, H0); builder @@ -1007,12 +1007,14 @@ mod tests { .unwrap(); assert_eq!( builder.build(consensus::BranchId::Sapling, &MockTxProver), - Err(Error::ChangeIsNegative(Amount::from_i64(-60000).unwrap())) + Err(Error::ChangeIsNegative( + Amount::from_i64(-50000).unwrap() - DEFAULT_FEE + )) ); } // Fail if there is only a transparent output - // 0.0005 t-ZEC out, 0.0001 t-ZEC fee + // 0.0005 t-ZEC out, 0.00001 t-ZEC fee { let mut builder = Builder::new(TEST_NETWORK, H0); builder @@ -1023,12 +1025,14 @@ mod tests { .unwrap(); assert_eq!( builder.build(consensus::BranchId::Sapling, &MockTxProver), - Err(Error::ChangeIsNegative(Amount::from_i64(-60000).unwrap())) + Err(Error::ChangeIsNegative( + Amount::from_i64(-50000).unwrap() - DEFAULT_FEE + )) ); } let note1 = to - .create_note(59999, Rseed::BeforeZip212(jubjub::Fr::random(&mut rng))) + .create_note(50999, Rseed::BeforeZip212(jubjub::Fr::random(&mut rng))) .unwrap(); let cmu1 = Node::new(note1.cmu().to_repr()); let mut tree = CommitmentTree::new(); @@ -1036,7 +1040,7 @@ mod tests { let mut witness1 = IncrementalWitness::from_tree(&tree); // Fail if there is insufficient input - // 0.0003 z-ZEC out, 0.0002 t-ZEC out, 0.0001 t-ZEC fee, 0.00059999 z-ZEC in + // 0.0003 z-ZEC out, 0.0002 t-ZEC out, 0.00001 t-ZEC fee, 0.00050999 z-ZEC in { let mut builder = Builder::new(TEST_NETWORK, H0); builder diff --git a/zcash_primitives/src/transaction/components/amount.rs b/zcash_primitives/src/transaction/components/amount.rs index 14f260431..f46c0b820 100644 --- a/zcash_primitives/src/transaction/components/amount.rs +++ b/zcash_primitives/src/transaction/components/amount.rs @@ -4,7 +4,7 @@ use std::ops::{Add, AddAssign, Sub, SubAssign}; pub const COIN: i64 = 1_0000_0000; pub const MAX_MONEY: i64 = 21_000_000 * COIN; -pub const DEFAULT_FEE: Amount = Amount(10000); +pub const DEFAULT_FEE: Amount = Amount(1000); /// A type-safe representation of some quantity of Zcash. ///