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")]
|
||||
pub(crate) struct OrchardPayment(NonNegativeAmount);
|
||||
|
||||
// TODO: introduce this method when it is needed for testing.
|
||||
// #[cfg(test)]
|
||||
// impl OrchardPayment {
|
||||
// pub(crate) fn new(amount: NonNegativeAmount) -> Self {
|
||||
// OrchardPayment(amount)
|
||||
// }
|
||||
// }
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "orchard")]
|
||||
impl OrchardPayment {
|
||||
pub(crate) fn new(amount: NonNegativeAmount) -> Self {
|
||||
OrchardPayment(amount)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "orchard")]
|
||||
impl orchard_fees::OutputView for OrchardPayment {
|
||||
|
|
|
@ -237,6 +237,9 @@ mod tests {
|
|||
ShieldedProtocol,
|
||||
};
|
||||
|
||||
#[cfg(feature = "orchard")]
|
||||
use crate::data_api::wallet::input_selection::OrchardPayment;
|
||||
|
||||
#[test]
|
||||
fn change_without_dust() {
|
||||
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]
|
||||
fn change_with_transparent_payments() {
|
||||
let change_strategy = SingleOutputChangeStrategy::new(
|
||||
|
|
Loading…
Reference in New Issue