@@ -15,6 +15,33 @@ module DataSystem
1515 subject # Force creation of FDv1 instance
1616 expect ( config . data_source_update_sink ) . to be_a ( LaunchDarkly ::Impl ::DataSource ::UpdateSink )
1717 end
18+
19+ it "wraps the feature store with FeatureStoreClientWrapper" do
20+ original_store = config . feature_store
21+ subject # Force creation of FDv1 instance
22+
23+ wrapped_store = config . feature_store
24+ expect ( wrapped_store ) . to be_a ( LaunchDarkly ::Impl ::FeatureStoreClientWrapper )
25+ expect ( wrapped_store . instance_variable_get ( :@store ) ) . to eq ( original_store )
26+ end
27+
28+ it "avoids nested wrappers when config.feature_store is already wrapped" do
29+ # First initialization wraps the store
30+ original_store = config . feature_store
31+ first_fdv1 = FDv1 . new ( sdk_key , config )
32+ first_wrapper = config . feature_store
33+ expect ( first_wrapper ) . to be_a ( LaunchDarkly ::Impl ::FeatureStoreClientWrapper )
34+
35+ # Second initialization (simulating postfork) should unwrap and re-wrap the original
36+ second_fdv1 = FDv1 . new ( sdk_key , config )
37+ second_wrapper = config . feature_store
38+ expect ( second_wrapper ) . to be_a ( LaunchDarkly ::Impl ::FeatureStoreClientWrapper )
39+
40+ # The inner store should be the original, not the first wrapper
41+ inner_store = second_wrapper . instance_variable_get ( :@store )
42+ expect ( inner_store ) . to eq ( original_store )
43+ expect ( inner_store ) . not_to be_a ( LaunchDarkly ::Impl ::FeatureStoreClientWrapper )
44+ end
1845 end
1946
2047 describe "#start" do
0 commit comments