react-native-update 10.50.0 → 10.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/NATIVE_CHECKUPDATE_DESIGN.md +251 -21
  2. package/NATIVE_CHECK_FOLLOWUPS.md +365 -0
  3. package/README-CN.md +14 -1
  4. package/README.md +14 -1
  5. package/android/jni/Android.mk +5 -1
  6. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  7. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  8. package/android/lib/x86/librnupdate.so +0 -0
  9. package/android/lib/x86_64/librnupdate.so +0 -0
  10. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +76 -21
  11. package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +3 -0
  12. package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +455 -0
  13. package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +23 -0
  14. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +160 -42
  15. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +44 -0
  16. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +10 -0
  17. package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +10 -0
  18. package/cpp/update_flow_core/flow_json.cpp +522 -0
  19. package/cpp/update_flow_core/flow_json.h +103 -0
  20. package/cpp/update_flow_core/tests/flow_vectors.json +1401 -0
  21. package/cpp/update_flow_core/tests/update_flow_core_test.cpp +317 -0
  22. package/cpp/update_flow_core/update_flow_core.cpp +301 -0
  23. package/cpp/update_flow_core/update_flow_core.h +77 -0
  24. package/cpp/update_flow_core/update_flow_jni.cpp +121 -0
  25. package/harmony/pushy/src/main/cpp/CMakeLists.txt +7 -0
  26. package/harmony/pushy/src/main/cpp/pushy.cpp +103 -1
  27. package/harmony/pushy/src/main/ets/DownloadTask.ts +48 -9
  28. package/harmony/pushy/src/main/ets/DownloadTaskParams.ts +3 -0
  29. package/harmony/pushy/src/main/ets/MonotonicClock.ts +13 -0
  30. package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +500 -0
  31. package/harmony/pushy/src/main/ets/NativePatchCore.ts +14 -0
  32. package/harmony/pushy/src/main/ets/PathUtils.ts +21 -0
  33. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +22 -0
  34. package/harmony/pushy/src/main/ets/UpdateContext.ts +148 -69
  35. package/harmony/pushy.har +0 -0
  36. package/ios/RCTPushy/RCTPushy.mm +779 -61
  37. package/ios/RCTPushy/RCTPushyDownloader.h +1 -0
  38. package/ios/RCTPushy/RCTPushyDownloader.mm +4 -3
  39. package/package.json +3 -1
  40. package/react-native-update.podspec +2 -0
  41. package/src/NativePushy.ts +14 -0
  42. package/src/client.ts +341 -118
  43. package/src/endpoint.ts +7 -29
  44. package/src/provider.tsx +38 -2
  45. package/src/type.ts +26 -0
  46. package/src/updateFlowCore.ts +320 -0
  47. package/src/utils.ts +1 -12
  48. package/src/isInRollout.ts +0 -87
  49. package/src/resolveCheckResult.ts +0 -30
@@ -0,0 +1,1401 @@
1
+ {
2
+ "generated_by": "scripts/generate-flow-vectors.ts — do not edit by hand",
3
+ "cases": [
4
+ {
5
+ "fn": "murmurhash3_32_gc",
6
+ "args": [
7
+ ""
8
+ ],
9
+ "expected": 0
10
+ },
11
+ {
12
+ "fn": "murmurhash3_32_gc",
13
+ "args": [
14
+ "hello"
15
+ ],
16
+ "expected": 613153351
17
+ },
18
+ {
19
+ "fn": "murmurhash3_32_gc",
20
+ "args": [
21
+ "test"
22
+ ],
23
+ "expected": 3127628307
24
+ },
25
+ {
26
+ "fn": "murmurhash3_32_gc",
27
+ "args": [
28
+ "Hello, world!"
29
+ ],
30
+ "expected": 3224780355
31
+ },
32
+ {
33
+ "fn": "murmurhash3_32_gc",
34
+ "args": [
35
+ "The quick brown fox jumps over the lazy dog"
36
+ ],
37
+ "expected": 776992547
38
+ },
39
+ {
40
+ "fn": "murmurhash3_32_gc",
41
+ "args": [
42
+ "test1"
43
+ ],
44
+ "expected": 374203662
45
+ },
46
+ {
47
+ "fn": "murmurhash3_32_gc",
48
+ "args": [
49
+ "test2"
50
+ ],
51
+ "expected": 3155333867
52
+ },
53
+ {
54
+ "fn": "murmurhash3_32_gc",
55
+ "args": [
56
+ "test3"
57
+ ],
58
+ "expected": 4144626353
59
+ },
60
+ {
61
+ "fn": "murmurhash3_32_gc",
62
+ "args": [
63
+ "123e4567-e89b-12d3-a456-426614174000"
64
+ ],
65
+ "expected": 439536286
66
+ },
67
+ {
68
+ "fn": "murmurhash3_32_gc",
69
+ "args": [
70
+ "123e4567-e89b-12d3-a456-426614174001"
71
+ ],
72
+ "expected": 3316680088
73
+ },
74
+ {
75
+ "fn": "murmurhash3_32_gc",
76
+ "args": [
77
+ "a"
78
+ ],
79
+ "expected": 1009084850
80
+ },
81
+ {
82
+ "fn": "murmurhash3_32_gc",
83
+ "args": [
84
+ "ab"
85
+ ],
86
+ "expected": 2613040991
87
+ },
88
+ {
89
+ "fn": "murmurhash3_32_gc",
90
+ "args": [
91
+ "abc"
92
+ ],
93
+ "expected": 3017643002
94
+ },
95
+ {
96
+ "fn": "murmurhash3_32_gc",
97
+ "args": [
98
+ "abcd"
99
+ ],
100
+ "expected": 1139631978
101
+ },
102
+ {
103
+ "fn": "isInRollout",
104
+ "args": [
105
+ 63,
106
+ "test1"
107
+ ],
108
+ "expected": true
109
+ },
110
+ {
111
+ "fn": "isInRollout",
112
+ "args": [
113
+ 62,
114
+ "test1"
115
+ ],
116
+ "expected": false
117
+ },
118
+ {
119
+ "fn": "isInRollout",
120
+ "args": [
121
+ 61,
122
+ "test1"
123
+ ],
124
+ "expected": false
125
+ },
126
+ {
127
+ "fn": "isInRollout",
128
+ "args": [
129
+ 0,
130
+ "test1"
131
+ ],
132
+ "expected": false
133
+ },
134
+ {
135
+ "fn": "isInRollout",
136
+ "args": [
137
+ 100,
138
+ "test1"
139
+ ],
140
+ "expected": true
141
+ },
142
+ {
143
+ "fn": "isInRollout",
144
+ "args": [
145
+ -1,
146
+ "test3"
147
+ ],
148
+ "expected": false
149
+ },
150
+ {
151
+ "fn": "isInRollout",
152
+ "args": [
153
+ 54,
154
+ "test3"
155
+ ],
156
+ "expected": true
157
+ },
158
+ {
159
+ "fn": "isInRollout",
160
+ "args": [
161
+ 53,
162
+ "test3"
163
+ ],
164
+ "expected": false
165
+ },
166
+ {
167
+ "fn": "joinUrls",
168
+ "args": [
169
+ [
170
+ "example.com"
171
+ ]
172
+ ]
173
+ },
174
+ {
175
+ "fn": "joinUrls",
176
+ "args": [
177
+ [
178
+ "example.com"
179
+ ],
180
+ ""
181
+ ]
182
+ },
183
+ {
184
+ "fn": "joinUrls",
185
+ "args": [
186
+ [],
187
+ "file.txt"
188
+ ],
189
+ "expected": []
190
+ },
191
+ {
192
+ "fn": "joinUrls",
193
+ "args": [
194
+ [
195
+ "example.com",
196
+ "test.org"
197
+ ],
198
+ "file.txt"
199
+ ],
200
+ "expected": [
201
+ "https://example.com/file.txt",
202
+ "https://test.org/file.txt"
203
+ ]
204
+ },
205
+ {
206
+ "fn": "joinUrls",
207
+ "args": [
208
+ [
209
+ "example.com///",
210
+ "http://example.com///"
211
+ ],
212
+ "file.txt"
213
+ ],
214
+ "expected": [
215
+ "https://example.com/file.txt",
216
+ "http://example.com/file.txt"
217
+ ]
218
+ },
219
+ {
220
+ "fn": "joinUrls",
221
+ "args": [
222
+ [
223
+ "ftp://example.com",
224
+ "myapp://some/path"
225
+ ],
226
+ "file.txt"
227
+ ],
228
+ "expected": [
229
+ "ftp://example.com/file.txt",
230
+ "myapp://some/path/file.txt"
231
+ ]
232
+ },
233
+ {
234
+ "fn": "joinUrls",
235
+ "args": [
236
+ [
237
+ "192.168.1.1:8080",
238
+ "10.0.0.1:3000/api"
239
+ ],
240
+ "file.txt"
241
+ ],
242
+ "expected": [
243
+ "https://192.168.1.1:8080/file.txt",
244
+ "https://10.0.0.1:3000/api/file.txt"
245
+ ]
246
+ },
247
+ {
248
+ "fn": "joinUrls",
249
+ "args": [
250
+ [
251
+ ""
252
+ ],
253
+ "file.txt"
254
+ ],
255
+ "expected": [
256
+ "https:///file.txt"
257
+ ]
258
+ },
259
+ {
260
+ "fn": "joinUrls",
261
+ "args": [
262
+ [
263
+ "HTTPS://Upper.example.com"
264
+ ],
265
+ "file.txt"
266
+ ],
267
+ "expected": [
268
+ "HTTPS://Upper.example.com/file.txt"
269
+ ]
270
+ },
271
+ {
272
+ "fn": "joinUrls",
273
+ "args": [
274
+ [
275
+ "a:b://weird"
276
+ ],
277
+ "file.txt"
278
+ ],
279
+ "expected": [
280
+ "https://a:b://weird/file.txt"
281
+ ]
282
+ },
283
+ {
284
+ "fn": "orderEndpointCandidates",
285
+ "args": [
286
+ [
287
+ "a",
288
+ "b",
289
+ "c"
290
+ ],
291
+ 0
292
+ ],
293
+ "expected": [
294
+ "a",
295
+ "b",
296
+ "c"
297
+ ]
298
+ },
299
+ {
300
+ "fn": "orderEndpointCandidates",
301
+ "args": [
302
+ [
303
+ "a",
304
+ "b",
305
+ "c"
306
+ ],
307
+ 0.34
308
+ ],
309
+ "expected": [
310
+ "b",
311
+ "a",
312
+ "c"
313
+ ]
314
+ },
315
+ {
316
+ "fn": "orderEndpointCandidates",
317
+ "args": [
318
+ [
319
+ "a",
320
+ "b",
321
+ "c"
322
+ ],
323
+ 0.5
324
+ ],
325
+ "expected": [
326
+ "b",
327
+ "a",
328
+ "c"
329
+ ]
330
+ },
331
+ {
332
+ "fn": "orderEndpointCandidates",
333
+ "args": [
334
+ [
335
+ "a",
336
+ "b",
337
+ "c"
338
+ ],
339
+ 0.99
340
+ ],
341
+ "expected": [
342
+ "c",
343
+ "a",
344
+ "b"
345
+ ]
346
+ },
347
+ {
348
+ "fn": "orderEndpointCandidates",
349
+ "args": [
350
+ [
351
+ "a",
352
+ "b",
353
+ "c"
354
+ ],
355
+ 1
356
+ ],
357
+ "expected": [
358
+ "c",
359
+ "a",
360
+ "b"
361
+ ]
362
+ },
363
+ {
364
+ "fn": "orderEndpointCandidates",
365
+ "args": [
366
+ [
367
+ "a",
368
+ null,
369
+ "a",
370
+ "",
371
+ "b"
372
+ ],
373
+ 0.6
374
+ ],
375
+ "expected": [
376
+ "b",
377
+ "a"
378
+ ]
379
+ },
380
+ {
381
+ "fn": "orderEndpointCandidates",
382
+ "args": [
383
+ [],
384
+ 0.5
385
+ ],
386
+ "expected": []
387
+ },
388
+ {
389
+ "fn": "orderEndpointCandidates",
390
+ "args": [
391
+ [
392
+ "a"
393
+ ],
394
+ 0.5
395
+ ],
396
+ "expected": [
397
+ "a"
398
+ ]
399
+ },
400
+ {
401
+ "fn": "buildCheckRequestBody",
402
+ "args": [
403
+ {
404
+ "packageVersion": "2.3.4",
405
+ "currentVersion": "abcdef1234",
406
+ "buildTime": "1719999999",
407
+ "cInfo": {
408
+ "rnu": "10.50.0",
409
+ "rn": "0.85.2",
410
+ "os": "ios 17.5",
411
+ "uuid": "u-1"
412
+ }
413
+ }
414
+ ],
415
+ "expected": {
416
+ "packageVersion": "2.3.4",
417
+ "hash": "abcdef1234",
418
+ "buildTime": "1719999999",
419
+ "cInfo": {
420
+ "rnu": "10.50.0",
421
+ "rn": "0.85.2",
422
+ "os": "ios 17.5",
423
+ "uuid": "u-1"
424
+ }
425
+ }
426
+ },
427
+ {
428
+ "fn": "buildCheckRequestBody",
429
+ "args": [
430
+ {
431
+ "packageVersion": "2.3.4",
432
+ "currentVersion": "abcdef1234",
433
+ "buildTime": "1719999999",
434
+ "cInfo": {
435
+ "rnu": "10.50.0",
436
+ "rn": "0.85.2",
437
+ "os": "ios 17.5",
438
+ "uuid": "u-1"
439
+ },
440
+ "supportedDiffVersion": 2,
441
+ "bundleHash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
442
+ }
443
+ ],
444
+ "expected": {
445
+ "packageVersion": "2.3.4",
446
+ "hash": "abcdef1234",
447
+ "buildTime": "1719999999",
448
+ "cInfo": {
449
+ "rnu": "10.50.0",
450
+ "rn": "0.85.2",
451
+ "os": "ios 17.5",
452
+ "uuid": "u-1"
453
+ },
454
+ "diffV": 2,
455
+ "bundleHash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
456
+ }
457
+ },
458
+ {
459
+ "fn": "buildCheckRequestBody",
460
+ "args": [
461
+ {
462
+ "packageVersion": "2.3.4",
463
+ "currentVersion": "",
464
+ "buildTime": "1719999999",
465
+ "cInfo": {
466
+ "rnu": "10.50.0",
467
+ "rn": "0.85.2",
468
+ "os": "ios 17.5",
469
+ "uuid": "u-1"
470
+ },
471
+ "supportedDiffVersion": 0,
472
+ "bundleHash": ""
473
+ }
474
+ ],
475
+ "expected": {
476
+ "packageVersion": "2.3.4",
477
+ "hash": "",
478
+ "buildTime": "1719999999",
479
+ "cInfo": {
480
+ "rnu": "10.50.0",
481
+ "rn": "0.85.2",
482
+ "os": "ios 17.5",
483
+ "uuid": "u-1"
484
+ }
485
+ }
486
+ },
487
+ {
488
+ "fn": "buildCheckRequestBody",
489
+ "args": [
490
+ {
491
+ "packageVersion": "2.3.4",
492
+ "currentVersion": "abcdef1234",
493
+ "buildTime": "1719999999",
494
+ "cInfo": {
495
+ "rnu": "10.50.0",
496
+ "rn": "0.85.2",
497
+ "os": "ios 17.5",
498
+ "uuid": "u-1"
499
+ },
500
+ "extra": {
501
+ "toHash": "debug-hash",
502
+ "hash": "override-hash"
503
+ }
504
+ }
505
+ ],
506
+ "expected": {
507
+ "packageVersion": "2.3.4",
508
+ "hash": "override-hash",
509
+ "buildTime": "1719999999",
510
+ "cInfo": {
511
+ "rnu": "10.50.0",
512
+ "rn": "0.85.2",
513
+ "os": "ios 17.5",
514
+ "uuid": "u-1"
515
+ },
516
+ "toHash": "debug-hash"
517
+ }
518
+ },
519
+ {
520
+ "fn": "buildCheckRequestBody",
521
+ "args": [
522
+ {
523
+ "packageVersion": "2.3.4",
524
+ "currentVersion": "abcdef1234",
525
+ "buildTime": "1719999999",
526
+ "cInfo": {
527
+ "rnu": "10.50.0",
528
+ "rn": "0.85.2",
529
+ "os": "ios 17.5",
530
+ "uuid": "u-1"
531
+ },
532
+ "isDev": true,
533
+ "extra": {
534
+ "buildTime": "injected"
535
+ }
536
+ }
537
+ ],
538
+ "expected": {
539
+ "packageVersion": "2.3.4",
540
+ "hash": "abcdef1234",
541
+ "cInfo": {
542
+ "rnu": "10.50.0",
543
+ "rn": "0.85.2",
544
+ "os": "ios 17.5",
545
+ "uuid": "u-1"
546
+ }
547
+ }
548
+ },
549
+ {
550
+ "fn": "buildCheckRequestBody",
551
+ "args": [
552
+ {
553
+ "packageVersion": "2.3.4",
554
+ "buildTime": "1719999999",
555
+ "cInfo": {
556
+ "rnu": "10.50.0",
557
+ "rn": "0.85.2",
558
+ "os": "ios 17.5",
559
+ "uuid": "u-1"
560
+ }
561
+ }
562
+ ],
563
+ "expected": {
564
+ "packageVersion": "2.3.4",
565
+ "buildTime": "1719999999",
566
+ "cInfo": {
567
+ "rnu": "10.50.0",
568
+ "rn": "0.85.2",
569
+ "os": "ios 17.5",
570
+ "uuid": "u-1"
571
+ }
572
+ }
573
+ },
574
+ {
575
+ "fn": "resolveCheckResult",
576
+ "args": [
577
+ {
578
+ "update": true,
579
+ "hash": "root-hash",
580
+ "name": "root",
581
+ "description": "rd",
582
+ "metaInfo": "rm",
583
+ "diff": "a.hdiff",
584
+ "pdiff": "b.phdiff",
585
+ "full": "c.ppk",
586
+ "paths": [
587
+ "cdn.example.com"
588
+ ],
589
+ "expVersion": {
590
+ "name": "gray",
591
+ "hash": "gray-hash",
592
+ "description": "d",
593
+ "metaInfo": "m",
594
+ "config": {
595
+ "rollout": {
596
+ "2.3.4": 63
597
+ }
598
+ }
599
+ }
600
+ },
601
+ {
602
+ "packageVersion": "2.3.4",
603
+ "currentVersion": "current-hash",
604
+ "uuid": "test1"
605
+ }
606
+ ],
607
+ "expected": {
608
+ "update": true,
609
+ "name": "gray",
610
+ "hash": "gray-hash",
611
+ "description": "d",
612
+ "metaInfo": "m",
613
+ "config": {
614
+ "rollout": {
615
+ "2.3.4": 63
616
+ }
617
+ },
618
+ "paths": [
619
+ "cdn.example.com"
620
+ ]
621
+ }
622
+ },
623
+ {
624
+ "fn": "resolveCheckResult",
625
+ "args": [
626
+ {
627
+ "update": true,
628
+ "hash": "root-hash",
629
+ "name": "root",
630
+ "description": "rd",
631
+ "metaInfo": "rm",
632
+ "diff": "a.hdiff",
633
+ "pdiff": "b.phdiff",
634
+ "full": "c.ppk",
635
+ "paths": [
636
+ "cdn.example.com"
637
+ ],
638
+ "expVersion": {
639
+ "name": "gray",
640
+ "hash": "gray-hash",
641
+ "description": "d",
642
+ "metaInfo": "m",
643
+ "config": {
644
+ "rollout": {
645
+ "2.3.4": 62
646
+ }
647
+ }
648
+ }
649
+ },
650
+ {
651
+ "packageVersion": "2.3.4",
652
+ "currentVersion": "current-hash",
653
+ "uuid": "test1"
654
+ }
655
+ ],
656
+ "expected": {
657
+ "update": true,
658
+ "hash": "root-hash",
659
+ "name": "root",
660
+ "description": "rd",
661
+ "metaInfo": "rm",
662
+ "diff": "a.hdiff",
663
+ "pdiff": "b.phdiff",
664
+ "full": "c.ppk",
665
+ "paths": [
666
+ "cdn.example.com"
667
+ ]
668
+ }
669
+ },
670
+ {
671
+ "fn": "resolveCheckResult",
672
+ "args": [
673
+ {
674
+ "update": true,
675
+ "hash": "root-hash",
676
+ "name": "root",
677
+ "description": "rd",
678
+ "metaInfo": "rm",
679
+ "diff": "a.hdiff",
680
+ "pdiff": "b.phdiff",
681
+ "full": "c.ppk",
682
+ "paths": [
683
+ "cdn.example.com"
684
+ ],
685
+ "expVersion": {
686
+ "name": "gray",
687
+ "hash": "current-hash",
688
+ "description": "d",
689
+ "metaInfo": "m",
690
+ "config": {
691
+ "rollout": {
692
+ "2.3.4": 100
693
+ }
694
+ }
695
+ }
696
+ },
697
+ {
698
+ "packageVersion": "2.3.4",
699
+ "currentVersion": "current-hash",
700
+ "uuid": "test1"
701
+ }
702
+ ],
703
+ "expected": {
704
+ "upToDate": true
705
+ }
706
+ },
707
+ {
708
+ "fn": "resolveCheckResult",
709
+ "args": [
710
+ {
711
+ "update": true,
712
+ "hash": "root-hash",
713
+ "name": "root",
714
+ "description": "rd",
715
+ "metaInfo": "rm",
716
+ "diff": "a.hdiff",
717
+ "pdiff": "b.phdiff",
718
+ "full": "c.ppk",
719
+ "paths": [
720
+ "cdn.example.com"
721
+ ]
722
+ },
723
+ {
724
+ "packageVersion": "2.3.4",
725
+ "currentVersion": "current-hash",
726
+ "uuid": "test1"
727
+ }
728
+ ],
729
+ "expected": {
730
+ "update": true,
731
+ "hash": "root-hash",
732
+ "name": "root",
733
+ "description": "rd",
734
+ "metaInfo": "rm",
735
+ "diff": "a.hdiff",
736
+ "pdiff": "b.phdiff",
737
+ "full": "c.ppk",
738
+ "paths": [
739
+ "cdn.example.com"
740
+ ]
741
+ }
742
+ },
743
+ {
744
+ "fn": "resolveCheckResult",
745
+ "args": [
746
+ {
747
+ "update": true,
748
+ "hash": "current-hash",
749
+ "name": "root",
750
+ "description": "rd",
751
+ "metaInfo": "rm",
752
+ "diff": "a.hdiff",
753
+ "pdiff": "b.phdiff",
754
+ "full": "c.ppk",
755
+ "paths": [
756
+ "cdn.example.com"
757
+ ]
758
+ },
759
+ {
760
+ "packageVersion": "2.3.4",
761
+ "currentVersion": "current-hash",
762
+ "uuid": "test1"
763
+ }
764
+ ],
765
+ "expected": {
766
+ "upToDate": true
767
+ }
768
+ },
769
+ {
770
+ "fn": "resolveCheckResult",
771
+ "args": [
772
+ {
773
+ "upToDate": true
774
+ },
775
+ {
776
+ "packageVersion": "2.3.4",
777
+ "currentVersion": "current-hash",
778
+ "uuid": "test1"
779
+ }
780
+ ],
781
+ "expected": {
782
+ "upToDate": true
783
+ }
784
+ },
785
+ {
786
+ "fn": "resolveCheckResult",
787
+ "args": [
788
+ {
789
+ "update": false,
790
+ "hash": "x"
791
+ },
792
+ {
793
+ "packageVersion": "2.3.4",
794
+ "currentVersion": "current-hash",
795
+ "uuid": "test1"
796
+ }
797
+ ],
798
+ "expected": {
799
+ "update": false,
800
+ "hash": "x"
801
+ }
802
+ },
803
+ {
804
+ "fn": "resolveCheckResult",
805
+ "args": [
806
+ {
807
+ "update": true,
808
+ "hash": "root-hash",
809
+ "name": "root",
810
+ "description": "rd",
811
+ "metaInfo": "rm",
812
+ "diff": "a.hdiff",
813
+ "pdiff": "b.phdiff",
814
+ "full": "c.ppk",
815
+ "paths": [
816
+ "cdn.example.com"
817
+ ],
818
+ "expVersion": {
819
+ "name": "gray",
820
+ "hash": "gray-hash",
821
+ "description": "d",
822
+ "metaInfo": "m",
823
+ "config": {
824
+ "rollout": {
825
+ "other": 100
826
+ }
827
+ }
828
+ }
829
+ },
830
+ {
831
+ "packageVersion": "2.3.4",
832
+ "currentVersion": "current-hash",
833
+ "uuid": "test1"
834
+ }
835
+ ],
836
+ "expected": {
837
+ "update": true,
838
+ "hash": "root-hash",
839
+ "name": "root",
840
+ "description": "rd",
841
+ "metaInfo": "rm",
842
+ "diff": "a.hdiff",
843
+ "pdiff": "b.phdiff",
844
+ "full": "c.ppk",
845
+ "paths": [
846
+ "cdn.example.com"
847
+ ]
848
+ }
849
+ },
850
+ {
851
+ "fn": "resolveCheckResult",
852
+ "args": [
853
+ {
854
+ "update": true,
855
+ "hash": "root-hash",
856
+ "expVersion": {
857
+ "name": "gray",
858
+ "hash": "gray-hash",
859
+ "description": "d",
860
+ "metaInfo": "m",
861
+ "config": {
862
+ "rollout": {
863
+ "2.3.4": 63
864
+ }
865
+ }
866
+ }
867
+ },
868
+ {
869
+ "packageVersion": "2.3.4",
870
+ "currentVersion": "current-hash",
871
+ "uuid": "test1"
872
+ }
873
+ ],
874
+ "expected": {
875
+ "update": true,
876
+ "name": "gray",
877
+ "hash": "gray-hash",
878
+ "description": "d",
879
+ "metaInfo": "m",
880
+ "config": {
881
+ "rollout": {
882
+ "2.3.4": 63
883
+ }
884
+ }
885
+ }
886
+ },
887
+ {
888
+ "fn": "resolveCheckResult",
889
+ "args": [
890
+ {
891
+ "update": true,
892
+ "hash": "root-hash",
893
+ "expVersion": {
894
+ "name": "gray",
895
+ "description": "d",
896
+ "metaInfo": "m",
897
+ "config": {
898
+ "rollout": {
899
+ "2.3.4": 63
900
+ }
901
+ }
902
+ }
903
+ },
904
+ {
905
+ "packageVersion": "2.3.4",
906
+ "uuid": "test1"
907
+ }
908
+ ],
909
+ "expected": {
910
+ "update": true,
911
+ "name": "gray",
912
+ "description": "d",
913
+ "metaInfo": "m",
914
+ "config": {
915
+ "rollout": {
916
+ "2.3.4": 63
917
+ }
918
+ }
919
+ }
920
+ },
921
+ {
922
+ "fn": "decideDownload",
923
+ "args": [
924
+ {
925
+ "upToDate": true
926
+ },
927
+ {
928
+ "currentVersion": "current-hash",
929
+ "rolledBackVersion": "bad-hash"
930
+ },
931
+ false
932
+ ],
933
+ "expected": {
934
+ "action": "none",
935
+ "reason": "noUpdate"
936
+ }
937
+ },
938
+ {
939
+ "fn": "decideDownload",
940
+ "args": [
941
+ {
942
+ "update": true
943
+ },
944
+ {
945
+ "currentVersion": "current-hash",
946
+ "rolledBackVersion": "bad-hash"
947
+ },
948
+ false
949
+ ],
950
+ "expected": {
951
+ "action": "none",
952
+ "reason": "noUpdate"
953
+ }
954
+ },
955
+ {
956
+ "fn": "decideDownload",
957
+ "args": [
958
+ {
959
+ "update": true,
960
+ "hash": "current-hash",
961
+ "diff": "cur-next.hdiff",
962
+ "pdiff": "pkg-next.phdiff",
963
+ "full": "next.ppk",
964
+ "paths": [
965
+ "cdn.example.com",
966
+ "https://mirror.example.com/base/"
967
+ ]
968
+ },
969
+ {
970
+ "currentVersion": "current-hash",
971
+ "rolledBackVersion": "bad-hash"
972
+ },
973
+ false
974
+ ],
975
+ "expected": {
976
+ "action": "none",
977
+ "reason": "alreadyCurrent"
978
+ }
979
+ },
980
+ {
981
+ "fn": "decideDownload",
982
+ "args": [
983
+ {
984
+ "update": true,
985
+ "hash": "bad-hash",
986
+ "diff": "cur-next.hdiff",
987
+ "pdiff": "pkg-next.phdiff",
988
+ "full": "next.ppk",
989
+ "paths": [
990
+ "cdn.example.com",
991
+ "https://mirror.example.com/base/"
992
+ ]
993
+ },
994
+ {
995
+ "currentVersion": "current-hash",
996
+ "rolledBackVersion": "bad-hash"
997
+ },
998
+ false
999
+ ],
1000
+ "expected": {
1001
+ "action": "none",
1002
+ "reason": "rolledBack"
1003
+ }
1004
+ },
1005
+ {
1006
+ "fn": "decideDownload",
1007
+ "args": [
1008
+ {
1009
+ "update": true,
1010
+ "hash": "bad-hash",
1011
+ "diff": "cur-next.hdiff",
1012
+ "pdiff": "pkg-next.phdiff",
1013
+ "full": "next.ppk",
1014
+ "paths": [
1015
+ "cdn.example.com",
1016
+ "https://mirror.example.com/base/"
1017
+ ]
1018
+ },
1019
+ {
1020
+ "currentVersion": "current-hash"
1021
+ },
1022
+ false
1023
+ ],
1024
+ "expected": {
1025
+ "action": "download",
1026
+ "hash": "bad-hash",
1027
+ "attempts": [
1028
+ {
1029
+ "type": "diff",
1030
+ "urls": [
1031
+ "https://cdn.example.com/cur-next.hdiff",
1032
+ "https://mirror.example.com/base/cur-next.hdiff"
1033
+ ]
1034
+ },
1035
+ {
1036
+ "type": "pdiff",
1037
+ "urls": [
1038
+ "https://cdn.example.com/pkg-next.phdiff",
1039
+ "https://mirror.example.com/base/pkg-next.phdiff"
1040
+ ]
1041
+ },
1042
+ {
1043
+ "type": "full",
1044
+ "urls": [
1045
+ "https://cdn.example.com/next.ppk",
1046
+ "https://mirror.example.com/base/next.ppk"
1047
+ ]
1048
+ }
1049
+ ],
1050
+ "devNoop": false
1051
+ }
1052
+ },
1053
+ {
1054
+ "fn": "decideDownload",
1055
+ "args": [
1056
+ {
1057
+ "update": true,
1058
+ "hash": "next-hash",
1059
+ "diff": "cur-next.hdiff",
1060
+ "pdiff": "pkg-next.phdiff",
1061
+ "full": "next.ppk",
1062
+ "paths": [
1063
+ "cdn.example.com",
1064
+ "https://mirror.example.com/base/"
1065
+ ]
1066
+ },
1067
+ {
1068
+ "currentVersion": "current-hash",
1069
+ "rolledBackVersion": "bad-hash"
1070
+ },
1071
+ false
1072
+ ],
1073
+ "expected": {
1074
+ "action": "download",
1075
+ "hash": "next-hash",
1076
+ "attempts": [
1077
+ {
1078
+ "type": "diff",
1079
+ "urls": [
1080
+ "https://cdn.example.com/cur-next.hdiff",
1081
+ "https://mirror.example.com/base/cur-next.hdiff"
1082
+ ]
1083
+ },
1084
+ {
1085
+ "type": "pdiff",
1086
+ "urls": [
1087
+ "https://cdn.example.com/pkg-next.phdiff",
1088
+ "https://mirror.example.com/base/pkg-next.phdiff"
1089
+ ]
1090
+ },
1091
+ {
1092
+ "type": "full",
1093
+ "urls": [
1094
+ "https://cdn.example.com/next.ppk",
1095
+ "https://mirror.example.com/base/next.ppk"
1096
+ ]
1097
+ }
1098
+ ],
1099
+ "devNoop": false
1100
+ }
1101
+ },
1102
+ {
1103
+ "fn": "decideDownload",
1104
+ "args": [
1105
+ {
1106
+ "update": true,
1107
+ "hash": "next-hash",
1108
+ "pdiff": "pkg-next.phdiff",
1109
+ "full": "next.ppk",
1110
+ "paths": [
1111
+ "cdn.example.com",
1112
+ "https://mirror.example.com/base/"
1113
+ ]
1114
+ },
1115
+ {
1116
+ "currentVersion": "current-hash",
1117
+ "rolledBackVersion": "bad-hash"
1118
+ },
1119
+ false
1120
+ ],
1121
+ "expected": {
1122
+ "action": "download",
1123
+ "hash": "next-hash",
1124
+ "attempts": [
1125
+ {
1126
+ "type": "pdiff",
1127
+ "urls": [
1128
+ "https://cdn.example.com/pkg-next.phdiff",
1129
+ "https://mirror.example.com/base/pkg-next.phdiff"
1130
+ ]
1131
+ },
1132
+ {
1133
+ "type": "full",
1134
+ "urls": [
1135
+ "https://cdn.example.com/next.ppk",
1136
+ "https://mirror.example.com/base/next.ppk"
1137
+ ]
1138
+ }
1139
+ ],
1140
+ "devNoop": false
1141
+ }
1142
+ },
1143
+ {
1144
+ "fn": "decideDownload",
1145
+ "args": [
1146
+ {
1147
+ "update": true,
1148
+ "hash": "next-hash",
1149
+ "diff": "cur-next.hdiff",
1150
+ "full": "next.ppk",
1151
+ "paths": [
1152
+ "cdn.example.com",
1153
+ "https://mirror.example.com/base/"
1154
+ ]
1155
+ },
1156
+ {
1157
+ "currentVersion": "current-hash",
1158
+ "rolledBackVersion": "bad-hash"
1159
+ },
1160
+ false
1161
+ ],
1162
+ "expected": {
1163
+ "action": "download",
1164
+ "hash": "next-hash",
1165
+ "attempts": [
1166
+ {
1167
+ "type": "diff",
1168
+ "urls": [
1169
+ "https://cdn.example.com/cur-next.hdiff",
1170
+ "https://mirror.example.com/base/cur-next.hdiff"
1171
+ ]
1172
+ },
1173
+ {
1174
+ "type": "full",
1175
+ "urls": [
1176
+ "https://cdn.example.com/next.ppk",
1177
+ "https://mirror.example.com/base/next.ppk"
1178
+ ]
1179
+ }
1180
+ ],
1181
+ "devNoop": false
1182
+ }
1183
+ },
1184
+ {
1185
+ "fn": "decideDownload",
1186
+ "args": [
1187
+ {
1188
+ "update": true,
1189
+ "hash": "next-hash",
1190
+ "paths": [
1191
+ "cdn.example.com",
1192
+ "https://mirror.example.com/base/"
1193
+ ]
1194
+ },
1195
+ {
1196
+ "currentVersion": "current-hash",
1197
+ "rolledBackVersion": "bad-hash"
1198
+ },
1199
+ false
1200
+ ],
1201
+ "expected": {
1202
+ "action": "none",
1203
+ "reason": "noArtifact"
1204
+ }
1205
+ },
1206
+ {
1207
+ "fn": "decideDownload",
1208
+ "args": [
1209
+ {
1210
+ "update": true,
1211
+ "hash": "next-hash",
1212
+ "diff": "cur-next.hdiff",
1213
+ "pdiff": "pkg-next.phdiff",
1214
+ "full": "next.ppk",
1215
+ "paths": []
1216
+ },
1217
+ {
1218
+ "currentVersion": "current-hash",
1219
+ "rolledBackVersion": "bad-hash"
1220
+ },
1221
+ false
1222
+ ],
1223
+ "expected": {
1224
+ "action": "none",
1225
+ "reason": "noArtifact"
1226
+ }
1227
+ },
1228
+ {
1229
+ "fn": "decideDownload",
1230
+ "args": [
1231
+ {
1232
+ "update": true,
1233
+ "hash": "next-hash",
1234
+ "full": "next.ppk"
1235
+ },
1236
+ {
1237
+ "currentVersion": "current-hash",
1238
+ "rolledBackVersion": "bad-hash"
1239
+ },
1240
+ false
1241
+ ],
1242
+ "expected": {
1243
+ "action": "none",
1244
+ "reason": "noArtifact"
1245
+ }
1246
+ },
1247
+ {
1248
+ "fn": "decideDownload",
1249
+ "args": [
1250
+ {
1251
+ "update": true,
1252
+ "hash": "next-hash",
1253
+ "diff": "cur-next.hdiff",
1254
+ "pdiff": "pkg-next.phdiff",
1255
+ "full": "next.ppk",
1256
+ "paths": [
1257
+ "cdn.example.com",
1258
+ "https://mirror.example.com/base/"
1259
+ ]
1260
+ },
1261
+ {
1262
+ "currentVersion": "current-hash",
1263
+ "rolledBackVersion": "bad-hash"
1264
+ },
1265
+ true
1266
+ ],
1267
+ "expected": {
1268
+ "action": "download",
1269
+ "hash": "next-hash",
1270
+ "attempts": [
1271
+ {
1272
+ "type": "full",
1273
+ "urls": [
1274
+ "https://cdn.example.com/next.ppk",
1275
+ "https://mirror.example.com/base/next.ppk"
1276
+ ]
1277
+ }
1278
+ ],
1279
+ "devNoop": false
1280
+ }
1281
+ },
1282
+ {
1283
+ "fn": "decideDownload",
1284
+ "args": [
1285
+ {
1286
+ "update": true,
1287
+ "hash": "next-hash",
1288
+ "diff": "cur-next.hdiff",
1289
+ "pdiff": "pkg-next.phdiff",
1290
+ "paths": [
1291
+ "cdn.example.com",
1292
+ "https://mirror.example.com/base/"
1293
+ ]
1294
+ },
1295
+ {
1296
+ "currentVersion": "current-hash",
1297
+ "rolledBackVersion": "bad-hash"
1298
+ },
1299
+ true
1300
+ ],
1301
+ "expected": {
1302
+ "action": "download",
1303
+ "hash": "next-hash",
1304
+ "attempts": [],
1305
+ "devNoop": true
1306
+ }
1307
+ },
1308
+ {
1309
+ "fn": "shouldActivateAfterDownload",
1310
+ "args": [
1311
+ {
1312
+ "hash": "x"
1313
+ },
1314
+ "setNeedUpdate"
1315
+ ],
1316
+ "expected": true
1317
+ },
1318
+ {
1319
+ "fn": "shouldActivateAfterDownload",
1320
+ "args": [
1321
+ {
1322
+ "hash": "x"
1323
+ },
1324
+ "none"
1325
+ ],
1326
+ "expected": false
1327
+ },
1328
+ {
1329
+ "fn": "shouldActivateAfterDownload",
1330
+ "args": [
1331
+ {
1332
+ "hash": "x",
1333
+ "config": {
1334
+ "forceBoot": true
1335
+ }
1336
+ },
1337
+ "none"
1338
+ ],
1339
+ "expected": true
1340
+ },
1341
+ {
1342
+ "fn": "shouldActivateAfterDownload",
1343
+ "args": [
1344
+ {
1345
+ "hash": "x",
1346
+ "config": {
1347
+ "forceBoot": false
1348
+ }
1349
+ },
1350
+ "none"
1351
+ ],
1352
+ "expected": false
1353
+ },
1354
+ {
1355
+ "fn": "shouldActivateAfterDownload",
1356
+ "args": [
1357
+ {
1358
+ "hash": "x",
1359
+ "config": {
1360
+ "forceBoot": 1
1361
+ }
1362
+ },
1363
+ "none"
1364
+ ],
1365
+ "expected": true
1366
+ },
1367
+ {
1368
+ "fn": "shouldActivateAfterDownload",
1369
+ "args": [
1370
+ {
1371
+ "hash": "x",
1372
+ "config": {}
1373
+ },
1374
+ "none"
1375
+ ],
1376
+ "expected": false
1377
+ },
1378
+ {
1379
+ "fn": "shouldActivateAfterDownload",
1380
+ "args": [
1381
+ {
1382
+ "hash": "x",
1383
+ "config": {
1384
+ "forceBoot": true
1385
+ }
1386
+ }
1387
+ ],
1388
+ "expected": true
1389
+ },
1390
+ {
1391
+ "fn": "shouldActivateAfterDownload",
1392
+ "args": [
1393
+ {
1394
+ "upToDate": true
1395
+ },
1396
+ "none"
1397
+ ],
1398
+ "expected": false
1399
+ }
1400
+ ]
1401
+ }