@@ -285,6 +285,8 @@ impl<C: fmt::Debug> std::error::Error for StoreErrorWithDump<C> {}
285285mod test {
286286 use super :: * ;
287287
288+ const DB_MAGIC : & [ u8 ] = & [ 0x21 , 0x24 , 0x48 ] ;
289+
288290 use std:: {
289291 collections:: BTreeSet ,
290292 fs,
@@ -297,6 +299,13 @@ mod test {
297299
298300 type TestChangeSet = BTreeSet < String > ;
299301
302+ use bdk_chain:: { keychain_txout, local_chain, tx_graph, ConfirmationBlockTime } ;
303+ use bdk_testenv:: persist_test_utils:: {
304+ persist_anchors, persist_first_seen, persist_indexer_changeset, persist_last_evicted,
305+ persist_last_revealed, persist_last_seen, persist_local_chain_changeset, persist_spk_cache,
306+ persist_txgraph_changeset, persist_txouts, persist_txs,
307+ } ;
308+
300309 /// Check behavior of [`Store::create`] and [`Store::load`].
301310 #[ test]
302311 fn construct_store ( ) {
@@ -599,4 +608,103 @@ mod test {
599608 // current position matches EOF
600609 assert_eq ! ( current_pointer, expected_pointer) ;
601610 }
611+
612+ #[ test]
613+ fn txgraph_is_persisted ( ) {
614+ persist_txgraph_changeset :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
615+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
616+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
617+ |db, changeset| Ok ( db. append ( changeset) ?) ,
618+ ) ;
619+ }
620+
621+ #[ test]
622+ fn indexer_is_persisted ( ) {
623+ persist_indexer_changeset :: < Store < keychain_txout:: ChangeSet > , _ , _ , _ > (
624+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
625+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
626+ |db, changeset| Ok ( db. append ( changeset) ?) ,
627+ ) ;
628+ }
629+
630+ #[ test]
631+ fn local_chain_is_persisted ( ) {
632+ persist_local_chain_changeset :: < Store < local_chain:: ChangeSet > , _ , _ , _ > (
633+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
634+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
635+ |db, changeset| Ok ( db. append ( changeset) ?) ,
636+ ) ;
637+ }
638+
639+ #[ test]
640+ fn txouts_are_persisted ( ) {
641+ persist_txouts :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
642+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
643+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
644+ |db, changeset| Ok ( db. append ( changeset) ?) ,
645+ ) ;
646+ }
647+
648+ #[ test]
649+ fn txs_are_persisted ( ) {
650+ persist_txs :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
651+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
652+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
653+ |db, changeset| Ok ( db. append ( changeset) ?) ,
654+ ) ;
655+ }
656+
657+ #[ test]
658+ fn anchors_are_persisted ( ) {
659+ persist_anchors :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
660+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
661+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
662+ |db, changeset| Ok ( db. append ( changeset) ?) ,
663+ ) ;
664+ }
665+
666+ #[ test]
667+ fn last_seen_is_persisted ( ) {
668+ persist_last_seen :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
669+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
670+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
671+ |db, changeset| Ok ( db. append ( changeset) ?) ,
672+ ) ;
673+ }
674+
675+ #[ test]
676+ fn last_evicted_is_persisted ( ) {
677+ persist_last_evicted :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
678+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
679+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
680+ |db, changeset| Ok ( db. append ( changeset) ?) ,
681+ ) ;
682+ }
683+
684+ #[ test]
685+ fn first_seen_is_persisted ( ) {
686+ persist_first_seen :: < Store < tx_graph:: ChangeSet < ConfirmationBlockTime > > , _ , _ , _ > (
687+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
688+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
689+ |db, changeset| Ok ( db. append ( changeset) ?) ,
690+ ) ;
691+ }
692+
693+ #[ test]
694+ fn last_revealed_is_persisted ( ) {
695+ persist_last_revealed :: < Store < keychain_txout:: ChangeSet > , _ , _ , _ > (
696+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
697+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
698+ |db, changeset| Ok ( db. append ( changeset) ?) ,
699+ ) ;
700+ }
701+
702+ #[ test]
703+ fn spk_cache_is_persisted ( ) {
704+ persist_spk_cache :: < Store < keychain_txout:: ChangeSet > , _ , _ , _ > (
705+ |path| Ok ( Store :: create ( DB_MAGIC , path) ?) ,
706+ |db| Ok ( db. dump ( ) . map ( Option :: unwrap_or_default) ?) ,
707+ |db, changeset| Ok ( db. append ( changeset) ?) ,
708+ ) ;
709+ }
602710}
0 commit comments