@@ -81,6 +81,10 @@ func TestSessionsStoreMigration(t *testing.T) {
8181 // session doesn't.
8282 overrideRemovedAccount (kvSession , sqlSession )
8383
84+ // Finally, we also need to override specific feature's
85+ // config if they are empty.
86+ overrideFeatureConfig (kvSession , sqlSession )
87+
8488 assertEqualSessions (t , kvSession , sqlSession )
8589 }
8690
@@ -200,6 +204,48 @@ func TestSessionsStoreMigration(t *testing.T) {
200204 return getBoltStoreSessions (t , store )
201205 },
202206 },
207+ {
208+ name : "one session with a feature config with empty" ,
209+ populateDB : func (t * testing.T , store * BoltStore ,
210+ _ accounts.Store ) []* Session {
211+
212+ // Set a feature config, which has an empty
213+ // entry for a specific feature.
214+ featureConfig := map [string ][]byte {
215+ "AutoFees" : {},
216+ }
217+
218+ _ , err := store .NewSession (
219+ ctx , "test" , TypeMacaroonAdmin ,
220+ time .Unix (1000 , 0 ), "" ,
221+ WithFeatureConfig (featureConfig ),
222+ )
223+ require .NoError (t , err )
224+
225+ return getBoltStoreSessions (t , store )
226+ },
227+ },
228+ {
229+ name : "one session with a feature config with nil" ,
230+ populateDB : func (t * testing.T , store * BoltStore ,
231+ _ accounts.Store ) []* Session {
232+
233+ // Set a feature config, which has a nil entry
234+ // for a specific feature.
235+ featureConfig := map [string ][]byte {
236+ "AutoFees" : nil ,
237+ }
238+
239+ _ , err := store .NewSession (
240+ ctx , "test" , TypeMacaroonAdmin ,
241+ time .Unix (1000 , 0 ), "" ,
242+ WithFeatureConfig (featureConfig ),
243+ )
244+ require .NoError (t , err )
245+
246+ return getBoltStoreSessions (t , store )
247+ },
248+ },
203249 {
204250 name : "one session with dev server" ,
205251 populateDB : func (t * testing.T , store * BoltStore ,
@@ -801,9 +847,18 @@ func randomPrivacyFlags() PrivacyFlags {
801847func randomFeatureConfig () FeaturesConfig {
802848 featureConfig := make (FeaturesConfig )
803849 for i := range rand .Intn (10 ) {
804- featureName := fmt .Sprintf ("feature%d" , i )
805- featureValue := []byte {byte (rand .Int31 ())}
806- featureConfig [featureName ] = featureValue
850+ var (
851+ featureName = fmt .Sprintf ("feature%d" , i )
852+ configValue []byte
853+ )
854+
855+ // For the vast majority of the features, we set a value for the
856+ // feature's config. But in 1/5 of the cases, we set an empty
857+ // config.
858+ if rand .Intn (5 ) != 0 {
859+ configValue = []byte {byte (rand .Int31 ())}
860+ }
861+ featureConfig [featureName ] = configValue
807862 }
808863
809864 return featureConfig
0 commit comments