@@ -37,23 +37,39 @@ func TestShareAvailable_OneFullNode(t *testing.T) {
37
37
{
38
38
name : "fully recoverable" ,
39
39
origSquareSize : 16 ,
40
- lightNodes : 24 ,
40
+ lightNodes : 24 , // ~99% chance of recoverability
41
41
sampleAmount : 20 ,
42
42
recoverability : FullyRecoverable ,
43
43
expectedFailure : false ,
44
44
},
45
+ {
46
+ name : "fully recoverable, not enough LNs" ,
47
+ origSquareSize : 16 ,
48
+ lightNodes : 19 , // ~0.7% chance of recoverability
49
+ sampleAmount : 20 ,
50
+ recoverability : FullyRecoverable ,
51
+ expectedFailure : true ,
52
+ },
45
53
{
46
54
name : "barely recoverable" ,
47
55
origSquareSize : 16 ,
48
- lightNodes : 69 ,
56
+ lightNodes : 230 , // 99% chance of recoverability
49
57
sampleAmount : 20 ,
50
58
recoverability : BarelyRecoverable ,
51
59
expectedFailure : false ,
52
60
},
61
+ {
62
+ name : "barely recoverable, not enough LNs" ,
63
+ origSquareSize : 16 ,
64
+ lightNodes : 22 , // ~0.3% chance of recoverability
65
+ sampleAmount : 20 ,
66
+ recoverability : BarelyRecoverable ,
67
+ expectedFailure : true ,
68
+ },
53
69
{
54
70
name : "unrecoverable" ,
55
71
origSquareSize : 16 ,
56
- lightNodes : 69 ,
72
+ lightNodes : 230 ,
57
73
sampleAmount : 20 ,
58
74
recoverability : Unrecoverable ,
59
75
expectedFailure : true ,
@@ -95,12 +111,7 @@ func TestShareAvailable_OneFullNode(t *testing.T) {
95
111
}(i )
96
112
}
97
113
98
- errg , errCtx := errgroup .WithContext (ctx )
99
- errg .Go (func () error {
100
- return full .SharesAvailable (errCtx , root )
101
- })
102
-
103
- err := errg .Wait ()
114
+ err := full .SharesAvailable (ctx , root )
104
115
if tt .expectedFailure {
105
116
require .Error (t , err )
106
117
} else {
@@ -134,20 +145,34 @@ func TestShareAvailable_ConnectedFullNodes(t *testing.T) {
134
145
recoverability : FullyRecoverable ,
135
146
expectedFailure : false ,
136
147
},
148
+ {
149
+ name : "fully recoverable, not enough LNs" ,
150
+ origSquareSize : 16 ,
151
+ lightNodes : 19 , // ~0.7% chance of recoverability
152
+ sampleAmount : 20 ,
153
+ recoverability : FullyRecoverable ,
154
+ expectedFailure : true ,
155
+ },
156
+ // NOTE: This test contains cases for barely recoverable but
157
+ // DisconnectedFullNodes does not. The reasoning for this is that
158
+ // DisconnectedFullNodes has the additional contstraint that the data
159
+ // should not be reconstructable from a single subnetwork, while this
160
+ // test only tests that the data is reconstructable once the subnetworks
161
+ // are connected.
137
162
{
138
163
name : "barely recoverable" ,
139
164
origSquareSize : 16 ,
140
- lightNodes : 69 ,
165
+ lightNodes : 230 , // 99% chance of recoverability
141
166
sampleAmount : 20 ,
142
167
recoverability : BarelyRecoverable ,
143
168
expectedFailure : false ,
144
169
},
145
170
{
146
- name : "unrecoverable " ,
171
+ name : "barely recoverable, not enough LNs " ,
147
172
origSquareSize : 16 ,
148
- lightNodes : 69 ,
173
+ lightNodes : 22 , // ~0.3% chance of recoverability
149
174
sampleAmount : 20 ,
150
- recoverability : Unrecoverable ,
175
+ recoverability : BarelyRecoverable ,
151
176
expectedFailure : true ,
152
177
},
153
178
}
@@ -159,7 +184,7 @@ func TestShareAvailable_ConnectedFullNodes(t *testing.T) {
159
184
origSquareSize := tt .origSquareSize // k
160
185
lightNodes := tt .lightNodes // c
161
186
162
- ctx , cancel := context .WithTimeout (context .Background (), time .Second * 30 )
187
+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 60 )
163
188
defer cancel ()
164
189
165
190
net := availability_test .NewTestDAGNet (ctx , t )
@@ -266,23 +291,23 @@ func TestShareAvailable_DisconnectedFullNodes(t *testing.T) {
266
291
{
267
292
name : "fully recoverable" ,
268
293
origSquareSize : 16 ,
269
- lightNodes : 32 ,
294
+ lightNodes : 24 , // ~99% chance of recoverability
270
295
sampleAmount : 20 ,
271
296
recoverability : FullyRecoverable ,
272
297
expectedFailure : false ,
273
298
},
274
299
{
275
- name : "barely recoverable" ,
300
+ name : "fully recoverable, not enough LNs " ,
276
301
origSquareSize : 16 ,
277
- lightNodes : 70 , // actually 69, but needs to be divisible by 2
302
+ lightNodes : 19 , // ~0.7% chance of recoverability
278
303
sampleAmount : 20 ,
279
- recoverability : BarelyRecoverable ,
280
- expectedFailure : false ,
304
+ recoverability : FullyRecoverable ,
305
+ expectedFailure : true ,
281
306
},
282
307
{
283
308
name : "unrecoverable" ,
284
309
origSquareSize : 16 ,
285
- lightNodes : 70 ,
310
+ lightNodes : 230 ,
286
311
sampleAmount : 20 ,
287
312
recoverability : Unrecoverable ,
288
313
expectedFailure : true ,
@@ -368,7 +393,9 @@ func TestShareAvailable_DisconnectedFullNodes(t *testing.T) {
368
393
// but after they connect
369
394
net .Connect (full1 .ID (), full2 .ID ())
370
395
371
- // with clean caches from the previous try
396
+ // we clear the blockservices not because we need to, but just to
397
+ // show its possible to reconstruct without any previously saved
398
+ // data from previous attempts.
372
399
full1 .ClearStorage ()
373
400
full2 .ClearStorage ()
374
401
0 commit comments