@@ -60,18 +60,39 @@ func TestKVStoreTxs(t *testing.T) {
6060
6161// TestTempAndPermStores tests that the kv stores stored under the `temp` bucket
6262// are properly deleted and re-initialised upon restart but that anything under
63- // the `perm` bucket is retained.
63+ // the `perm` bucket is retained. We repeat the test for both the session level
64+ // KV stores and the session feature level stores.
6465func TestTempAndPermStores (t * testing.T ) {
66+ t .Run ("session level kv store" , func (t * testing.T ) {
67+ testTempAndPermStores (t , false )
68+ })
69+
70+ t .Run ("session feature level kv store" , func (t * testing.T ) {
71+ testTempAndPermStores (t , true )
72+ })
73+ }
74+
75+ // testTempAndPermStores tests that the kv stores stored under the `temp` bucket
76+ // are properly deleted and re-initialised upon restart but that anything under
77+ // the `perm` bucket is retained. If featureSpecificStore is true, then this
78+ // will test the session feature level KV stores. Otherwise, it will test the
79+ // session level KV stores.
80+ func testTempAndPermStores (t * testing.T , featureSpecificStore bool ) {
6581 ctx := context .Background ()
6682 tmpDir := t .TempDir ()
6783
84+ var featureName string
85+ if featureSpecificStore {
86+ featureName = "auto-fees"
87+ }
88+
6889 db , err := NewDB (tmpDir , "test.db" , nil )
6990 require .NoError (t , err )
7091 t .Cleanup (func () {
7192 _ = db .Close ()
7293 })
7394
74- store := db .GetKVStores ("test-rule" , [4 ]byte {1 , 1 , 1 , 1 }, "auto-fees" )
95+ store := db .GetKVStores ("test-rule" , [4 ]byte {1 , 1 , 1 , 1 }, featureName )
7596
7697 err = store .Update (func (tx KVStoreTx ) error {
7798 // Set an item in the temp store.
@@ -119,7 +140,7 @@ func TestTempAndPermStores(t *testing.T) {
119140 _ = db .Close ()
120141 _ = os .RemoveAll (tmpDir )
121142 })
122- store = db .GetKVStores ("test-rule" , [4 ]byte {1 , 1 , 1 , 1 }, "auto-fees" )
143+ store = db .GetKVStores ("test-rule" , [4 ]byte {1 , 1 , 1 , 1 }, featureName )
123144
124145 // The temp store should no longer have the stored value but the perm
125146 // store should .
0 commit comments