@@ -56,7 +56,7 @@ func TestInitialize(t *testing.T) {
56
56
require .NoError (t , err )
57
57
58
58
{
59
- ctx , cancel := context .WithCancel (context . Background ())
59
+ ctx , cancel := context .WithCancel (t . Context ())
60
60
defer cancel ()
61
61
62
62
var eg errgroup.Group
@@ -105,7 +105,7 @@ func TestInitialize_NotStuck_If_No_Nonce_found(t *testing.T) {
105
105
require .NoError (t , err )
106
106
107
107
{
108
- ctx , cancel := context .WithCancel (context . Background ())
108
+ ctx , cancel := context .WithCancel (t . Context ())
109
109
defer cancel ()
110
110
require .NoError (t , init .Initialize (ctx ))
111
111
}
@@ -132,7 +132,7 @@ func TestInitialize_BeforeNonceValue(t *testing.T) {
132
132
)
133
133
require .NoError (t , err )
134
134
135
- ctx , cancel := context .WithCancel (context . Background ())
135
+ ctx , cancel := context .WithCancel (t . Context ())
136
136
defer cancel ()
137
137
require .NoError (t , init .Initialize (ctx ))
138
138
cancel ()
@@ -189,7 +189,7 @@ func TestInitialize_PowOutOfRange(t *testing.T) {
189
189
)
190
190
r .NoError (err )
191
191
192
- r .NoError (init .Initialize (context . Background ()))
192
+ r .NoError (init .Initialize (t . Context ()))
193
193
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
194
194
195
195
m := & shared.VRFNonceMetadata {
@@ -218,7 +218,7 @@ func TestInitialize_ContinueWithLastPos(t *testing.T) {
218
218
)
219
219
r .NoError (err )
220
220
221
- r .NoError (init .Initialize (context . Background ()))
221
+ r .NoError (init .Initialize (t . Context ()))
222
222
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
223
223
224
224
meta := & shared.VRFNonceMetadata {
@@ -241,7 +241,7 @@ func TestInitialize_ContinueWithLastPos(t *testing.T) {
241
241
)
242
242
r .NoError (err )
243
243
244
- r .NoError (init .Initialize (context . Background ()))
244
+ r .NoError (init .Initialize (t . Context ()))
245
245
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
246
246
247
247
m , err := LoadMetadata (opts .DataDir )
@@ -264,7 +264,7 @@ func TestInitialize_ContinueWithLastPos(t *testing.T) {
264
264
)
265
265
r .NoError (err )
266
266
267
- r .NoError (init .Initialize (context . Background ()))
267
+ r .NoError (init .Initialize (t . Context ()))
268
268
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
269
269
270
270
m , err = LoadMetadata (opts .DataDir )
@@ -288,7 +288,7 @@ func TestInitialize_ContinueWithLastPos(t *testing.T) {
288
288
)
289
289
r .NoError (err )
290
290
291
- r .NoError (init .Initialize (context . Background ()))
291
+ r .NoError (init .Initialize (t . Context ()))
292
292
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
293
293
294
294
m , err = LoadMetadata (opts .DataDir )
@@ -322,7 +322,7 @@ func TestInitialize_ContinueWithLastPos(t *testing.T) {
322
322
)
323
323
r .NoError (err )
324
324
325
- r .NoError (init .Initialize (context . Background ()))
325
+ r .NoError (init .Initialize (t . Context ()))
326
326
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , init .NumLabelsWritten ())
327
327
328
328
m , err = LoadMetadata (opts .DataDir )
@@ -365,7 +365,7 @@ func TestReset_WhileInitializing(t *testing.T) {
365
365
r .ErrorIs (init .Reset (), ErrCannotResetWhileInitializing )
366
366
return nil
367
367
})
368
- eg .Go (func () error { return init .Initialize (context . Background ()) })
368
+ eg .Go (func () error { return init .Initialize (t . Context ()) })
369
369
eg .Wait ()
370
370
371
371
r .NoError (init .Reset ())
@@ -387,7 +387,7 @@ func TestInitialize_Repeated(t *testing.T) {
387
387
r .NoError (err )
388
388
389
389
{
390
- ctx , cancel := context .WithCancel (context . Background ())
390
+ ctx , cancel := context .WithCancel (t . Context ())
391
391
defer cancel ()
392
392
393
393
var eg errgroup.Group
@@ -408,7 +408,7 @@ func TestInitialize_Repeated(t *testing.T) {
408
408
r .NoError (err )
409
409
410
410
{
411
- ctx , cancel := context .WithCancel (context . Background ())
411
+ ctx , cancel := context .WithCancel (t . Context ())
412
412
defer cancel ()
413
413
414
414
var eg errgroup.Group
@@ -436,7 +436,7 @@ func TestInitialize_NumUnits_Increase(t *testing.T) {
436
436
r .NoError (err )
437
437
438
438
{
439
- ctx , cancel := context .WithCancel (context . Background ())
439
+ ctx , cancel := context .WithCancel (t . Context ())
440
440
defer cancel ()
441
441
442
442
var eg errgroup.Group
@@ -458,7 +458,7 @@ func TestInitialize_NumUnits_Increase(t *testing.T) {
458
458
r .NoError (err )
459
459
460
460
{
461
- ctx , cancel := context .WithCancel (context . Background ())
461
+ ctx , cancel := context .WithCancel (t . Context ())
462
462
defer cancel ()
463
463
464
464
var eg errgroup.Group
@@ -485,7 +485,7 @@ func TestInitialize_NumUnits_Decrease(t *testing.T) {
485
485
r .NoError (err )
486
486
487
487
{
488
- ctx , cancel := context .WithCancel (context . Background ())
488
+ ctx , cancel := context .WithCancel (t . Context ())
489
489
defer cancel ()
490
490
491
491
var eg errgroup.Group
@@ -507,7 +507,7 @@ func TestInitialize_NumUnits_Decrease(t *testing.T) {
507
507
r .NoError (err )
508
508
509
509
{
510
- ctx , cancel := context .WithCancel (context . Background ())
510
+ ctx , cancel := context .WithCancel (t . Context ())
511
511
defer cancel ()
512
512
513
513
var eg errgroup.Group
@@ -535,7 +535,7 @@ func TestInitialize_RedundantFiles(t *testing.T) {
535
535
r .NoError (err )
536
536
537
537
{
538
- ctx , cancel := context .WithCancel (context . Background ())
538
+ ctx , cancel := context .WithCancel (t . Context ())
539
539
defer cancel ()
540
540
541
541
var eg errgroup.Group
@@ -558,7 +558,7 @@ func TestInitialize_RedundantFiles(t *testing.T) {
558
558
r .NoError (err )
559
559
560
560
{
561
- ctx , cancel := context .WithCancel (context . Background ())
561
+ ctx , cancel := context .WithCancel (t . Context ())
562
562
defer cancel ()
563
563
564
564
var eg errgroup.Group
@@ -602,7 +602,7 @@ func TestInitialize_MultipleFiles(t *testing.T) {
602
602
WithLogger (zaptest .NewLogger (t , zaptest .Level (zap .DebugLevel ))),
603
603
)
604
604
require .NoError (t , err )
605
- require .NoError (t , init .Initialize (context . Background ()))
605
+ require .NoError (t , init .Initialize (t . Context ()))
606
606
607
607
oneFileData , err = initData (opts .DataDir )
608
608
require .NoError (t , err )
@@ -636,7 +636,7 @@ func TestInitialize_MultipleFiles(t *testing.T) {
636
636
WithLogger (zaptest .NewLogger (t , zaptest .Level (zap .DebugLevel ))),
637
637
)
638
638
require .NoError (t , err )
639
- require .NoError (t , init .Initialize (context . Background ()))
639
+ require .NoError (t , init .Initialize (t . Context ()))
640
640
641
641
multipleFilesData , err := initData (opts .DataDir )
642
642
require .NoError (t , err )
@@ -676,13 +676,13 @@ func TestNumLabelsWritten(t *testing.T) {
676
676
r .Equal (uint64 (0 ), numLabelsWritten )
677
677
678
678
// Initialize.
679
- r .NoError (init .Initialize (context . Background ()))
679
+ r .NoError (init .Initialize (t . Context ()))
680
680
numLabelsWritten , err = init .diskState .NumLabelsWritten ()
681
681
r .NoError (err )
682
682
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , numLabelsWritten )
683
683
684
684
// Initialize repeated.
685
- r .NoError (init .Initialize (context . Background ()))
685
+ r .NoError (init .Initialize (t . Context ()))
686
686
numLabelsWritten , err = init .diskState .NumLabelsWritten ()
687
687
r .NoError (err )
688
688
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , numLabelsWritten )
@@ -699,7 +699,7 @@ func TestNumLabelsWritten(t *testing.T) {
699
699
numLabelsWritten , err = init .diskState .NumLabelsWritten ()
700
700
r .NoError (err )
701
701
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , numLabelsWritten )
702
- r .NoError (init .Initialize (context . Background ()))
702
+ r .NoError (init .Initialize (t . Context ()))
703
703
numLabelsWritten , err = init .diskState .NumLabelsWritten ()
704
704
r .NoError (err )
705
705
r .Equal (uint64 (opts .NumUnits )* cfg .LabelsPerUnit , numLabelsWritten )
@@ -723,7 +723,7 @@ func TestValidateMetadata(t *testing.T) {
723
723
r .NoError (err )
724
724
r .NoError (init .verifyMetadata (m ))
725
725
726
- r .NoError (init .Initialize (context . Background ()))
726
+ r .NoError (init .Initialize (t . Context ()))
727
727
m , err = init .loadMetadata ()
728
728
r .NoError (err )
729
729
r .NoError (init .verifyMetadata (m ))
@@ -802,7 +802,7 @@ func TestStop(t *testing.T) {
802
802
803
803
// Start initialization and stop it after it has written some labels
804
804
{
805
- ctx , cancel := context .WithCancel (context . Background ())
805
+ ctx , cancel := context .WithCancel (t . Context ())
806
806
defer cancel ()
807
807
808
808
var eg errgroup.Group
@@ -819,7 +819,7 @@ func TestStop(t *testing.T) {
819
819
820
820
// Continue the initialization to completion.
821
821
{
822
- ctx , cancel := context .WithCancel (context . Background ())
822
+ ctx , cancel := context .WithCancel (t . Context ())
823
823
defer cancel ()
824
824
825
825
var eg errgroup.Group
@@ -878,7 +878,7 @@ func TestWrongLabelsDetected(t *testing.T) {
878
878
)
879
879
require .NoError (t , err )
880
880
881
- err = init .Initialize (context . Background ())
881
+ err = init .Initialize (t . Context ())
882
882
883
883
var errWrongLabels ErrReferenceLabelMismatch
884
884
require .ErrorAs (t , err , & errWrongLabels )
@@ -908,7 +908,7 @@ func TestMissingProviderErrorsOnInitialize(t *testing.T) {
908
908
)
909
909
require .NoError (t , err ) // no error on missing provider
910
910
911
- err = init .Initialize (context . Background ())
911
+ err = init .Initialize (t . Context ())
912
912
require .ErrorContains (t , err , "no provider specified" )
913
913
}
914
914
@@ -926,7 +926,7 @@ func TestMissingProviderNoErrorWithFinishedInitialization(t *testing.T) {
926
926
)
927
927
require .NoError (t , err )
928
928
929
- err = init .Initialize (context . Background ())
929
+ err = init .Initialize (t . Context ())
930
930
require .NoError (t , err )
931
931
932
932
opts .ProviderID = nil
@@ -939,7 +939,7 @@ func TestMissingProviderNoErrorWithFinishedInitialization(t *testing.T) {
939
939
)
940
940
require .NoError (t , err )
941
941
942
- err = init .Initialize (context . Background ())
942
+ err = init .Initialize (t . Context ())
943
943
require .NoError (t , err ) // no error on missing provider because init is finished already
944
944
}
945
945
@@ -986,7 +986,7 @@ func TestInitializeSubset(t *testing.T) {
986
986
WithLogger (zaptest .NewLogger (t , zaptest .Level (zap .DebugLevel ))),
987
987
)
988
988
require .NoError (t , err )
989
- err = init .Initialize (context . Background ())
989
+ err = init .Initialize (t . Context ())
990
990
require .NoError (t , err )
991
991
992
992
optsSubset := opts
@@ -1003,7 +1003,7 @@ func TestInitializeSubset(t *testing.T) {
1003
1003
WithLogger (zaptest .NewLogger (t , zaptest .Level (zap .DebugLevel ))),
1004
1004
)
1005
1005
require .NoError (t , err )
1006
- require .NoError (t , initSubset .Initialize (context . Background ()))
1006
+ require .NoError (t , initSubset .Initialize (t . Context ()))
1007
1007
1008
1008
// Verify that the subset is a subset of the full set
1009
1009
fullData , err := initData (opts .DataDir )
@@ -1067,7 +1067,7 @@ func TestInitializeSubset_NoNonce(t *testing.T) {
1067
1067
}),
1068
1068
)
1069
1069
require .NoError (t , err )
1070
- require .NoError (t , init .Initialize (context . Background ()))
1070
+ require .NoError (t , init .Initialize (t . Context ()))
1071
1071
1072
1072
// no nonce is found when initializing a subset
1073
1073
require .Nil (t , init .Nonce ())
@@ -1097,7 +1097,7 @@ func TestInitializeSubset_NoNonce(t *testing.T) {
1097
1097
}),
1098
1098
)
1099
1099
require .NoError (t , err )
1100
- require .NoError (t , init .Initialize (context . Background ()))
1100
+ require .NoError (t , init .Initialize (t . Context ()))
1101
1101
1102
1102
require .NotNil (t , init .Nonce ())
1103
1103
require .NotNil (t , init .NonceValue ())
@@ -1126,7 +1126,7 @@ func TestInitializeLastFileIsSmaller(t *testing.T) {
1126
1126
WithLogger (zaptest .NewLogger (t , zaptest .Level (zap .DebugLevel ))),
1127
1127
)
1128
1128
require .NoError (t , err )
1129
- err = init .Initialize (context . Background ())
1129
+ err = init .Initialize (t . Context ())
1130
1130
require .NoError (t , err )
1131
1131
1132
1132
// Verify that the first file contains 2 units
0 commit comments