Don't let users accidentally burn their funds either

This commit is contained in:
Greg Fitzgerald
2018-03-11 12:04:44 -06:00
parent aa0a184ebe
commit 45765b625a
2 changed files with 21 additions and 17 deletions

View File

@@ -288,10 +288,19 @@ mod tests {
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!
payment.asset = 2; // <-- attack!
}
assert_eq!(
acc.process_transaction(tr),
acc.process_transaction(tr.clone()),
Err(AccountingError::InvalidTransfer)
);
// Also, ensure all branchs of the plan spend all assets
if let Plan::Action(Action::Pay(ref mut payment)) = tr.plan {
payment.asset = 0; // <-- whoops!
}
assert_eq!(
acc.process_transaction(tr.clone()),
Err(AccountingError::InvalidTransfer)
);
}