@@ -14,20 +14,15 @@ import (
1414// atomic access to the db. If anything fails in the middle of an `Update`
1515// function, then all the changes prior should be rolled back.
1616func TestKVStoreTxs (t * testing.T ) {
17- ctx := context .Background ()
18- tmpDir := t .TempDir ()
19-
20- db , err := NewBoltDB (tmpDir , "test.db" , nil )
21- require .NoError (t , err )
22- t .Cleanup (func () {
23- _ = db .Close ()
24- })
17+ t .Parallel ()
2518
19+ ctx := context .Background ()
20+ db := NewTestDB (t )
2621 store := db .GetKVStores ("AutoFees" , [4 ]byte {1 , 1 , 1 , 1 }, "auto-fees" )
2722
2823 // Test that if an action fails midway through the transaction, then
2924 // it is rolled back.
30- err = store .Update (ctx , func (ctx context.Context , tx KVStoreTx ) error {
25+ err : = store .Update (ctx , func (ctx context.Context , tx KVStoreTx ) error {
3126 err := tx .Global ().Set (ctx , "test" , []byte {1 })
3227 if err != nil {
3328 return err
@@ -63,10 +58,14 @@ func TestKVStoreTxs(t *testing.T) {
6358// KV stores and the session feature level stores.
6459func TestTempAndPermStores (t * testing.T ) {
6560 t .Run ("session level kv store" , func (t * testing.T ) {
61+ t .Parallel ()
62+
6663 testTempAndPermStores (t , false )
6764 })
6865
6966 t .Run ("session feature level kv store" , func (t * testing.T ) {
67+ t .Parallel ()
68+
7069 testTempAndPermStores (t , true )
7170 })
7271}
@@ -78,26 +77,21 @@ func TestTempAndPermStores(t *testing.T) {
7877// session level KV stores.
7978func testTempAndPermStores (t * testing.T , featureSpecificStore bool ) {
8079 ctx := context .Background ()
81- tmpDir := t .TempDir ()
8280
8381 var featureName string
8482 if featureSpecificStore {
8583 featureName = "auto-fees"
8684 }
8785
88- store , err := NewBoltDB (tmpDir , "test.db" , nil )
89- require .NoError (t , err )
90- t .Cleanup (func () {
91- _ = store .Close ()
92- })
86+ store := NewTestDB (t )
9387 db := NewDB (store )
9488 require .NoError (t , db .Start (ctx ))
9589
9690 kvstores := db .GetKVStores (
9791 "test-rule" , [4 ]byte {1 , 1 , 1 , 1 }, featureName ,
9892 )
9993
100- err = kvstores .Update (ctx , func (ctx context.Context ,
94+ err : = kvstores .Update (ctx , func (ctx context.Context ,
10195 tx KVStoreTx ) error {
10296
10397 // Set an item in the temp store.
@@ -164,14 +158,9 @@ func testTempAndPermStores(t *testing.T, featureSpecificStore bool) {
164158
165159// TestKVStoreNameSpaces tests that the various name spaces are used correctly.
166160func TestKVStoreNameSpaces (t * testing.T ) {
161+ t .Parallel ()
167162 ctx := context .Background ()
168- tmpDir := t .TempDir ()
169-
170- db , err := NewBoltDB (tmpDir , "test.db" , nil )
171- require .NoError (t , err )
172- t .Cleanup (func () {
173- _ = db .Close ()
174- })
163+ db := NewTestDB (t )
175164
176165 var (
177166 groupID1 = intToSessionID (1 )
@@ -187,7 +176,7 @@ func TestKVStoreNameSpaces(t *testing.T) {
187176 rulesDB3 := db .GetKVStores ("test-rule" , groupID2 , "re-balance" )
188177
189178 // Test that the three ruleDBs share the same global space.
190- err = rulesDB1 .Update (ctx , func (ctx context.Context ,
179+ err : = rulesDB1 .Update (ctx , func (ctx context.Context ,
191180 tx KVStoreTx ) error {
192181
193182 return tx .Global ().Set (
0 commit comments