@@ -60,18 +60,39 @@ func TestKVStoreTxs(t *testing.T) {
60
60
61
61
// TestTempAndPermStores tests that the kv stores stored under the `temp` bucket
62
62
// 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.
64
65
func 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 ) {
65
81
ctx := context .Background ()
66
82
tmpDir := t .TempDir ()
67
83
84
+ var featureName string
85
+ if featureSpecificStore {
86
+ featureName = "auto-fees"
87
+ }
88
+
68
89
db , err := NewDB (tmpDir , "test.db" , nil )
69
90
require .NoError (t , err )
70
91
t .Cleanup (func () {
71
92
_ = db .Close ()
72
93
})
73
94
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 )
75
96
76
97
err = store .Update (func (tx KVStoreTx ) error {
77
98
// Set an item in the temp store.
@@ -119,7 +140,7 @@ func TestTempAndPermStores(t *testing.T) {
119
140
_ = db .Close ()
120
141
_ = os .RemoveAll (tmpDir )
121
142
})
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 )
123
144
124
145
// The temp store should no longer have the stored value but the perm
125
146
// store should .
0 commit comments