From dd2bd6704945aca98d18be959773fbf109082a7e Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Thu, 8 Mar 2018 08:58:01 -0700 Subject: [PATCH] Add a barebones test for transaction conditions --- src/accountant.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/accountant.rs b/src/accountant.rs index afd4bea103..d496b32075 100644 --- a/src/accountant.rs +++ b/src/accountant.rs @@ -257,4 +257,29 @@ mod tests { ExitReason::RecvDisconnected ); } + + #[test] + fn test_transfer_on_date() { + let alice = Mint::new(1); + let mut acc = Accountant::new(&alice, Some(2)); + let alice_keypair = alice.keypair(); + let bob_pubkey = KeyPair::new().pubkey(); + let dt = Utc::now(); + acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt) + .unwrap(); + + // Alice's balance will be zero because all funds are locked up. + assert_eq!(acc.get_balance(&alice.pubkey()), Some(0)); + + // Bob's balance will be None because the funds have not been + // sent. + assert_eq!(acc.get_balance(&bob_pubkey), None); + + // Now, acknowledge the time in the condition occurred and + // that bob's funds are now available. + acc.process_verified_timestamp(alice.pubkey(), dt).unwrap(); + + // TODO: Uncomment this once process_verified_timestamp is implemented. + //assert_eq!(acc.get_balance(&bob_pubkey), Some(1)); + } }