Skip to content

Commit

Permalink
refactor: Add assertion to show coin inserted before processing input
Browse files Browse the repository at this point in the history
  • Loading branch information
netrome committed Jan 31, 2025
1 parent cad3ba0 commit ec0a924
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/fraud_proofs/global_merkle_root/storage/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,27 @@ mod tests {
.process_output(tx_pointer, utxo_id, &inputs, &output)
.unwrap();

let coin_was_inserted_before_process_input = !storage_update_tx
.storage
.storage_as_ref::<Coins>()
.get(&utxo_id)
.unwrap()
.is_none();

storage_update_tx.process_input(&input).unwrap();

storage_tx.commit().unwrap();

// Then
assert!(storage
let coin_doesnt_exist_after_process_input = storage
.read_transaction()
.storage_as_ref::<Coins>()
.get(&utxo_id)
.unwrap()
.is_none());
.is_none();

// Then
assert!(coin_was_inserted_before_process_input);
assert!(coin_doesnt_exist_after_process_input);
}

fn random_utxo_id(rng: &mut impl rand::RngCore) -> UtxoId {
Expand Down

0 comments on commit ec0a924

Please sign in to comment.