Extensively test transactions

This commit is contained in:
Luke Parker
2023-04-12 08:51:40 -04:00
parent 402a7be966
commit 354ac856a5
7 changed files with 286 additions and 28 deletions

View File

@@ -0,0 +1,18 @@
use std::collections::{HashSet, HashMap};
use rand_core::OsRng;
use crate::{Transaction, verify_transaction, tests::random_provided_transaction};
#[test]
fn provided_transaction() {
let tx = random_provided_transaction(&mut OsRng);
// Make sure this works when provided
let mut provided = HashSet::from([tx.hash()]);
verify_transaction(&tx, [0x88; 32], &mut provided, &mut HashMap::new()).unwrap();
assert_eq!(provided.len(), 0);
// Make sure this fails when not provided
assert!(verify_transaction(&tx, [0x88; 32], &mut HashSet::new(), &mut HashMap::new()).is_err());
}