Add withdraw test vector
@@ -13,8 +13,18 @@ use crate::witness::{
#[test]
#[ignore]
fn test_withdraw() {
+ // Test vector of (initial_balance, transfer_amount, fee_amount).
+ let test_vector = vec![
+ (10, 7, 3), // Basic transfer
+ (0, 0, 0), // Zero transfer
+ (std::u64::MAX, 1, 1), // Small transfer from rich account,
+ (std::u64::MAX, 10000, 1), // Big transfer from rich account (too big values can't be used, since they're not packable),
+ (std::u64::MAX, 1, 10000), // Very big fee
+ ];
+
+ for (initial_balance, transfer_amount, fee_amount) in test_vector {
// Input data.
- let accounts = vec![WitnessTestAccount::new(1, 10)];
+ let accounts = vec![WitnessTestAccount::new(1, initial_balance)];
let account = &accounts[0];
let withdraw_op = WithdrawOp {
tx: account
@@ -22,8 +32,8 @@ fn test_withdraw() {
.sign_withdraw(
0,
"",
- BigDecimal::from(7),
- BigDecimal::from(3),
+ BigDecimal::from(transfer_amount),
+ BigDecimal::from(fee_amount),
&Address::zero(),
None,
true,
@@ -33,7 +43,8 @@ fn test_withdraw() {
};
// Additional data required for performing the operation.
- let input = SigDataInput::from_withdraw_op(&withdraw_op).expect("SigDataInput creation failed");
+ let input =
+ SigDataInput::from_withdraw_op(&withdraw_op).expect("SigDataInput creation failed");
generic_test_scenario::<WithdrawWitness<Bn256>, _>(
&accounts,
@@ -47,3 +58,4 @@ fn test_withdraw() {
},
);
}
+}
