-
Notifications
You must be signed in to change notification settings - Fork 104
/
manta_test.go
768 lines (725 loc) · 26.6 KB
/
manta_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
package manta
import (
"os"
"testing"
"github.com/dotabuff/manta/dota"
"github.com/stretchr/testify/assert"
)
func BenchmarkMatch2159568145(b *testing.B) { testScenarios[2159568145].bench(b) }
// Test client
func TestMatchNew7116386145(t *testing.T) { testScenarios[7116386145].test(t) }
func TestMatchNew7047839963(t *testing.T) { testScenarios[7047839963].test(t) }
func TestMatchNew6841449576(t *testing.T) { testScenarios[6841449576].test(t) }
func TestMatchNew6841524459(t *testing.T) { testScenarios[6841524459].test(t) }
func TestMatchNew6792460214(t *testing.T) { testScenarios[6792460214].test(t) }
func TestMatchNew6492864631(t *testing.T) { testScenarios[6492864631].test(t) }
func TestMatchNew6320800962(t *testing.T) { testScenarios[6320800962].test(t) }
func TestMatchNew5747195393(t *testing.T) { testScenarios[5747195393].test(t) }
func TestMatchNew5746628011(t *testing.T) { testScenarios[5746628011].test(t) }
func TestMatchNew5746427505(t *testing.T) { testScenarios[5746427505].test(t) }
func TestMatch5129306977(t *testing.T) { testScenarios[5129306977].test(t) }
func TestMatch5129281647(t *testing.T) { testScenarios[5129281647].test(t) }
func TestMatch4259518439(t *testing.T) { testScenarios[4259518439].test(t) }
func TestMatch4257655794(t *testing.T) { testScenarios[4257655794].test(t) }
func TestMatch3949386909(t *testing.T) { testScenarios[3949386909].test(t) }
func TestMatch3777736409(t *testing.T) { testScenarios[3777736409].test(t) }
func TestMatch3534483793(t *testing.T) { testScenarios[3534483793].test(t) }
func TestMatch3220517753(t *testing.T) { testScenarios[3220517753].test(t) }
func TestMatch2369359192(t *testing.T) { testScenarios[2369359192].test(t) }
func TestMatch2246960647(t *testing.T) { testScenarios[2246960647].test(t) }
func TestMatch2159568145(t *testing.T) { testScenarios[2159568145].test(t) }
func TestMatch2109130988(t *testing.T) { testScenarios[2109130988].test(t) }
func TestMatch1855408730(t *testing.T) { testScenarios[1855408730].test(t) }
func TestMatch1855345768(t *testing.T) { testScenarios[1855345768].test(t) }
func TestMatch1855304265(t *testing.T) { testScenarios[1855304265].test(t) }
func TestMatch1788648401(t *testing.T) { testScenarios[1788648401].test(t) }
func TestMatch1786687320(t *testing.T) { testScenarios[1786687320].test(t) }
func TestMatch1785937100(t *testing.T) { testScenarios[1785937100].test(t) }
func TestMatch1785899023(t *testing.T) { testScenarios[1785899023].test(t) }
func TestMatch1785874713(t *testing.T) { testScenarios[1785874713].test(t) }
func TestMatch1781640270(t *testing.T) { testScenarios[1781640270].test(t) }
func TestMatch1764592109(t *testing.T) { testScenarios[1764592109].test(t) }
func TestMatch1763193771(t *testing.T) { testScenarios[1763193771].test(t) }
func TestMatch1763177231(t *testing.T) { testScenarios[1763177231].test(t) }
func TestMatch1734886116(t *testing.T) { testScenarios[1734886116].test(t) }
func TestMatch1731962898(t *testing.T) { testScenarios[1731962898].test(t) }
func TestMatch1716444111(t *testing.T) { testScenarios[1716444111].test(t) }
func TestMatch1712853372(t *testing.T) { testScenarios[1712853372].test(t) }
func TestMatch1648457986(t *testing.T) { testScenarios[1648457986].test(t) }
func TestMatch1605340040(t *testing.T) { testScenarios[1605340040].test(t) }
func TestMatch1582611189(t *testing.T) { testScenarios[1582611189].test(t) }
func TestMatch1560315800(t *testing.T) { testScenarios[1560315800].test(t) }
func TestMatch1560294294(t *testing.T) { testScenarios[1560294294].test(t) }
func TestMatch1560289528(t *testing.T) { testScenarios[1560289528].test(t) }
func TestMatch6682694(t *testing.T) { testScenarios[6682694].test(t) }
type testScenario struct {
matchId string
replayUrl string
debugLevel uint
debugTick uint32
skipPacketEntities bool
expectGameBuild uint32
expectEntityEvents int32
expectCombatLogDamage int32
expectCombatLogHealing int32
expectCombatLogDeaths int32
expectCombatLogEvents int32
expectUnitOrderEvents int32
expectPlayer6Name string
expectPlayer6Steamid uint64
expectHeroEntityName string
expectHeroEntityMana float32
expectHeroEntityPlayerId int32
skipInCI bool
}
var testScenarios = map[int64]testScenario{
7116386145: {
matchId: "7116386145",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/7116386145.dem",
expectGameBuild: 5682,
expectEntityEvents: 2806164,
expectUnitOrderEvents: 58902,
},
7047839963: {
matchId: "7047839963",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/7047839963.dem",
expectGameBuild: 5630,
expectEntityEvents: 2051476,
expectUnitOrderEvents: 56231,
expectHeroEntityName: "CDOTA_Unit_Hero_Pudge",
expectHeroEntityMana: 1281.9387,
},
6841449576: {
matchId: "6841449576",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6841449576.dem",
expectGameBuild: 5520,
expectEntityEvents: 1614296,
expectUnitOrderEvents: 45320,
},
6841524459: {
matchId: "6841524459",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6841524459.dem",
expectGameBuild: 5520,
expectEntityEvents: 3009702,
expectUnitOrderEvents: 70702,
},
6792460214: {
matchId: "6792460214",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6792460214.dem",
expectGameBuild: 5469,
expectEntityEvents: 1703858,
expectUnitOrderEvents: 58720,
},
6492864631: {
matchId: "6492864631",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6492864631.dem",
expectGameBuild: 5227,
expectEntityEvents: 1310514,
expectUnitOrderEvents: 51555,
},
6320800962: {
matchId: "6320800962",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6320800962.dem",
expectGameBuild: 5118,
expectEntityEvents: 1593488,
expectUnitOrderEvents: 39818,
},
5747195393: {
matchId: "5747195393",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/5747195393.dem",
expectGameBuild: 4581,
expectEntityEvents: 3077503,
expectUnitOrderEvents: 70122,
},
5746628011: {
matchId: "5746628011",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/5746628011.dem",
expectGameBuild: 4577,
expectEntityEvents: 5598752,
expectUnitOrderEvents: 105684,
},
5746427505: {
matchId: "5746427505",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/5746427505.dem",
expectGameBuild: 4570,
expectEntityEvents: 2739947,
expectUnitOrderEvents: 55779,
expectHeroEntityName: "CDOTA_Unit_Hero_Techies",
expectHeroEntityMana: 1827.9392,
expectHeroEntityPlayerId: 0,
},
5129306977: {
matchId: "5129306977",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/5129306977.dem",
expectGameBuild: 3846,
expectEntityEvents: 2466090,
expectUnitOrderEvents: 36185,
expectHeroEntityName: "CDOTA_Unit_Hero_Warlock",
expectHeroEntityMana: 2582.94,
expectHeroEntityPlayerId: 8,
},
5129281647: {
matchId: "5129281647",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/5129281647.dem",
expectGameBuild: 3846,
expectEntityEvents: 2919107,
expectUnitOrderEvents: 43538,
expectHeroEntityName: "CDOTA_Unit_Hero_Pudge",
expectHeroEntityMana: 1647.9391,
expectHeroEntityPlayerId: 8,
},
4259518439: {
matchId: "4259518439",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/4259518439.dem",
expectGameBuild: 3267,
expectEntityEvents: 2709121,
expectUnitOrderEvents: 86120,
expectHeroEntityName: "CDOTA_Unit_Hero_Medusa",
expectHeroEntityMana: 1764.9392,
expectHeroEntityPlayerId: 1,
},
4257655794: {
matchId: "4257655794",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/4257655794.dem",
expectGameBuild: 3262,
expectEntityEvents: 2319568,
expectUnitOrderEvents: 78510,
expectHeroEntityName: "CDOTA_Unit_Hero_Dazzle",
expectHeroEntityMana: 1734.9392,
expectHeroEntityPlayerId: 6,
},
3949386909: {
matchId: "3949386909",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/3949386909.dem",
expectGameBuild: 2956,
expectEntityEvents: 3339557,
expectUnitOrderEvents: 77975,
expectHeroEntityName: "CDOTA_Unit_Hero_Bloodseeker",
expectHeroEntityMana: 1101.9386,
expectHeroEntityPlayerId: 9,
},
3777736409: {
matchId: "3777736409",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/3777736409.dem",
expectGameBuild: 2735,
expectEntityEvents: 2263283,
expectUnitOrderEvents: 58814,
expectHeroEntityName: "CDOTA_Unit_Hero_Lion",
expectHeroEntityMana: 1106.9386,
expectHeroEntityPlayerId: 6,
},
3534483793: {
matchId: "3534483793",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/3534483793.dem",
expectGameBuild: 2463,
expectEntityEvents: 2170677,
expectUnitOrderEvents: 44582,
expectHeroEntityName: "CDOTA_Unit_Hero_Rattletrap",
expectHeroEntityMana: 1293.9387,
expectHeroEntityPlayerId: 8,
},
6682694: {
matchId: "6682694",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/6682694.dem",
expectGameBuild: 1083,
expectEntityEvents: 3586579,
expectUnitOrderEvents: 67817,
},
3220517753: {
matchId: "3220517753",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/3220517753.dem",
expectGameBuild: 2163,
expectEntityEvents: 4624363,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 108879,
},
2369359192: {
matchId: "2369359192",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/2369359192.dem",
expectGameBuild: 1449,
expectEntityEvents: 2434738,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 64186,
},
2246960647: {
matchId: "2246960647",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/2246960647.dem",
expectGameBuild: 1339,
expectEntityEvents: 4455033,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 42687,
},
2159568145: {
matchId: "2159568145",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/2159568145.dem",
expectGameBuild: 1295,
expectEntityEvents: 1831423,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 27202,
},
2109130988: {
matchId: "2109130988",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/2109130988.dem",
expectGameBuild: 1253,
expectEntityEvents: 1072803,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 40297,
},
1855408730: {
matchId: "1855408730",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1855408730.dem",
expectGameBuild: 1106,
expectEntityEvents: 1397062,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 34862,
},
1855345768: {
matchId: "1855345768",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1855345768.dem",
expectGameBuild: 1104,
expectEntityEvents: 1567910,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 41874,
skipInCI: true,
},
1855304265: {
matchId: "1855304265",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1855304265.dem",
expectGameBuild: 1101,
expectEntityEvents: 2477532,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectUnitOrderEvents: 64823,
skipInCI: true,
},
1788648401: {
matchId: "1788648401",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1788648401.dem",
expectGameBuild: 1036,
expectEntityEvents: 2357365,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
expectHeroEntityName: "CDOTA_Unit_Hero_Earthshaker",
expectHeroEntityMana: 1189.9386,
expectHeroEntityPlayerId: 8,
},
1786687320: {
matchId: "1786687320",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1786687320.dem",
expectGameBuild: 1033,
expectCombatLogDamage: 0,
expectCombatLogHealing: 0,
expectCombatLogDeaths: 0,
expectCombatLogEvents: 0,
skipInCI: true,
},
1785937100: {
matchId: "1785937100",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1785937100.dem",
expectGameBuild: 1033,
expectEntityEvents: 1965109,
expectCombatLogDamage: 955729,
expectCombatLogHealing: 33158,
expectCombatLogDeaths: 1345,
expectCombatLogEvents: 41529,
expectUnitOrderEvents: 52359,
expectPlayer6Name: "JiimoxD",
expectPlayer6Steamid: 76561198203594628,
skipInCI: true,
},
1785899023: {
matchId: "1785899023",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1785899023.dem",
expectGameBuild: 1033,
expectEntityEvents: 2419045,
expectCombatLogDamage: 1803248,
expectCombatLogHealing: 48337,
expectCombatLogDeaths: 1954,
expectCombatLogEvents: 78804,
expectUnitOrderEvents: 58269,
expectPlayer6Name: "+27",
expectPlayer6Steamid: 76561198063151170,
skipInCI: true,
},
1785874713: {
matchId: "1785874713",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1785874713.dem",
expectGameBuild: 1033,
expectEntityEvents: 1381012,
expectCombatLogDamage: 513912,
expectCombatLogHealing: 33359,
expectCombatLogDeaths: 749,
expectCombatLogEvents: 21840,
expectUnitOrderEvents: 40240,
expectPlayer6Name: "San-Say",
expectPlayer6Steamid: 76561198020188611,
skipInCI: true,
},
1781640270: {
matchId: "1781640270",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1781640270.dem",
expectGameBuild: 1027,
expectEntityEvents: 1057562,
expectCombatLogDamage: 345422,
expectCombatLogHealing: 25884,
expectCombatLogDeaths: 645,
expectCombatLogEvents: 18313,
expectUnitOrderEvents: 39222,
expectPlayer6Name: "GGGGGGGGGG",
expectPlayer6Steamid: 76561198032710514,
},
1764592109: {
matchId: "1764592109",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1764592109.dem",
expectGameBuild: 1017,
expectEntityEvents: 1827933,
expectCombatLogDamage: 1008784,
expectCombatLogHealing: 33784,
expectCombatLogDeaths: 1631,
expectCombatLogEvents: 42228,
expectUnitOrderEvents: 36172,
expectPlayer6Name: "Doffo",
expectPlayer6Steamid: 76561198087353732,
skipInCI: true,
},
1763193771: {
matchId: "1763193771",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1763193771.dem",
expectGameBuild: 1016,
expectEntityEvents: 1203640,
expectCombatLogDamage: 623594,
expectCombatLogHealing: 19530,
expectCombatLogDeaths: 1022,
expectCombatLogEvents: 24436,
expectUnitOrderEvents: 31994,
expectPlayer6Name: "Monst_er",
expectPlayer6Steamid: 76561198201328510,
skipInCI: true,
},
1763177231: {
matchId: "1763177231",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1763177231.dem",
expectGameBuild: 1016,
expectEntityEvents: 1221874,
expectCombatLogDamage: 479350,
expectCombatLogHealing: 22611,
expectCombatLogDeaths: 977,
expectCombatLogEvents: 20043,
expectUnitOrderEvents: 35975,
expectPlayer6Name: "Supercowman",
expectPlayer6Steamid: 76561198013311415,
skipInCI: true,
},
1734886116: {
matchId: "1734886116",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1734886116.dem",
expectGameBuild: 1003,
expectEntityEvents: 2049211,
expectCombatLogDamage: 1048805,
expectCombatLogHealing: 25089,
expectCombatLogDeaths: 1447,
expectCombatLogEvents: 42307,
expectUnitOrderEvents: 59775,
expectPlayer6Name: "Eggard",
expectPlayer6Steamid: 76561197972599979,
},
1731962898: {
matchId: "1731962898",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1731962898.dem",
expectGameBuild: 1003,
expectEntityEvents: 1183267,
expectCombatLogDamage: 415560,
expectCombatLogHealing: 20018,
expectCombatLogDeaths: 690,
expectCombatLogEvents: 24296,
expectUnitOrderEvents: 27525,
expectPlayer6Name: "Snayp8",
expectPlayer6Steamid: 76561198047587062,
skipInCI: true,
},
1716444111: {
matchId: "1716444111",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1716444111.dem",
expectGameBuild: 995,
expectEntityEvents: 2854511,
expectCombatLogDamage: 1398735,
expectCombatLogHealing: 49659,
expectCombatLogDeaths: 2169,
expectCombatLogEvents: 76921,
expectUnitOrderEvents: 48822,
expectPlayer6Name: "GangBang",
expectPlayer6Steamid: 76561198136700681,
skipInCI: true,
},
1712853372: {
matchId: "1712853372",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1712853372.dem",
expectGameBuild: 991,
expectEntityEvents: 1708696,
expectCombatLogDamage: 671297,
expectCombatLogHealing: 23467,
expectCombatLogDeaths: 1099,
expectCombatLogEvents: 30381,
expectUnitOrderEvents: 48107,
expectPlayer6Name: "BFG",
expectPlayer6Steamid: 76561198047707927,
skipInCI: true,
},
1648457986: {
matchId: "1648457986",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1648457986.dem",
expectGameBuild: 962,
expectEntityEvents: 742252,
expectCombatLogDamage: 224773,
expectCombatLogHealing: 5914,
expectCombatLogDeaths: 466,
expectCombatLogEvents: 10170,
expectUnitOrderEvents: 17822,
expectPlayer6Name: "Grinder",
expectPlayer6Steamid: 76561198207988337,
skipInCI: true,
},
1605340040: {
matchId: "1605340040",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1605340040.dem",
expectGameBuild: 955,
expectEntityEvents: 1283574,
expectCombatLogDamage: 522367,
expectCombatLogHealing: 31721,
expectCombatLogDeaths: 795,
expectCombatLogEvents: 21116,
expectUnitOrderEvents: 40669,
expectPlayer6Name: "Az ★ | Big A Man",
expectPlayer6Steamid: 76561198156504817,
expectHeroEntityName: "CDOTA_Unit_Hero_Chen",
expectHeroEntityMana: 1159.9386,
skipInCI: true,
},
1582611189: {
matchId: "1582611189",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1582611189.dem",
expectGameBuild: 944,
expectEntityEvents: 1427025,
expectCombatLogDamage: 599388,
expectCombatLogHealing: 28576,
expectCombatLogDeaths: 930,
expectCombatLogEvents: 23800,
expectUnitOrderEvents: 40237,
expectPlayer6Name: "The13ananaMan",
expectPlayer6Steamid: 76561198068424443,
skipInCI: true,
},
1560315800: {
matchId: "1560315800",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1560315800.dem",
expectGameBuild: 928,
expectEntityEvents: 2781076,
expectCombatLogDamage: 1332418,
expectCombatLogHealing: 57874,
expectCombatLogDeaths: 1645,
expectCombatLogEvents: 51288,
expectUnitOrderEvents: 63992,
expectPlayer6Name: "ariethebeast",
expectPlayer6Steamid: 76561198065323776,
expectHeroEntityName: "CDOTA_Unit_Hero_Pudge",
expectHeroEntityMana: 858.10474,
skipInCI: true,
},
1560294294: {
matchId: "1560294294",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1560294294.dem",
expectGameBuild: 928,
expectEntityEvents: 1611898,
expectCombatLogDamage: 768154,
expectCombatLogHealing: 11565,
expectCombatLogDeaths: 954,
expectCombatLogEvents: 24535,
expectUnitOrderEvents: 30657,
expectPlayer6Name: "Laslo",
expectPlayer6Steamid: 76561198034549887,
skipInCI: true,
},
1560289528: {
matchId: "1560289528",
replayUrl: "https://s3-us-west-2.amazonaws.com/manta.dotabuff/1560289528.dem",
expectGameBuild: 928,
expectEntityEvents: 2270022,
expectCombatLogDamage: 1180993,
expectCombatLogHealing: 57511,
expectCombatLogDeaths: 1449,
expectCombatLogEvents: 49146,
expectUnitOrderEvents: 63387,
expectPlayer6Name: "It takes a tree to tango",
expectPlayer6Steamid: 76561197993050562,
expectHeroEntityName: "CDOTA_Unit_Hero_Undying",
expectHeroEntityMana: 1108.1353,
skipInCI: true,
},
}
func (s testScenario) bench(b *testing.B) {
for n := 0; n < b.N; n++ {
r := mustGetReplayReader(s.matchId, s.replayUrl)
parser, err := NewStreamParser(r)
if err != nil {
b.Fatalf("unable to instantiate parser: %s", err)
}
parser.Callbacks.OnCDOTAUserMsg_SpectatorPlayerUnitOrders(func(m *dota.CDOTAUserMsg_SpectatorPlayerUnitOrders) error { return nil })
parser.Callbacks.OnCDemoFileInfo(func(m *dota.CDemoFileInfo) error { return nil })
parser.OnEntity(func(e *Entity, op EntityOp) error { return nil })
parser.OnGameEvent("dota_combatlog", func(m *GameEvent) error { return nil })
if err := parser.Start(); err != nil {
b.Fatal(err)
}
}
b.ReportAllocs()
}
func (s testScenario) test(t *testing.T) {
assert := assert.New(t)
if s.debugLevel > 0 {
if s.debugTick == 0 {
debugLevel = s.debugLevel
}
defer func() {
debugLevel = 0
}()
}
if s.skipInCI && os.Getenv("CI") != "" {
t.Skip("skipping scenario in CI environment")
}
t.Parallel()
r := mustGetReplayReader(s.matchId, s.replayUrl)
defer r.Close()
parser, err := NewStreamParser(r)
if err != nil {
t.Errorf("unable to instantiate parser: %s", err)
return
}
gotFileInfo := false
gotCombatLogDamage := int32(0)
gotCombatLogHealing := int32(0)
gotCombatLogDeaths := int32(0)
gotCombatLogEvents := int32(0)
gotUnitOrderEvents := int32(0)
gotEntityEvents := int32(0)
gotPlayer6Name := "<Missing>"
gotPlayer6Steamid := uint64(0)
gotHeroEntityMana := float32(0.0)
gotHeroEntityPlayerId := int32(0)
if s.debugTick > 0 {
parser.Callbacks.OnCNETMsg_Tick(func(m *dota.CNETMsg_Tick) error {
if parser.Tick >= s.debugTick {
debugLevel = s.debugLevel
}
return nil
})
}
parser.Callbacks.OnCDOTAUserMsg_SpectatorPlayerUnitOrders(func(m *dota.CDOTAUserMsg_SpectatorPlayerUnitOrders) error {
gotUnitOrderEvents += 1
return nil
})
parser.Callbacks.OnCDemoFileInfo(func(m *dota.CDemoFileInfo) error {
gotFileInfo = true
return nil
})
parser.OnEntity(func(e *Entity, op EntityOp) error {
gotEntityEvents += 1
if e.class.name == s.expectHeroEntityName {
if v, ok := e.Get("m_flMaxMana").(float32); ok {
gotHeroEntityMana = v
}
if v, ok := e.GetInt32("m_iPlayerID"); ok {
gotHeroEntityPlayerId = v
}
}
if e.class.name == "CDOTA_PlayerResource" {
if v, ok := e.Get("m_vecPlayerData.0006.m_iszPlayerName").(string); ok {
gotPlayer6Name = v
} else if v, ok := e.Get("m_iszPlayerNames.0006").(string); ok {
gotPlayer6Name = v
}
if v, ok := e.Get("m_vecPlayerData.0006.m_iPlayerSteamID").(uint64); ok {
gotPlayer6Steamid = v
} else if v, ok := e.Get("m_iPlayerSteamIDs.0006").(uint64); ok {
gotPlayer6Steamid = v
}
}
return nil
})
parser.OnGameEvent("dota_combatlog", func(m *GameEvent) error {
gotCombatLogEvents += 1
t, err := m.GetInt32("type")
assert.Nil(err)
switch dota.DOTA_COMBATLOG_TYPES(t) {
case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DAMAGE:
v, err := m.GetInt32("value")
assert.Nil(err)
gotCombatLogDamage += v
case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DEATH:
gotCombatLogDeaths += 1
case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_HEAL:
v, err := m.GetInt32("value")
assert.Nil(err)
gotCombatLogHealing += v
}
return nil
})
err = parser.Start()
assert.Nil(err, s.matchId)
assert.True(gotFileInfo)
assert.Equal(s.expectGameBuild, parser.GameBuild, s.matchId)
if s.expectEntityEvents > 0 {
assert.Equal(s.expectEntityEvents, gotEntityEvents, s.matchId)
}
if s.expectCombatLogDamage > 0 {
assert.Equal(s.expectCombatLogDamage, gotCombatLogDamage, s.matchId)
}
if s.expectCombatLogHealing > 0 {
assert.Equal(s.expectCombatLogHealing, gotCombatLogHealing, s.matchId)
}
if s.expectCombatLogDeaths > 0 {
assert.Equal(s.expectCombatLogDeaths, gotCombatLogDeaths, s.matchId)
}
if s.expectCombatLogEvents > 0 {
assert.Equal(s.expectCombatLogEvents, gotCombatLogEvents, s.matchId)
}
if s.expectUnitOrderEvents > 0 {
assert.Equal(s.expectUnitOrderEvents, gotUnitOrderEvents, s.matchId)
}
if s.expectPlayer6Name != "" {
assert.Equal(s.expectPlayer6Name, gotPlayer6Name, s.matchId)
}
if s.expectPlayer6Steamid > 0 {
assert.Equal(s.expectPlayer6Steamid, gotPlayer6Steamid, s.matchId)
}
if s.expectHeroEntityMana > 0.0 {
assert.Equal(s.expectHeroEntityMana, gotHeroEntityMana, s.matchId)
}
if s.expectHeroEntityPlayerId > 0.0 {
assert.Equal(s.expectHeroEntityPlayerId, gotHeroEntityPlayerId, s.matchId)
}
}