Skip to content

Commit 337ea0d

Browse files
authored
fix: enable paralleltest lint check in package postage (#4913)
1 parent 110bb51 commit 337ea0d

File tree

10 files changed

+61
-9
lines changed

10 files changed

+61
-9
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ issues:
7070
- dogsled
7171
path: pkg/pushsync/(.+)_test\.go # temporally disable dogsled in pushsync test files
7272
# temporally disable paralleltest in following packages
73-
- linters:
74-
- paralleltest
75-
path: pkg/postage
7673
- linters:
7774
- paralleltest
7875
path: pkg/log

pkg/postage/batch_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
// TestBatchMarshalling tests the idempotence of binary marshal/unmarshal for a
1616
// Batch.
1717
func TestBatchMarshalling(t *testing.T) {
18+
t.Parallel()
19+
1820
a := postagetesting.MustNewBatch()
1921
buf, err := a.MarshalBinary()
2022
if err != nil {

pkg/postage/batchservice/batchservice_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ func (m *mockBatchListener) HandleDepthIncrease(_ []byte, _ uint8) {
6464

6565
var _ postage.BatchEventListener = (*mockBatchListener)(nil)
6666

67-
func TestBatchServiceCreate_FLAKY(t *testing.T) {
67+
func TestBatchServiceCreate(t *testing.T) {
68+
t.Parallel()
69+
6870
testChainState := postagetesting.NewChainState()
6971

7072
validateNoBatch := func(t *testing.T, testBatch *postage.Batch, st *mock.BatchStore) {
@@ -240,6 +242,8 @@ func TestBatchServiceCreate_FLAKY(t *testing.T) {
240242
}
241243

242244
func TestBatchServiceTopUp(t *testing.T) {
245+
t.Parallel()
246+
243247
testBatch := postagetesting.MustNewBatch()
244248
testNormalisedBalance := big.NewInt(2000000000000)
245249
testTopUpAmount := big.NewInt(1000)
@@ -341,6 +345,8 @@ func TestBatchServiceTopUp(t *testing.T) {
341345
}
342346

343347
func TestBatchServiceUpdateDepth(t *testing.T) {
348+
t.Parallel()
349+
344350
const testNewDepth = 30
345351
testNormalisedBalance := big.NewInt(2000000000000)
346352
testBatch := postagetesting.MustNewBatch()
@@ -443,6 +449,8 @@ func TestBatchServiceUpdateDepth(t *testing.T) {
443449
}
444450

445451
func TestBatchServiceUpdatePrice(t *testing.T) {
452+
t.Parallel()
453+
446454
testChainState := postagetesting.NewChainState()
447455
testChainState.CurrentPrice = big.NewInt(100000)
448456
testNewPrice := big.NewInt(20000000)
@@ -477,6 +485,8 @@ func TestBatchServiceUpdatePrice(t *testing.T) {
477485
})
478486
}
479487
func TestBatchServiceUpdateBlockNumber(t *testing.T) {
488+
t.Parallel()
489+
480490
testChainState := &postage.ChainState{
481491
Block: 1,
482492
CurrentPrice: big.NewInt(100),
@@ -501,6 +511,8 @@ func TestBatchServiceUpdateBlockNumber(t *testing.T) {
501511
}
502512

503513
func TestTransactionOk(t *testing.T) {
514+
t.Parallel()
515+
504516
svc, store, s := newTestStoreAndService(t)
505517
if err := svc.Start(context.Background(), 10, nil); err != nil {
506518
t.Fatal(err)
@@ -528,6 +540,8 @@ func TestTransactionOk(t *testing.T) {
528540
}
529541

530542
func TestTransactionError(t *testing.T) {
543+
t.Parallel()
544+
531545
svc, store, s := newTestStoreAndService(t)
532546
if err := svc.Start(context.Background(), 10, nil); err != nil {
533547
t.Fatal(err)
@@ -551,6 +565,8 @@ func TestTransactionError(t *testing.T) {
551565
}
552566

553567
func TestChecksum(t *testing.T) {
568+
t.Parallel()
569+
554570
s := mocks.NewStateStore()
555571
store := mock.New()
556572
mockHash := &hs{}
@@ -572,6 +588,8 @@ func TestChecksum(t *testing.T) {
572588
}
573589

574590
func TestChecksumResync(t *testing.T) {
591+
t.Parallel()
592+
575593
s := mocks.NewStateStore()
576594
store := mock.New()
577595
mockHash := &hs{}

pkg/postage/batchstore/mock/store_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
)
1515

1616
func TestBatchStore(t *testing.T) {
17+
t.Parallel()
18+
1719
const testCnt = 3
1820

1921
testBatch := postagetesting.MustNewBatch(
@@ -54,6 +56,8 @@ func TestBatchStore(t *testing.T) {
5456
}
5557

5658
func TestBatchStorePutChainState(t *testing.T) {
59+
t.Parallel()
60+
5761
const testCnt = 3
5862

5963
testChainState := postagetesting.NewChainState()
@@ -74,6 +78,8 @@ func TestBatchStorePutChainState(t *testing.T) {
7478
}
7579

7680
func TestBatchStoreWithBatch(t *testing.T) {
81+
t.Parallel()
82+
7783
testBatch := postagetesting.MustNewBatch()
7884
batchStore := mock.New(
7985
mock.WithBatch(testBatch),

pkg/postage/batchstore/store_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var noopEvictFn = func([]byte) error { return nil }
2727
const defaultCapacity = 2 ^ 22
2828

2929
func TestBatchStore_Get(t *testing.T) {
30+
t.Parallel()
3031
testBatch := postagetest.MustNewBatch()
3132

3233
stateStore := mock.NewStateStore()
@@ -42,6 +43,7 @@ func TestBatchStore_Get(t *testing.T) {
4243
}
4344

4445
func TestBatchStore_Iterate(t *testing.T) {
46+
t.Parallel()
4547
testBatch := postagetest.MustNewBatch()
4648
key := batchstore.BatchKey(testBatch.ID)
4749

@@ -63,6 +65,7 @@ func TestBatchStore_Iterate(t *testing.T) {
6365
}
6466

6567
func TestBatchStore_IterateStopsEarly(t *testing.T) {
68+
t.Parallel()
6669
testBatch1 := postagetest.MustNewBatch()
6770
key1 := batchstore.BatchKey(testBatch1.ID)
6871

@@ -113,6 +116,7 @@ func TestBatchStore_IterateStopsEarly(t *testing.T) {
113116
}
114117

115118
func TestBatchStore_SaveAndUpdate(t *testing.T) {
119+
t.Parallel()
116120
testBatch := postagetest.MustNewBatch()
117121
key := batchstore.BatchKey(testBatch.ID)
118122

@@ -157,6 +161,7 @@ func TestBatchStore_SaveAndUpdate(t *testing.T) {
157161
}
158162

159163
func TestBatchStore_GetChainState(t *testing.T) {
164+
t.Parallel()
160165
testChainState := postagetest.NewChainState()
161166

162167
stateStore := mock.NewStateStore()
@@ -171,6 +176,7 @@ func TestBatchStore_GetChainState(t *testing.T) {
171176
}
172177

173178
func TestBatchStore_PutChainState(t *testing.T) {
179+
t.Parallel()
174180
testChainState := postagetest.NewChainState()
175181

176182
stateStore := mock.NewStateStore()
@@ -183,6 +189,7 @@ func TestBatchStore_PutChainState(t *testing.T) {
183189
}
184190

185191
func TestBatchStore_Reset(t *testing.T) {
192+
t.Parallel()
186193
testChainState := postagetest.NewChainState()
187194
testBatch := postagetest.MustNewBatch(
188195
postagetest.WithValue(15),
@@ -236,7 +243,7 @@ type testBatch struct {
236243
// TestBatchSave adds batches to the batchstore, and after each batch, checks
237244
// the reserve state radius.
238245
func TestBatchSave(t *testing.T) {
239-
246+
t.Parallel()
240247
totalCapacity := batchstore.Exp2(5)
241248

242249
defaultDepth := uint8(8)
@@ -310,7 +317,7 @@ func TestBatchSave(t *testing.T) {
310317
// TestBatchUpdate adds an initial group of batches to the batchstore and one by one
311318
// updates their depth and value fields while checking the batchstore radius values.
312319
func TestBatchUpdate(t *testing.T) {
313-
320+
t.Parallel()
314321
totalCapacity := batchstore.Exp2(5)
315322

316323
defaultDepth := uint8(8)
@@ -406,7 +413,7 @@ func TestBatchUpdate(t *testing.T) {
406413
// TestPutChainState add a group of batches to the batchstore, and after updating the chainstate,
407414
// checks the batchstore radius reflects the updates.
408415
func TestPutChainState(t *testing.T) {
409-
416+
t.Parallel()
410417
totalCapacity := batchstore.Exp2(5)
411418

412419
defaultDepth := uint8(8)
@@ -481,6 +488,7 @@ func TestPutChainState(t *testing.T) {
481488
}
482489

483490
func TestBatchExpiry(t *testing.T) {
491+
t.Parallel()
484492
store := setupBatchStore(t, defaultCapacity)
485493

486494
batch := postagetest.MustNewBatch(
@@ -512,6 +520,7 @@ func TestBatchExpiry(t *testing.T) {
512520
}
513521

514522
func TestUnexpiredBatch(t *testing.T) {
523+
t.Parallel()
515524
store := setupBatchStore(t, defaultCapacity)
516525

517526
batch := postagetest.MustNewBatch(
@@ -571,7 +580,6 @@ func setupBatchStore(t *testing.T, capacity int) postage.Storer {
571580
}
572581

573582
func checkState(t *testing.T, name string, store postage.Storer, radius uint8) {
574-
575583
t.Helper()
576584

577585
if radius != store.Radius() {
@@ -580,7 +588,6 @@ func checkState(t *testing.T, name string, store postage.Storer, radius uint8) {
580588
}
581589

582590
func addBatch(t *testing.T, s postage.Storer, depth uint8, value int) *postage.Batch {
583-
584591
t.Helper()
585592

586593
batch := postagetest.MustNewBatch(

pkg/postage/listener/listener_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func toBatchBlock(block uint64) uint64 {
4545
}
4646

4747
func TestListener(t *testing.T) {
48+
t.Parallel()
49+
4850
const (
4951
blockNumber = uint64(500)
5052
timeout = 5 * time.Second
@@ -417,6 +419,8 @@ func TestListener(t *testing.T) {
417419
}
418420

419421
func TestListenerBatchState(t *testing.T) {
422+
t.Parallel()
423+
420424
ev := newEventUpdaterMock()
421425
mf := newMockFilterer()
422426

pkg/postage/service_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
// TestSaveLoad tests the idempotence of saving and loading the postage.Service
2727
// with all the active stamp issuers.
2828
func TestSaveLoad(t *testing.T) {
29+
t.Parallel()
30+
2931
store := inmemstore.New()
3032
defer store.Close()
3133
pstore := pstoremock.New()
@@ -74,6 +76,8 @@ func TestSaveLoad(t *testing.T) {
7476
}
7577

7678
func TestGetStampIssuer(t *testing.T) {
79+
t.Parallel()
80+
7781
store := inmemstore.New()
7882
defer store.Close()
7983
chainID := int64(0)
@@ -208,6 +212,8 @@ func TestGetStampIssuer(t *testing.T) {
208212
}
209213

210214
func TestSetExpired(t *testing.T) {
215+
t.Parallel()
216+
211217
store := inmemstore.New()
212218
testutil.CleanupCloser(t, store)
213219

pkg/postage/stamp_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121

2222
// TestStampMarshalling tests the idempotence of binary marshal/unmarshals for Stamps.
2323
func TestStampMarshalling(t *testing.T) {
24+
t.Parallel()
25+
2426
sExp := postagetesting.MustNewStamp()
2527
buf, _ := sExp.MarshalBinary()
2628
if len(buf) != postage.StampSize {
@@ -35,6 +37,8 @@ func TestStampMarshalling(t *testing.T) {
3537

3638
// TestStampMarshalling tests the idempotence of binary marshal/unmarshals for Stamps.
3739
func TestStampJsonMarshalling(t *testing.T) {
40+
t.Parallel()
41+
3842
sExp := postagetesting.MustNewStamp()
3943

4044
b, err := json.Marshal(sExp)
@@ -70,6 +74,8 @@ func compareStamps(t *testing.T, s1, s2 *postage.Stamp) {
7074

7175
// TestStampIndexMarshalling tests the idempotence of stamp index serialisation.
7276
func TestStampIndexMarshalling(t *testing.T) {
77+
t.Parallel()
78+
7379
var (
7480
expBucket uint32 = 11789
7581
expIndex uint32 = 199999
@@ -85,6 +91,8 @@ func TestStampIndexMarshalling(t *testing.T) {
8591
}
8692

8793
func TestValidStamp(t *testing.T) {
94+
t.Parallel()
95+
8896
privKey, err := crypto.GenerateSecp256k1Key()
8997
if err != nil {
9098
t.Fatal(err)

pkg/postage/stamper_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919

2020
// TestStamperStamping tests if the stamp created by the stamper is valid.
2121
func TestStamperStamping(t *testing.T) {
22+
t.Parallel()
23+
2224
privKey, err := crypto.GenerateSecp256k1Key()
2325
if err != nil {
2426
t.Fatal(err)

pkg/postage/stampissuer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727

2828
// TestStampIssuerMarshalling tests the idempotence of binary marshal/unmarshal.
2929
func TestStampIssuerMarshalling(t *testing.T) {
30+
t.Parallel()
31+
3032
want := newTestStampIssuer(t, 1000)
3133
buf, err := want.MarshalBinary()
3234
if err != nil {

0 commit comments

Comments
 (0)