Add a test for async_add and async_fetch_orphan
use crate::{
blocks::Block,
chain_storage::{async_db, BlockchainDatabase, MemoryDatabase, MmrTree},
- test_utils::sample_blockchains::create_blockchain_db_no_cut_through,
+ test_utils::{
+ builders::create_test_block,
+ sample_blockchains::{create_blockchain_db_no_cut_through, generate_new_block},
+ },
transaction::{TransactionOutput, UnblindedOutput},
types::{HashDigest, COMMITMENT_FACTORY},
};
@@ -205,3 +208,18 @@ fn fetch_async_mmr_roots() {
});
});
}
+
+#[test]
+fn async_add_block_fetch_orphan() {
+ let (db, blocks, _) = create_blockchain_db_no_cut_through();
+ let orphan = create_test_block(7, None, vec![]);
+ let block_hash = orphan.hash();
+ test_async(move |rt| {
+ let dbc = db.clone();
+ rt.spawn(async move {
+ async_db::add_block(dbc.clone(), orphan.clone()).await.unwrap();
+ let block = async_db::fetch_orphan(dbc.clone(), block_hash).await.unwrap();
+ assert_eq!(orphan, block);
+ });
+ });
+}
