@@ -148,3 +148,88 @@ func TestParseVerifyDealsForActivation(t *testing.T) {
148
148
})
149
149
}
150
150
}
151
+
152
+ func TestActivateDeals (t * testing.T ) {
153
+ eg := setupTest (t , "mainnet" )
154
+
155
+ tests := []struct {
156
+ name string
157
+ txType string
158
+ txFrom string
159
+ txTo string
160
+ metadata string
161
+ height uint64
162
+ }{
163
+
164
+ {
165
+ name : "NV3" ,
166
+ txType : parser .MethodActivateDeals ,
167
+ txFrom : txFrom ,
168
+ txTo : txTo ,
169
+ metadata : `{"MethodNum":"6","Params":{"DealIDs":null,"SectorExpiry":1646434}}` ,
170
+ height : 94000 ,
171
+ },
172
+ {
173
+ name : "NV10" ,
174
+ txType : parser .MethodActivateDeals ,
175
+ txFrom : txFrom ,
176
+ txTo : txTo ,
177
+ metadata : `{"MethodNum":"6","Params":{"DealIDs":[1596649,1596648],"SectorExpiry":1079530}}` ,
178
+ height : 550367 ,
179
+ },
180
+ {
181
+ name : "NV17" ,
182
+ txType : parser .MethodActivateDeals ,
183
+ txFrom : txFrom ,
184
+ txTo : txTo ,
185
+ metadata : `{"MethodNum":"6","Params":{"DealIDs":[17507589],"SectorExpiry":3937912}}` ,
186
+ height : 2383680 ,
187
+ },
188
+ {
189
+ name : "NV22 - null activations" ,
190
+ txType : parser .MethodActivateDeals ,
191
+ txFrom : txFrom ,
192
+ txTo : txTo ,
193
+ metadata : `{"MethodNum":"6","Params":{"Sectors":[{"SectorNumber":5868,"SectorType":8,"SectorExpiry":5388210,"DealIDs":[79175167]}],"ComputeCID":false},"Return":{"ActivationResults":{"SuccessCount":0,"FailCodes":[{"Idx":0,"Code":16}]},"Activations":null}}` ,
194
+ height : 3857557 ,
195
+ },
196
+ {
197
+ name : "NV22" ,
198
+ txType : parser .MethodActivateDeals ,
199
+ txFrom : txFrom ,
200
+ txTo : txTo ,
201
+ 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":3,"FailCodes":null},"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":{}}]}}` ,
202
+ height : 3857557 ,
203
+ },
204
+ {
205
+ name : "NV22 - failed activation" ,
206
+ txType : parser .MethodActivateDeals ,
207
+ txFrom : txFrom ,
208
+ 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":{}}]}}` ,
210
+ height : 3857557 ,
211
+ },
212
+ }
213
+
214
+ for _ , test := range tests {
215
+ t .Run (test .name , func (t * testing.T ) {
216
+ _ , err := eg .GenerateDealsEvents (context .Background (), []* types.Transaction {
217
+ {
218
+ TxBasicBlockData : types.TxBasicBlockData {
219
+ BasicBlockData : types.BasicBlockData {
220
+ Height : test .height ,
221
+ },
222
+ },
223
+ TxCid : txCid ,
224
+ TxType : test .txType ,
225
+ TxFrom : test .txFrom ,
226
+ TxTo : test .txTo ,
227
+ TxMetadata : test .metadata ,
228
+ Status : tools .GetExitCodeStatus (exitcode .Ok ),
229
+ SubcallStatus : tools .GetExitCodeStatus (exitcode .Ok ),
230
+ },
231
+ }, tipsetCid , filTypes .EmptyTSK )
232
+ require .NoError (t , err )
233
+ })
234
+ }
235
+ }
0 commit comments