File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -742,3 +742,22 @@ fn applying_changesets_one_by_one_vs_aggregate_must_have_same_result() {
742742 indexer_b. last_revealed_indices( )
743743 ) ;
744744}
745+
746+ // When the same descriptor is associated with various keychains,
747+ // index methods only return the highest keychain by Ord
748+ #[ test]
749+ fn test_only_highest_ord_keychain_is_returned ( ) {
750+ let desc = parse_descriptor ( DESCRIPTORS [ 0 ] ) ;
751+
752+ let mut indexer = KeychainTxOutIndex :: < TestKeychain > :: new ( 0 ) ;
753+ let _ = indexer. insert_descriptor ( TestKeychain :: Internal , desc. clone ( ) ) ;
754+ let _ = indexer. insert_descriptor ( TestKeychain :: External , desc) ;
755+
756+ // reveal_next_spk will work with either keychain
757+ let spk0: ScriptBuf = indexer. reveal_next_spk ( & TestKeychain :: External ) . unwrap ( ) . 0 . 1 . into ( ) ;
758+ let spk1: ScriptBuf = indexer. reveal_next_spk ( & TestKeychain :: Internal ) . unwrap ( ) . 0 . 1 . into ( ) ;
759+
760+ // index_of_spk will always return External
761+ assert_eq ! ( indexer. index_of_spk( & spk0) , Some ( ( TestKeychain :: External , 0 ) ) ) ;
762+ assert_eq ! ( indexer. index_of_spk( & spk1) , Some ( ( TestKeychain :: External , 1 ) ) ) ;
763+ }
You can’t perform that action at this time.
0 commit comments