-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrew Whitehead <[email protected]>
- Loading branch information
1 parent
ed7dce3
commit fdd3140
Showing
4 changed files
with
166 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#[macro_use] | ||
mod utils; | ||
|
||
use indy_vdr::common::merkle_tree::MerkleTree; | ||
use indy_vdr::pool::PoolTransactions; | ||
|
||
use utils::pool::default_transactions; | ||
|
||
mod pool_transactions_tests { | ||
use super::*; | ||
|
||
pub fn _merkle_tree() -> MerkleTree { | ||
PoolTransactions::from_json_transactions(default_transactions()) | ||
.unwrap() | ||
.merkle_tree() | ||
.unwrap() | ||
} | ||
|
||
#[test] | ||
fn test_pool_transactions_from_transactions_json_works() { | ||
let txns = default_transactions(); | ||
|
||
let transactions: PoolTransactions = | ||
PoolTransactions::from_json_transactions(&txns).unwrap(); | ||
|
||
assert_eq!(transactions.encode_json().unwrap(), txns) | ||
} | ||
|
||
// #[test] | ||
// fn test_pool_transactions_from_file_works() { | ||
// let mut transaction = GenesisTransactions::new(None); | ||
// let file = transaction.store_to_file(); | ||
|
||
// let transactions: PoolTransactions = PoolTransactions::from_json_file(file).unwrap(); | ||
|
||
// assert_eq!( | ||
// transactions.encode_json().unwrap(), | ||
// GenesisTransactions::default_transactions() | ||
// ) | ||
// } | ||
|
||
// #[test] | ||
// fn test_pool_transactions_from_file_for_unknown_file() { | ||
// let file = { | ||
// let mut transaction = GenesisTransactions::new(None); | ||
// transaction.store_to_file() | ||
// }; | ||
|
||
// let _err = PoolTransactions::from_json_file(file).unwrap_err(); | ||
// } | ||
|
||
// #[test] | ||
// fn test_pool_transactions_from_file_for_invalid_transactions() { | ||
// let mut txns = GenesisTransactions::from_transactions([r#"{invalid}"#]); | ||
// let _err = PoolTransactions::from_json_file(txns.store_to_file()).unwrap_err(); | ||
// } | ||
|
||
#[test] | ||
fn test_merkle_tree_from_transactions_works() { | ||
let merkle_tree = _merkle_tree(); | ||
|
||
assert_eq!(merkle_tree.count(), 4, "test restored MT size"); | ||
assert_eq!( | ||
merkle_tree.root_hash_hex(), | ||
"ef25b5d33e511d2b8e3fbf267cc4496a77cf522976d5ac158878f787190d9a97", | ||
"test restored MT root hash" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters