zcash_client_backend: Add a test for ZIP 317 cross-pool payments.
This commit is contained in:
parent
b3d06ba419
commit
b2597aa952
|
@ -273,13 +273,13 @@ impl sapling::OutputView for SaplingPayment {
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
pub(crate) struct OrchardPayment(NonNegativeAmount);
|
pub(crate) struct OrchardPayment(NonNegativeAmount);
|
||||||
|
|
||||||
// TODO: introduce this method when it is needed for testing.
|
#[cfg(test)]
|
||||||
// #[cfg(test)]
|
#[cfg(feature = "orchard")]
|
||||||
// impl OrchardPayment {
|
impl OrchardPayment {
|
||||||
// pub(crate) fn new(amount: NonNegativeAmount) -> Self {
|
pub(crate) fn new(amount: NonNegativeAmount) -> Self {
|
||||||
// OrchardPayment(amount)
|
OrchardPayment(amount)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
impl orchard_fees::OutputView for OrchardPayment {
|
impl orchard_fees::OutputView for OrchardPayment {
|
||||||
|
|
|
@ -237,6 +237,9 @@ mod tests {
|
||||||
ShieldedProtocol,
|
ShieldedProtocol,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "orchard")]
|
||||||
|
use crate::data_api::wallet::input_selection::OrchardPayment;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn change_without_dust() {
|
fn change_without_dust() {
|
||||||
let change_strategy = SingleOutputChangeStrategy::new(
|
let change_strategy = SingleOutputChangeStrategy::new(
|
||||||
|
@ -280,6 +283,50 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "orchard")]
|
||||||
|
fn cross_pool_change_without_dust() {
|
||||||
|
let change_strategy = SingleOutputChangeStrategy::new(
|
||||||
|
Zip317FeeRule::standard(),
|
||||||
|
None,
|
||||||
|
ShieldedProtocol::Orchard,
|
||||||
|
);
|
||||||
|
|
||||||
|
// spend a single Sapling note that is sufficient to pay the fee
|
||||||
|
let result = change_strategy.compute_balance(
|
||||||
|
&Network::TestNetwork,
|
||||||
|
Network::TestNetwork
|
||||||
|
.activation_height(NetworkUpgrade::Nu5)
|
||||||
|
.unwrap(),
|
||||||
|
&Vec::<TestTransparentInput>::new(),
|
||||||
|
&Vec::<TxOut>::new(),
|
||||||
|
&(
|
||||||
|
sapling::builder::BundleType::DEFAULT,
|
||||||
|
&[TestSaplingInput {
|
||||||
|
note_id: 0,
|
||||||
|
value: NonNegativeAmount::const_from_u64(55000),
|
||||||
|
}][..],
|
||||||
|
&Vec::<Infallible>::new()[..],
|
||||||
|
),
|
||||||
|
#[cfg(feature = "orchard")]
|
||||||
|
&(
|
||||||
|
orchard::builder::BundleType::DEFAULT,
|
||||||
|
&Vec::<Infallible>::new()[..],
|
||||||
|
&[OrchardPayment::new(NonNegativeAmount::const_from_u64(
|
||||||
|
30000,
|
||||||
|
))][..],
|
||||||
|
),
|
||||||
|
&DustOutputPolicy::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_matches!(
|
||||||
|
result,
|
||||||
|
Ok(balance) if
|
||||||
|
balance.proposed_change() == [ChangeValue::orchard(NonNegativeAmount::const_from_u64(5000), None)] &&
|
||||||
|
balance.fee_required() == NonNegativeAmount::const_from_u64(20000)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn change_with_transparent_payments() {
|
fn change_with_transparent_payments() {
|
||||||
let change_strategy = SingleOutputChangeStrategy::new(
|
let change_strategy = SingleOutputChangeStrategy::new(
|
||||||
|
|
Loading…
Reference in New Issue