Skip to content

Commit

Permalink
nonce: Add test for replayed InstErr fee theft
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Jan 10, 2020
1 parent 6fd5f95 commit cc1225a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4962,10 +4962,11 @@ mod tests {
bank.process_transaction(&durable_tx),
Err(TransactionError::BlockhashNotFound)
);
/* Check fee not charged */
/* Check fee not charged and nonce not advanced */
assert_eq!(bank.get_balance(&custodian_pubkey), 4_640_000);
assert_eq!(new_nonce, get_nonce(&bank, &nonce_pubkey).unwrap());

let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap();
let nonce_hash = new_nonce;

/* Kick nonce hash off the blockhash_queue */
for _ in 0..MAX_RECENT_BLOCKHASHES + 1 {
Expand All @@ -4989,8 +4990,16 @@ mod tests {
system_instruction::SystemError::ResultWithNegativeLamports.into()
))
);
/* Check fee charged */
/* Check fee charged and nonce has advanced */
assert_eq!(bank.get_balance(&custodian_pubkey), 4_630_000);
assert_ne!(nonce_hash, get_nonce(&bank, &nonce_pubkey).unwrap());
/* Confirm replaying a TX that failed with InstructionError::* now
* fails with TransactionError::BlockhashNotFound
*/
assert_eq!(
bank.process_transaction(&durable_tx),
Err(TransactionError::BlockhashNotFound),
);
}

#[test]
Expand Down

0 comments on commit cc1225a

Please sign in to comment.