Skip to content

Commit 72be02e

Browse files
authored
Separate deals idx and activation idx in ActivateDeals (#511)
* fix: use diff. idx for deals and activations * test: add test cases for failed activations * test: fix last deal test case
1 parent 45ea6bf commit 72be02e

2 files changed

Lines changed: 95 additions & 5 deletions

File tree

tools/deals/activations.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,15 @@ func (eg *eventGenerator) parseActivateDeals(tx *types.Transaction, params, ret
267267
}
268268
}
269269

270-
for i := range sectorDeals {
271-
if failedActivations[int64(i)] {
270+
activationIdx := 0
271+
for dealIdx := range sectorDeals {
272+
if failedActivations[int64(dealIdx)] {
272273
continue
273274
}
274-
if err := parseDeals(sectorDeals[i], activations[i]); err != nil {
275+
if err := parseDeals(sectorDeals[dealIdx], activations[activationIdx]); err != nil {
275276
return nil, nil, err
276277
}
278+
activationIdx++
277279
}
278280
return dealActivations, dealSpaceInfo, nil
279281
}

tools/deals/deals_test.go

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,101 @@ func TestActivateDeals(t *testing.T) {
202202
height: 3857557,
203203
},
204204
{
205-
name: "NV22 - failed activation",
205+
name: "NV22 - failed activation ( last deal )",
206206
txType: parser.MethodActivateDeals,
207207
txFrom: txFrom,
208208
txTo: txTo,
209-
metadata: `{"MethodNum":"6","Params":{"Sectors":[{"SectorNumber":37656,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[78950968]},{"SectorNumber":37888,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[78951195]},{"SectorNumber":37549,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[79166044]}],"ComputeCID":false},"Return":{"ActivationResults":{"SuccessCount":2,"FailCodes":[{"Idx":1,"Code":16}]},"Activations":[{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":3061409,"AllocationId":61239862,"Data":{"/":"baga6ea4seaqgvrjfj65lawcocwvrpgq7h53oghvto6akrys6wllhbbckchfgefy"},"Size":34359738368}],"UnsealedCid":{}},{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":3061409,"AllocationId":61240089,"Data":{"/":"baga6ea4seaqbuieim7slc3wu7kms436xpnorao5jxr6tqftnqsysfxcp5dnduia"},"Size":34359738368}],"UnsealedCid":{}},{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":3061409,"AllocationId":61454935,"Data":{"/":"baga6ea4seaqfodzysx243k4s6ieuxzzoawew4ckycynubcd5t67vxctunfjt6pq"},"Size":34359738368}],"UnsealedCid":{}}]}}`,
209+
metadata: `{"MethodNum":"6","Params":{"Sectors":[{"SectorNumber":37656,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[78950968]},{"SectorNumber":37888,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[78951195]},{"SectorNumber":37549,"SectorType":8,"SectorExpiry":4920235,"DealIDs":[79166044]}],"ComputeCID":false},"Return":{"ActivationResults":{"SuccessCount":2,"FailCodes":[{"Idx":2,"Code":16}]},"Activations":[{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":3061409,"AllocationId":61239862,"Data":{"/":"baga6ea4seaqgvrjfj65lawcocwvrpgq7h53oghvto6akrys6wllhbbckchfgefy"},"Size":34359738368}],"UnsealedCid":{}},{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":3061409,"AllocationId":61240089,"Data":{"/":"baga6ea4seaqbuieim7slc3wu7kms436xpnorao5jxr6tqftnqsysfxcp5dnduia"},"Size":34359738368}],"UnsealedCid":{}}]}}`,
210210
height: 3857557,
211211
},
212+
{
213+
name: "NV22 - failed activation ( first deal )",
214+
txType: parser.MethodActivateDeals,
215+
txFrom: txFrom,
216+
txTo: txTo,
217+
metadata: `{"MethodNum":"6","Params":{"Sectors":[{"SectorNumber":5926,"SectorType":8,"SectorExpiry":5388210,"DealIDs":[79173041]},{"SectorNumber":5839,"SectorType":8,"SectorExpiry":5388210,"DealIDs":[79174788]}],"ComputeCID":false},"Return":{"ActivationResults":{"SuccessCount":1,"FailCodes":[{"Idx":0,"Code":16}]},"Activations":[{"NonVerifiedDealSpace":"0","VerifiedInfos":[{"Client":2026357,"AllocationId":61463679,"Data":{"/":"baga6ea4seaqpol3htxs5b2iwsvzqssuuzvld6a3g445gn6axaumw4yzuvkmvgei"},"Size":34359738368}],"UnsealedCid":{}}]}}`,
218+
height: 3857651,
219+
},
220+
{
221+
name: "NV22 - failed activation ( middle deal )",
222+
txType: parser.MethodActivateDeals,
223+
txFrom: txFrom,
224+
txTo: txTo,
225+
metadata: `{
226+
"MethodNum": "6",
227+
"Params": {
228+
"Sectors": [
229+
{
230+
"SectorNumber": 5926,
231+
"SectorType": 8,
232+
"SectorExpiry": 5388210,
233+
"DealIDs": [
234+
79173041
235+
]
236+
},
237+
{
238+
"SectorNumber": 5839,
239+
"SectorType": 8,
240+
"SectorExpiry": 5388210,
241+
"DealIDs": [
242+
79174788
243+
]
244+
},
245+
{
246+
"SectorNumber": 50009,
247+
"SectorType": 8,
248+
"SectorExpiry": 5388210,
249+
"DealIDs": [
250+
791747838
251+
]
252+
}
253+
],
254+
"ComputeCID": false
255+
},
256+
"Return": {
257+
"ActivationResults": {
258+
"SuccessCount": 2,
259+
"FailCodes": [
260+
{
261+
"Idx": 1,
262+
"Code": 16
263+
}
264+
]
265+
},
266+
"Activations": [
267+
{
268+
"NonVerifiedDealSpace": "0",
269+
"VerifiedInfos": [
270+
{
271+
"Client": 2026357,
272+
"AllocationId": 61463679,
273+
"Data": {
274+
"/": "baga6ea4seaqpol3htxs5b2iwsvzqssuuzvld6a3g445gn6axaumw4yzuvkmvgei"
275+
},
276+
"Size": 34359738368
277+
}
278+
],
279+
"UnsealedCid": {}
280+
},
281+
{
282+
"NonVerifiedDealSpace": "0",
283+
"VerifiedInfos": [
284+
{
285+
"Client": 2026357,
286+
"AllocationId": 61463679,
287+
"Data": {
288+
"/": "baga6ea4seaqpol3htxs5b2iwsvzqssuuzvld6a3g445gn6axaumw4yzuvkmvgei"
289+
},
290+
"Size": 34359738368
291+
}
292+
],
293+
"UnsealedCid": {}
294+
}
295+
]
296+
}
297+
}`,
298+
height: 3857651,
299+
},
212300
}
213301

214302
for _, test := range tests {

0 commit comments

Comments
 (0)