diff --git a/src/accountant.rs b/src/accountant.rs index dc73c6278d..9a04f6b9d4 100644 --- a/src/accountant.rs +++ b/src/accountant.rs @@ -202,11 +202,11 @@ mod tests { let alice = Mint::new(10_000); let bob_pubkey = KeyPair::new().pubkey(); let mut acc = Accountant::new(&alice); - acc.transfer(1_000, &alice.keypair(), bob_pubkey, alice.seed()) + acc.transfer(1_000, &alice.keypair(), bob_pubkey, alice.last_id()) .unwrap(); assert_eq!(acc.get_balance(&bob_pubkey).unwrap(), 1_000); - acc.transfer(500, &alice.keypair(), bob_pubkey, alice.seed()) + acc.transfer(500, &alice.keypair(), bob_pubkey, alice.last_id()) .unwrap(); assert_eq!(acc.get_balance(&bob_pubkey).unwrap(), 1_500); } @@ -216,10 +216,10 @@ mod tests { let alice = Mint::new(11_000); let mut acc = Accountant::new(&alice); let bob_pubkey = KeyPair::new().pubkey(); - acc.transfer(1_000, &alice.keypair(), bob_pubkey, alice.seed()) + acc.transfer(1_000, &alice.keypair(), bob_pubkey, alice.last_id()) .unwrap(); assert_eq!( - acc.transfer(10_001, &alice.keypair(), bob_pubkey, alice.seed()), + acc.transfer(10_001, &alice.keypair(), bob_pubkey, alice.last_id()), Err(AccountingError::InsufficientFunds) ); @@ -233,7 +233,7 @@ mod tests { let alice = Mint::new(1); let mut acc = Accountant::new(&alice); let bob_pubkey = KeyPair::new().pubkey(); - let mut tr = Transaction::new(&alice.keypair(), bob_pubkey, 1, alice.seed()); + let mut tr = Transaction::new(&alice.keypair(), bob_pubkey, 1, alice.last_id()); if let Plan::Pay(ref mut payment) = tr.plan { payment.tokens = 2; // <-- attack! } @@ -258,7 +258,7 @@ mod tests { let mut acc = Accountant::new(&alice); let alice_keypair = alice.keypair(); let bob_pubkey = KeyPair::new().pubkey(); - acc.transfer(500, &alice_keypair, bob_pubkey, alice.seed()) + acc.transfer(500, &alice_keypair, bob_pubkey, alice.last_id()) .unwrap(); assert_eq!(acc.get_balance(&bob_pubkey).unwrap(), 500); } @@ -270,7 +270,7 @@ mod tests { 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, alice.seed()) + acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt, alice.last_id()) .unwrap(); // Alice's balance will be zero because all funds are locked up. @@ -299,7 +299,7 @@ mod tests { acc.process_verified_timestamp(alice.pubkey(), dt).unwrap(); // It's now past now, so this transfer should be processed immediately. - acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt, alice.seed()) + acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt, alice.last_id()) .unwrap(); assert_eq!(acc.get_balance(&alice.pubkey()), Some(0)); @@ -313,7 +313,7 @@ mod tests { let alice_keypair = alice.keypair(); let bob_pubkey = KeyPair::new().pubkey(); let dt = Utc::now(); - let sig = acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt, alice.seed()) + let sig = acc.transfer_on_date(1, &alice_keypair, bob_pubkey, dt, alice.last_id()) .unwrap(); // Alice's balance will be zero because all funds are locked up. diff --git a/src/accountant_stub.rs b/src/accountant_stub.rs index cd8b1c87a2..0c7c528087 100644 --- a/src/accountant_stub.rs +++ b/src/accountant_stub.rs @@ -106,10 +106,10 @@ mod tests { let acc = Accountant::new(&alice); let bob_pubkey = KeyPair::new().pubkey(); let exit = Arc::new(AtomicBool::new(false)); - let historian = Historian::new(&alice.seed(), Some(30)); + let historian = Historian::new(&alice.last_id(), Some(30)); let acc = Arc::new(Mutex::new(AccountantSkel::new( acc, - alice.seed(), + alice.last_id(), sink(), historian, ))); diff --git a/src/mint.rs b/src/mint.rs index fb9a1a2a81..5b869c3152 100644 --- a/src/mint.rs +++ b/src/mint.rs @@ -33,6 +33,10 @@ impl Mint { hash(&self.pkcs8) } + pub fn last_id(&self) -> Hash { + self.create_entries()[1].id + } + pub fn keypair(&self) -> KeyPair { KeyPair::from_pkcs8(Input::from(&self.pkcs8)).unwrap() }