File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -742,3 +742,38 @@ 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
758+ . reveal_next_spk ( & TestKeychain :: External )
759+ . unwrap ( )
760+ . 0
761+ . 1
762+ . into ( ) ;
763+ let spk1: ScriptBuf = indexer
764+ . reveal_next_spk ( & TestKeychain :: Internal )
765+ . unwrap ( )
766+ . 0
767+ . 1
768+ . into ( ) ;
769+
770+ // index_of_spk will always return External
771+ assert_eq ! (
772+ indexer. index_of_spk( & spk0) ,
773+ Some ( ( TestKeychain :: External , 0 ) )
774+ ) ;
775+ assert_eq ! (
776+ indexer. index_of_spk( & spk1) ,
777+ Some ( ( TestKeychain :: External , 1 ) )
778+ ) ;
779+ }
You can’t perform that action at this time.
0 commit comments