Ensure the server isn't passed a Plan that spends more than is bonded
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
use hash::Hash;
|
||||
use entry::Entry;
|
||||
use event::Event;
|
||||
use transaction::{Action, Condition, Plan, Transaction};
|
||||
use transaction::{Action, Plan, Transaction};
|
||||
use signature::{KeyPair, PublicKey, Signature};
|
||||
use mint::Mint;
|
||||
use historian::{reserve_signature, Historian};
|
||||
@@ -281,6 +281,21 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_overspend_attack() {
|
||||
let alice = Mint::new(1);
|
||||
let mut acc = Accountant::new(&alice, None);
|
||||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let mut tr = Transaction::new(&alice.keypair(), bob_pubkey, 1, alice.seed());
|
||||
if let Plan::Action(Action::Pay(ref mut payment)) = tr.plan {
|
||||
payment.asset = 2; // <-- Attack!
|
||||
}
|
||||
assert_eq!(
|
||||
acc.process_transaction(tr),
|
||||
Err(AccountingError::InvalidTransfer)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transfer_to_newb() {
|
||||
let alice = Mint::new(10_000);
|
||||
|
Reference in New Issue
Block a user