@@ -36,12 +36,12 @@ func getVirtualNetwork() tn.Network {
36
36
37
37
func TestClose (t * testing.T ) {
38
38
vnet := getVirtualNetwork ()
39
- sesgen := testinstance .NewTestSessionGenerator (vnet )
40
- defer sesgen .Close ()
39
+ ig := testinstance .NewTestInstanceGenerator (vnet )
40
+ defer ig .Close ()
41
41
bgen := blocksutil .NewBlockGenerator ()
42
42
43
43
block := bgen .Next ()
44
- bitswap := sesgen .Next ()
44
+ bitswap := ig .Next ()
45
45
46
46
bitswap .Exchange .Close ()
47
47
bitswap .Exchange .GetBlock (context .Background (), block .Cid ())
@@ -51,14 +51,14 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) { // TODO revisit this
51
51
52
52
rs := mockrouting .NewServer ()
53
53
net := tn .VirtualNetwork (rs , delay .Fixed (kNetworkDelay ))
54
- g := testinstance .NewTestSessionGenerator (net )
55
- defer g .Close ()
54
+ ig := testinstance .NewTestInstanceGenerator (net )
55
+ defer ig .Close ()
56
56
57
57
block := blocks .NewBlock ([]byte ("block" ))
58
58
pinfo := p2ptestutil .RandTestBogusIdentityOrFatal (t )
59
59
rs .Client (pinfo ).Provide (context .Background (), block .Cid (), true ) // but not on network
60
60
61
- solo := g .Next ()
61
+ solo := ig .Next ()
62
62
defer solo .Exchange .Close ()
63
63
64
64
ctx , cancel := context .WithTimeout (context .Background (), time .Nanosecond )
@@ -74,10 +74,10 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
74
74
75
75
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
76
76
block := blocks .NewBlock ([]byte ("block" ))
77
- g := testinstance .NewTestSessionGenerator (net )
78
- defer g .Close ()
77
+ ig := testinstance .NewTestInstanceGenerator (net )
78
+ defer ig .Close ()
79
79
80
- peers := g .Instances (2 )
80
+ peers := ig .Instances (2 )
81
81
hasBlock := peers [0 ]
82
82
defer hasBlock .Exchange .Close ()
83
83
@@ -107,10 +107,10 @@ func TestDoesNotProvideWhenConfiguredNotTo(t *testing.T) {
107
107
108
108
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
109
109
block := blocks .NewBlock ([]byte ("block" ))
110
- g := testinstance .NewTestSessionGenerator (net )
111
- defer g .Close ()
110
+ ig := testinstance .NewTestInstanceGenerator (net )
111
+ defer ig .Close ()
112
112
113
- hasBlock := g .Next ()
113
+ hasBlock := ig .Next ()
114
114
defer hasBlock .Exchange .Close ()
115
115
116
116
if err := hasBlock .Exchange .HasBlock (block ); err != nil {
@@ -120,7 +120,7 @@ func TestDoesNotProvideWhenConfiguredNotTo(t *testing.T) {
120
120
ctx , cancel := context .WithTimeout (context .Background (), time .Second )
121
121
defer cancel ()
122
122
123
- wantsBlock := g .Next ()
123
+ wantsBlock := ig .Next ()
124
124
defer wantsBlock .Exchange .Close ()
125
125
126
126
ns := wantsBlock .Exchange .NewSession (ctx ).(* bssession.Session )
@@ -144,10 +144,10 @@ func TestUnwantedBlockNotAdded(t *testing.T) {
144
144
bsMessage := message .New (true )
145
145
bsMessage .AddBlock (block )
146
146
147
- g := testinstance .NewTestSessionGenerator (net )
148
- defer g .Close ()
147
+ ig := testinstance .NewTestInstanceGenerator (net )
148
+ defer ig .Close ()
149
149
150
- peers := g .Instances (2 )
150
+ peers := ig .Instances (2 )
151
151
hasBlock := peers [0 ]
152
152
defer hasBlock .Exchange .Close ()
153
153
@@ -216,11 +216,11 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
216
216
t .SkipNow ()
217
217
}
218
218
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
219
- sg := testinstance .NewTestSessionGenerator (net )
220
- defer sg .Close ()
219
+ ig := testinstance .NewTestInstanceGenerator (net )
220
+ defer ig .Close ()
221
221
bg := blocksutil .NewBlockGenerator ()
222
222
223
- instances := sg .Instances (numInstances )
223
+ instances := ig .Instances (numInstances )
224
224
blocks := bg .Blocks (numBlocks )
225
225
226
226
t .Log ("Give the blocks to the first instance" )
@@ -279,11 +279,11 @@ func TestSendToWantingPeer(t *testing.T) {
279
279
}
280
280
281
281
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
282
- sg := testinstance .NewTestSessionGenerator (net )
283
- defer sg .Close ()
282
+ ig := testinstance .NewTestInstanceGenerator (net )
283
+ defer ig .Close ()
284
284
bg := blocksutil .NewBlockGenerator ()
285
285
286
- peers := sg .Instances (2 )
286
+ peers := ig .Instances (2 )
287
287
peerA := peers [0 ]
288
288
peerB := peers [1 ]
289
289
@@ -321,9 +321,9 @@ func TestSendToWantingPeer(t *testing.T) {
321
321
322
322
func TestEmptyKey (t * testing.T ) {
323
323
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
324
- sg := testinstance .NewTestSessionGenerator (net )
325
- defer sg .Close ()
326
- bs := sg .Instances (1 )[0 ].Exchange
324
+ ig := testinstance .NewTestInstanceGenerator (net )
325
+ defer ig .Close ()
326
+ bs := ig .Instances (1 )[0 ].Exchange
327
327
328
328
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
329
329
defer cancel ()
@@ -354,13 +354,13 @@ func assertStat(t *testing.T, st *bitswap.Stat, sblks, rblks, sdata, rdata uint6
354
354
355
355
func TestBasicBitswap (t * testing.T ) {
356
356
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
357
- sg := testinstance .NewTestSessionGenerator (net )
358
- defer sg .Close ()
357
+ ig := testinstance .NewTestInstanceGenerator (net )
358
+ defer ig .Close ()
359
359
bg := blocksutil .NewBlockGenerator ()
360
360
361
361
t .Log ("Test a one node trying to get one block from another" )
362
362
363
- instances := sg .Instances (3 )
363
+ instances := ig .Instances (3 )
364
364
blocks := bg .Blocks (1 )
365
365
err := instances [0 ].Exchange .HasBlock (blocks [0 ])
366
366
if err != nil {
@@ -423,13 +423,13 @@ func TestBasicBitswap(t *testing.T) {
423
423
424
424
func TestDoubleGet (t * testing.T ) {
425
425
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
426
- sg := testinstance .NewTestSessionGenerator (net )
427
- defer sg .Close ()
426
+ ig := testinstance .NewTestInstanceGenerator (net )
427
+ defer ig .Close ()
428
428
bg := blocksutil .NewBlockGenerator ()
429
429
430
430
t .Log ("Test a one node trying to get one block from another" )
431
431
432
- instances := sg .Instances (2 )
432
+ instances := ig .Instances (2 )
433
433
blocks := bg .Blocks (1 )
434
434
435
435
// NOTE: A race condition can happen here where these GetBlocks requests go
@@ -491,11 +491,11 @@ func TestDoubleGet(t *testing.T) {
491
491
492
492
func TestWantlistCleanup (t * testing.T ) {
493
493
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
494
- sg := testinstance .NewTestSessionGenerator (net )
495
- defer sg .Close ()
494
+ ig := testinstance .NewTestInstanceGenerator (net )
495
+ defer ig .Close ()
496
496
bg := blocksutil .NewBlockGenerator ()
497
497
498
- instances := sg .Instances (1 )[0 ]
498
+ instances := ig .Instances (1 )[0 ]
499
499
bswap := instances .Exchange
500
500
blocks := bg .Blocks (20 )
501
501
@@ -602,13 +602,13 @@ func newReceipt(sent, recv, exchanged uint64) *decision.Receipt {
602
602
603
603
func TestBitswapLedgerOneWay (t * testing.T ) {
604
604
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
605
- sg := testinstance .NewTestSessionGenerator (net )
606
- defer sg .Close ()
605
+ ig := testinstance .NewTestInstanceGenerator (net )
606
+ defer ig .Close ()
607
607
bg := blocksutil .NewBlockGenerator ()
608
608
609
609
t .Log ("Test ledgers match when one peer sends block to another" )
610
610
611
- instances := sg .Instances (2 )
611
+ instances := ig .Instances (2 )
612
612
blocks := bg .Blocks (1 )
613
613
err := instances [0 ].Exchange .HasBlock (blocks [0 ])
614
614
if err != nil {
@@ -654,13 +654,13 @@ func TestBitswapLedgerOneWay(t *testing.T) {
654
654
655
655
func TestBitswapLedgerTwoWay (t * testing.T ) {
656
656
net := tn .VirtualNetwork (mockrouting .NewServer (), delay .Fixed (kNetworkDelay ))
657
- sg := testinstance .NewTestSessionGenerator (net )
658
- defer sg .Close ()
657
+ ig := testinstance .NewTestInstanceGenerator (net )
658
+ defer ig .Close ()
659
659
bg := blocksutil .NewBlockGenerator ()
660
660
661
661
t .Log ("Test ledgers match when two peers send one block to each other" )
662
662
663
- instances := sg .Instances (2 )
663
+ instances := ig .Instances (2 )
664
664
blocks := bg .Blocks (2 )
665
665
err := instances [0 ].Exchange .HasBlock (blocks [0 ])
666
666
if err != nil {
0 commit comments