-
Notifications
You must be signed in to change notification settings - Fork 55
/
conversion_test.go
1652 lines (1581 loc) · 75.8 KB
/
conversion_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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// uint256: Fixed size 256-bit math library
// Copyright 2020 uint256 Authors
// SPDX-License-Identifier: BSD-3-Clause
package uint256
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"math/big"
"testing"
)
var (
_ fmt.Formatter = &Int{} // Test if Int supports Formatter interface.
)
func TestFromBig(t *testing.T) {
var a *big.Int
b, o := FromBig(a)
if o {
t.Fatalf("nil conversion overflowed! big.Int %x", b)
}
if b != nil {
t.Fatalf("got %x, exp %v", b, nil)
}
b2 := MustFromBig(a)
if b2 != nil {
t.Fatalf("got %x, exp %v", b2, nil)
}
a = new(big.Int)
b, o = FromBig(a)
if o {
t.Fatalf("conversion overflowed! big.Int %x", a.Bytes())
}
if exp, got := a.Bytes(), b.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
b2 = MustFromBig(a)
if exp, got := a.Bytes(), b2.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
a = big.NewInt(1)
b, o = FromBig(a)
if o {
t.Fatalf("conversion overflowed! big.Int %x", a.Bytes())
}
if exp, got := a.Bytes(), b.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
b2 = MustFromBig(a)
if exp, got := a.Bytes(), b2.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
a = big.NewInt(0x1000000000000000)
b, o = FromBig(a)
if o {
t.Fatalf("conversion overflowed! big.Int %x", a.Bytes())
}
if exp, got := a.Bytes(), b.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
b2 = MustFromBig(a)
if exp, got := a.Bytes(), b2.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
a = big.NewInt(0x1234)
b, o = FromBig(a)
if o {
t.Fatalf("conversion overflowed! big.Int %x", a.Bytes())
}
if exp, got := a.Bytes(), b.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
b2 = MustFromBig(a)
if exp, got := a.Bytes(), b2.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
a = big.NewInt(1)
a.Lsh(a, 256)
b, o = FromBig(a)
if !o {
t.Fatalf("expected overflow")
}
if !b.Eq(new(Int)) {
t.Fatalf("got %x exp 0", b.Bytes())
}
if !causesPanic(func() { MustFromBig(a) }) {
t.Fatalf("expected overflow")
}
a.Sub(a, big.NewInt(1))
b, o = FromBig(a)
if o {
t.Fatalf("conversion overflowed! big.Int %x", a.Bytes())
}
if exp, got := a.Bytes(), b.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
b2 = MustFromBig(a)
if exp, got := a.Bytes(), b2.Bytes(); !bytes.Equal(got, exp) {
t.Fatalf("got %x exp %x", got, exp)
}
}
func TestScanScientific(t *testing.T) {
intsub1 := new(Int)
_ = intsub1.fromDecimal(twoPow256Sub1)
cases := []struct {
in string
exp *Int
err string
}{
{
in: "",
exp: new(Int),
},
{
in: "e30",
err: "EOF",
},
{
in: "30e",
err: "EOF",
},
{
in: twoPow256Sub1 + "e",
err: "EOF",
},
{
in: "14e30",
exp: new(Int).Mul(NewInt(14), new(Int).Exp(NewInt(10), NewInt(30))),
},
{ // 0xdd15fe86affad800000000000000000000000000000000000000000000000000
in: "1e77",
exp: new(Int).Mul(NewInt(1), new(Int).Exp(NewInt(10), NewInt(77))),
},
{ // 0x8a2dbf142dfcc8000000000000000000000000000000000000000000000000000
in: "1e78",
err: ErrBig256Range.Error(),
},
{
in: "1455522523e31",
exp: new(Int).Mul(NewInt(1455522523), new(Int).Exp(NewInt(10), NewInt(31))),
},
{
in: twoPow256Sub1 + "e0",
exp: intsub1,
},
{
in: "1e25352",
err: ErrBig256Range.Error(),
},
{
in: "1213128763127863781263781263781263781263781263871263871268371268371263781627836128736128736127836127836127863781e0",
err: ErrBig256Range.Error(),
},
{
in: twoPow256Sub1 + "e1",
err: ErrBig256Range.Error(),
},
{
in: "1e253e52",
err: `strconv.ParseUint: parsing "253e52": invalid syntax`,
},
{
in: "1e00000000000000000",
exp: NewInt(1),
},
}
for tc, v := range cases {
have := ""
i := new(Int)
if err := i.Scan(v.in); err != nil {
have = err.Error()
}
if want := v.err; have != want {
t.Fatalf("test %d: wrong error, have '%s', want '%s'", tc, have, want)
}
if len(v.err) > 0 {
continue
}
if !v.exp.Eq(i) {
t.Fatalf("test %d: got %#x exp %#x", tc, i, v.exp)
}
}
}
func TestFromBigOverflow(t *testing.T) {
// Test overflow with error returns
b := new(big.Int).SetBytes(hex2Bytes("ababee444444444444ffcc333333333333ddaa222222222222bb8811111111111199"))
_, o := FromBig(b)
if !o {
t.Errorf("expected overflow, got %v", o)
}
// Test overflow with panic (recovery is a bit unwieldy)
if !causesPanic(func() { MustFromBig(b) }) {
t.Fatalf("expected overflow")
}
// Test no overflow
b = new(big.Int).SetBytes(hex2Bytes("ee444444444444ffcc333333333333ddaa222222222222bb8811111111111199"))
_, o = FromBig(b)
if o {
t.Errorf("expected no overflow, got %v", o)
}
MustFromBig(b)
b = new(big.Int).SetBytes(hex2Bytes("ee444444444444ffcc333333333333ddaa222222222222bb8811111111111199"))
b.Neg(b)
_, o = FromBig(b)
if o {
t.Errorf("expected no overflow, got %v", o)
}
MustFromBig(b)
}
func TestToBig(t *testing.T) {
var uint256Nil *Int
if bigNil := uint256Nil.ToBig(); bigNil != nil {
t.Errorf("want big.Int <nil>, have %x", bigNil)
}
if bigZero := new(Int).ToBig(); bigZero.Cmp(new(big.Int)) != 0 {
t.Errorf("expected big.Int 0, got %x", bigZero)
}
for i := uint(0); i < 256; i++ {
f := new(Int).SetUint64(1)
f.Lsh(f, i)
b := f.ToBig()
expected := big.NewInt(1)
expected.Lsh(expected, i)
if b.Cmp(expected) != 0 {
t.Fatalf("expected %x, got %x", expected, b)
}
}
}
func TestIntoBig(t *testing.T) {
var uint256Nil *Int
bigNil := new(big.Int)
if uint256Nil.IntoBig(&bigNil); bigNil != nil {
t.Errorf("want big.Int <nil>, have %x", bigNil)
}
var bigZero *big.Int
if new(Int).IntoBig(&bigZero); bigZero.Cmp(new(big.Int)) != 0 {
t.Errorf("expected big.Int 0, got %x", bigZero)
}
var b *big.Int
for i := uint(0); i < 256; i++ {
f := new(Int).SetUint64(1)
f.Lsh(f, i)
f.IntoBig(&b)
expected := big.NewInt(1)
expected.Lsh(expected, i)
if b.Cmp(expected) != 0 {
t.Fatalf("expected %x, got %x", expected, b)
}
}
}
func BenchmarkScanScientific(b *testing.B) {
intsub1 := new(Int)
_ = intsub1.fromDecimal(twoPow256Sub1)
cases := []struct {
in string
exp *Int
err string
}{
{
in: "14e30",
exp: new(Int).Mul(NewInt(14), new(Int).Exp(NewInt(10), NewInt(30))),
},
{
in: "1455522523e31",
exp: new(Int).Mul(NewInt(1455522523), new(Int).Exp(NewInt(10), NewInt(31))),
},
{
in: twoPow256Sub1 + "e0",
exp: intsub1,
},
{
in: "1e00000000000000000",
exp: NewInt(1),
},
}
i := new(Int)
b.ResetTimer()
for idx := 0; idx < b.N; idx++ {
for _, v := range cases {
_ = i.Scan(v.in)
}
}
}
func benchSetFromBig(bench *testing.B, b *big.Int) Int {
var f Int
for i := 0; i < bench.N; i++ {
f.SetFromBig(b)
}
return f
}
func BenchmarkSetFromBig(bench *testing.B) {
param1 := big.NewInt(0xff)
bench.Run("1word", func(bench *testing.B) { benchSetFromBig(bench, param1) })
param2 := new(big.Int).Lsh(param1, 64)
bench.Run("2words", func(bench *testing.B) { benchSetFromBig(bench, param2) })
param3 := new(big.Int).Lsh(param2, 64)
bench.Run("3words", func(bench *testing.B) { benchSetFromBig(bench, param3) })
param4 := new(big.Int).Lsh(param3, 64)
bench.Run("4words", func(bench *testing.B) { benchSetFromBig(bench, param4) })
param5 := new(big.Int).Lsh(param4, 64)
bench.Run("overflow", func(bench *testing.B) { benchSetFromBig(bench, param5) })
}
func benchToBig(bench *testing.B, f *Int) *big.Int {
var b *big.Int
for i := 0; i < bench.N; i++ {
b = f.ToBig()
}
return b
}
func BenchmarkToBig(bench *testing.B) {
param1 := new(Int).SetUint64(0xff)
bench.Run("1word", func(bench *testing.B) { benchToBig(bench, param1) })
param2 := new(Int).Lsh(param1, 64)
bench.Run("2words", func(bench *testing.B) { benchToBig(bench, param2) })
param3 := new(Int).Lsh(param2, 64)
bench.Run("3words", func(bench *testing.B) { benchToBig(bench, param3) })
param4 := new(Int).Lsh(param3, 64)
bench.Run("4words", func(bench *testing.B) { benchToBig(bench, param4) })
}
func benchIntoBig(bench *testing.B, f *Int) *big.Int {
var b *big.Int
for i := 0; i < bench.N; i++ {
f.IntoBig(&b)
}
return b
}
func BenchmarkIntoBig(bench *testing.B) {
param1 := new(Int).SetUint64(0xff)
bench.Run("1word", func(bench *testing.B) { benchIntoBig(bench, param1) })
param2 := new(Int).Lsh(param1, 64)
bench.Run("2words", func(bench *testing.B) { benchIntoBig(bench, param2) })
param3 := new(Int).Lsh(param2, 64)
bench.Run("3words", func(bench *testing.B) { benchIntoBig(bench, param3) })
param4 := new(Int).Lsh(param3, 64)
bench.Run("4words", func(bench *testing.B) { benchIntoBig(bench, param4) })
}
func TestFormat(t *testing.T) {
testCases := []string{
"0",
"1",
"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221100",
}
for i := 0; i < len(testCases); i++ {
expected := testCases[i]
b, _ := new(big.Int).SetString(expected, 16)
f, o := FromBig(b)
if o {
t.Fatalf("too big test case %s", expected)
}
s := fmt.Sprintf("%x", f)
if s != expected {
t.Errorf("Invalid format conversion to hex: %s, expected %s", s, expected)
}
}
}
// TestSetBytes tests all setbyte-methods from 0 to overlong,
// - verifies that all non-set bits are properly cleared
// - verifies that overlong input is correctly cropped
func TestSetBytes(t *testing.T) {
for i := 0; i < 35; i++ {
buf := hex2Bytes("aaaa12131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031bbbb")
exp, _ := FromBig(new(big.Int).SetBytes(buf[0:i]))
z := new(Int).SetAllOne().SetBytes(buf[0:i])
if !z.Eq(exp) {
t.Errorf("testcase %d: exp %x, got %x", i, exp, z)
}
}
// nil check
exp, _ := FromBig(new(big.Int).SetBytes(nil))
z := new(Int).SetAllOne().SetBytes(nil)
if !z.Eq(exp) {
t.Errorf("nil-test : exp %x, got %x", exp, z)
}
}
func BenchmarkSetBytes(b *testing.B) {
val := new(Int)
bytearr := hex2Bytes("12131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031")
b.Run("generic", func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
val.SetBytes(bytearr[:1])
val.SetBytes(bytearr[:2])
val.SetBytes(bytearr[:3])
val.SetBytes(bytearr[:4])
val.SetBytes(bytearr[:5])
val.SetBytes(bytearr[:6])
val.SetBytes(bytearr[:7])
val.SetBytes(bytearr[:8])
val.SetBytes(bytearr[:9])
val.SetBytes(bytearr[:10])
val.SetBytes(bytearr[:11])
val.SetBytes(bytearr[:12])
val.SetBytes(bytearr[:13])
val.SetBytes(bytearr[:14])
val.SetBytes(bytearr[:15])
val.SetBytes(bytearr[:16])
val.SetBytes(bytearr[:17])
val.SetBytes(bytearr[:18])
val.SetBytes(bytearr[:19])
val.SetBytes(bytearr[:20])
val.SetBytes(bytearr[:21])
val.SetBytes(bytearr[:22])
val.SetBytes(bytearr[:23])
val.SetBytes(bytearr[:24])
val.SetBytes(bytearr[:25])
val.SetBytes(bytearr[:26])
val.SetBytes(bytearr[:27])
val.SetBytes(bytearr[:28])
val.SetBytes(bytearr[:29])
val.SetBytes(bytearr[:30])
val.SetBytes(bytearr[:31])
val.SetBytes(bytearr[:32])
}
})
b.Run("specific", func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
val.SetBytes1(bytearr)
val.SetBytes2(bytearr)
val.SetBytes3(bytearr)
val.SetBytes4(bytearr)
val.SetBytes5(bytearr)
val.SetBytes6(bytearr)
val.SetBytes7(bytearr)
val.SetBytes8(bytearr)
val.SetBytes9(bytearr)
val.SetBytes10(bytearr)
val.SetBytes11(bytearr)
val.SetBytes12(bytearr)
val.SetBytes13(bytearr)
val.SetBytes14(bytearr)
val.SetBytes15(bytearr)
val.SetBytes16(bytearr)
val.SetBytes17(bytearr)
val.SetBytes18(bytearr)
val.SetBytes19(bytearr)
val.SetBytes20(bytearr)
val.SetBytes21(bytearr)
val.SetBytes22(bytearr)
val.SetBytes23(bytearr)
val.SetBytes24(bytearr)
val.SetBytes25(bytearr)
val.SetBytes26(bytearr)
val.SetBytes27(bytearr)
val.SetBytes28(bytearr)
val.SetBytes29(bytearr)
val.SetBytes30(bytearr)
val.SetBytes31(bytearr)
val.SetBytes32(bytearr)
}
})
}
func TestSSZEncodeDecodeHash(t *testing.T) {
type testcase struct {
val string
exp string
}
for i, tt := range []testcase{
{"", "0000000000000000000000000000000000000000000000000000000000000000"},
{"01", "0100000000000000000000000000000000000000000000000000000000000000"},
{"02", "0200000000000000000000000000000000000000000000000000000000000000"},
{"04", "0400000000000000000000000000000000000000000000000000000000000000"},
{"08", "0800000000000000000000000000000000000000000000000000000000000000"},
{"10", "1000000000000000000000000000000000000000000000000000000000000000"},
{"20", "2000000000000000000000000000000000000000000000000000000000000000"},
{"40", "4000000000000000000000000000000000000000000000000000000000000000"},
{"80", "8000000000000000000000000000000000000000000000000000000000000000"},
{"0100", "0001000000000000000000000000000000000000000000000000000000000000"},
{"0200", "0002000000000000000000000000000000000000000000000000000000000000"},
{"0400", "0004000000000000000000000000000000000000000000000000000000000000"},
{"0800", "0008000000000000000000000000000000000000000000000000000000000000"},
{"1000", "0010000000000000000000000000000000000000000000000000000000000000"},
{"2000", "0020000000000000000000000000000000000000000000000000000000000000"},
{"4000", "0040000000000000000000000000000000000000000000000000000000000000"},
{"8000", "0080000000000000000000000000000000000000000000000000000000000000"},
{"010000", "0000010000000000000000000000000000000000000000000000000000000000"},
{"020000", "0000020000000000000000000000000000000000000000000000000000000000"},
{"040000", "0000040000000000000000000000000000000000000000000000000000000000"},
{"080000", "0000080000000000000000000000000000000000000000000000000000000000"},
{"100000", "0000100000000000000000000000000000000000000000000000000000000000"},
{"200000", "0000200000000000000000000000000000000000000000000000000000000000"},
{"400000", "0000400000000000000000000000000000000000000000000000000000000000"},
{"800000", "0000800000000000000000000000000000000000000000000000000000000000"},
{"01000000", "0000000100000000000000000000000000000000000000000000000000000000"},
{"02000000", "0000000200000000000000000000000000000000000000000000000000000000"},
{"04000000", "0000000400000000000000000000000000000000000000000000000000000000"},
{"08000000", "0000000800000000000000000000000000000000000000000000000000000000"},
{"10000000", "0000001000000000000000000000000000000000000000000000000000000000"},
{"20000000", "0000002000000000000000000000000000000000000000000000000000000000"},
{"40000000", "0000004000000000000000000000000000000000000000000000000000000000"},
{"80000000", "0000008000000000000000000000000000000000000000000000000000000000"},
{"0100000000", "0000000001000000000000000000000000000000000000000000000000000000"},
{"0200000000", "0000000002000000000000000000000000000000000000000000000000000000"},
{"0400000000", "0000000004000000000000000000000000000000000000000000000000000000"},
{"0800000000", "0000000008000000000000000000000000000000000000000000000000000000"},
{"1000000000", "0000000010000000000000000000000000000000000000000000000000000000"},
{"2000000000", "0000000020000000000000000000000000000000000000000000000000000000"},
{"4000000000", "0000000040000000000000000000000000000000000000000000000000000000"},
{"8000000000", "0000000080000000000000000000000000000000000000000000000000000000"},
{"010000000000", "0000000000010000000000000000000000000000000000000000000000000000"},
{"020000000000", "0000000000020000000000000000000000000000000000000000000000000000"},
{"040000000000", "0000000000040000000000000000000000000000000000000000000000000000"},
{"080000000000", "0000000000080000000000000000000000000000000000000000000000000000"},
{"100000000000", "0000000000100000000000000000000000000000000000000000000000000000"},
{"200000000000", "0000000000200000000000000000000000000000000000000000000000000000"},
{"400000000000", "0000000000400000000000000000000000000000000000000000000000000000"},
{"800000000000", "0000000000800000000000000000000000000000000000000000000000000000"},
{"01000000000000", "0000000000000100000000000000000000000000000000000000000000000000"},
{"02000000000000", "0000000000000200000000000000000000000000000000000000000000000000"},
{"04000000000000", "0000000000000400000000000000000000000000000000000000000000000000"},
{"08000000000000", "0000000000000800000000000000000000000000000000000000000000000000"},
{"10000000000000", "0000000000001000000000000000000000000000000000000000000000000000"},
{"20000000000000", "0000000000002000000000000000000000000000000000000000000000000000"},
{"40000000000000", "0000000000004000000000000000000000000000000000000000000000000000"},
{"80000000000000", "0000000000008000000000000000000000000000000000000000000000000000"},
{"0100000000000000", "0000000000000001000000000000000000000000000000000000000000000000"},
{"0200000000000000", "0000000000000002000000000000000000000000000000000000000000000000"},
{"0400000000000000", "0000000000000004000000000000000000000000000000000000000000000000"},
{"0800000000000000", "0000000000000008000000000000000000000000000000000000000000000000"},
{"1000000000000000", "0000000000000010000000000000000000000000000000000000000000000000"},
{"2000000000000000", "0000000000000020000000000000000000000000000000000000000000000000"},
{"4000000000000000", "0000000000000040000000000000000000000000000000000000000000000000"},
{"8000000000000000", "0000000000000080000000000000000000000000000000000000000000000000"},
{"010000000000000000", "0000000000000000010000000000000000000000000000000000000000000000"},
{"020000000000000000", "0000000000000000020000000000000000000000000000000000000000000000"},
{"040000000000000000", "0000000000000000040000000000000000000000000000000000000000000000"},
{"080000000000000000", "0000000000000000080000000000000000000000000000000000000000000000"},
{"100000000000000000", "0000000000000000100000000000000000000000000000000000000000000000"},
{"200000000000000000", "0000000000000000200000000000000000000000000000000000000000000000"},
{"400000000000000000", "0000000000000000400000000000000000000000000000000000000000000000"},
{"800000000000000000", "0000000000000000800000000000000000000000000000000000000000000000"},
{"01000000000000000000", "0000000000000000000100000000000000000000000000000000000000000000"},
{"02000000000000000000", "0000000000000000000200000000000000000000000000000000000000000000"},
{"04000000000000000000", "0000000000000000000400000000000000000000000000000000000000000000"},
{"08000000000000000000", "0000000000000000000800000000000000000000000000000000000000000000"},
{"10000000000000000000", "0000000000000000001000000000000000000000000000000000000000000000"},
{"20000000000000000000", "0000000000000000002000000000000000000000000000000000000000000000"},
{"40000000000000000000", "0000000000000000004000000000000000000000000000000000000000000000"},
{"80000000000000000000", "0000000000000000008000000000000000000000000000000000000000000000"},
{"0100000000000000000000", "0000000000000000000001000000000000000000000000000000000000000000"},
{"0200000000000000000000", "0000000000000000000002000000000000000000000000000000000000000000"},
{"0400000000000000000000", "0000000000000000000004000000000000000000000000000000000000000000"},
{"0800000000000000000000", "0000000000000000000008000000000000000000000000000000000000000000"},
{"1000000000000000000000", "0000000000000000000010000000000000000000000000000000000000000000"},
{"2000000000000000000000", "0000000000000000000020000000000000000000000000000000000000000000"},
{"4000000000000000000000", "0000000000000000000040000000000000000000000000000000000000000000"},
{"8000000000000000000000", "0000000000000000000080000000000000000000000000000000000000000000"},
{"010000000000000000000000", "0000000000000000000000010000000000000000000000000000000000000000"},
{"020000000000000000000000", "0000000000000000000000020000000000000000000000000000000000000000"},
{"040000000000000000000000", "0000000000000000000000040000000000000000000000000000000000000000"},
{"080000000000000000000000", "0000000000000000000000080000000000000000000000000000000000000000"},
{"100000000000000000000000", "0000000000000000000000100000000000000000000000000000000000000000"},
{"200000000000000000000000", "0000000000000000000000200000000000000000000000000000000000000000"},
{"400000000000000000000000", "0000000000000000000000400000000000000000000000000000000000000000"},
{"800000000000000000000000", "0000000000000000000000800000000000000000000000000000000000000000"},
{"01000000000000000000000000", "0000000000000000000000000100000000000000000000000000000000000000"},
{"02000000000000000000000000", "0000000000000000000000000200000000000000000000000000000000000000"},
{"04000000000000000000000000", "0000000000000000000000000400000000000000000000000000000000000000"},
{"08000000000000000000000000", "0000000000000000000000000800000000000000000000000000000000000000"},
{"10000000000000000000000000", "0000000000000000000000001000000000000000000000000000000000000000"},
{"20000000000000000000000000", "0000000000000000000000002000000000000000000000000000000000000000"},
{"40000000000000000000000000", "0000000000000000000000004000000000000000000000000000000000000000"},
{"80000000000000000000000000", "0000000000000000000000008000000000000000000000000000000000000000"},
{"0100000000000000000000000000", "0000000000000000000000000001000000000000000000000000000000000000"},
{"0200000000000000000000000000", "0000000000000000000000000002000000000000000000000000000000000000"},
{"0400000000000000000000000000", "0000000000000000000000000004000000000000000000000000000000000000"},
{"0800000000000000000000000000", "0000000000000000000000000008000000000000000000000000000000000000"},
{"1000000000000000000000000000", "0000000000000000000000000010000000000000000000000000000000000000"},
{"2000000000000000000000000000", "0000000000000000000000000020000000000000000000000000000000000000"},
{"4000000000000000000000000000", "0000000000000000000000000040000000000000000000000000000000000000"},
{"8000000000000000000000000000", "0000000000000000000000000080000000000000000000000000000000000000"},
{"010000000000000000000000000000", "0000000000000000000000000000010000000000000000000000000000000000"},
{"020000000000000000000000000000", "0000000000000000000000000000020000000000000000000000000000000000"},
{"040000000000000000000000000000", "0000000000000000000000000000040000000000000000000000000000000000"},
{"080000000000000000000000000000", "0000000000000000000000000000080000000000000000000000000000000000"},
{"100000000000000000000000000000", "0000000000000000000000000000100000000000000000000000000000000000"},
{"200000000000000000000000000000", "0000000000000000000000000000200000000000000000000000000000000000"},
{"400000000000000000000000000000", "0000000000000000000000000000400000000000000000000000000000000000"},
{"800000000000000000000000000000", "0000000000000000000000000000800000000000000000000000000000000000"},
{"01000000000000000000000000000000", "0000000000000000000000000000000100000000000000000000000000000000"},
{"02000000000000000000000000000000", "0000000000000000000000000000000200000000000000000000000000000000"},
{"04000000000000000000000000000000", "0000000000000000000000000000000400000000000000000000000000000000"},
{"08000000000000000000000000000000", "0000000000000000000000000000000800000000000000000000000000000000"},
{"10000000000000000000000000000000", "0000000000000000000000000000001000000000000000000000000000000000"},
{"20000000000000000000000000000000", "0000000000000000000000000000002000000000000000000000000000000000"},
{"40000000000000000000000000000000", "0000000000000000000000000000004000000000000000000000000000000000"},
{"80000000000000000000000000000000", "0000000000000000000000000000008000000000000000000000000000000000"},
{"0100000000000000000000000000000000", "0000000000000000000000000000000001000000000000000000000000000000"},
{"0200000000000000000000000000000000", "0000000000000000000000000000000002000000000000000000000000000000"},
{"0400000000000000000000000000000000", "0000000000000000000000000000000004000000000000000000000000000000"},
{"0800000000000000000000000000000000", "0000000000000000000000000000000008000000000000000000000000000000"},
{"1000000000000000000000000000000000", "0000000000000000000000000000000010000000000000000000000000000000"},
{"2000000000000000000000000000000000", "0000000000000000000000000000000020000000000000000000000000000000"},
{"4000000000000000000000000000000000", "0000000000000000000000000000000040000000000000000000000000000000"},
{"8000000000000000000000000000000000", "0000000000000000000000000000000080000000000000000000000000000000"},
{"010000000000000000000000000000000000", "0000000000000000000000000000000000010000000000000000000000000000"},
{"020000000000000000000000000000000000", "0000000000000000000000000000000000020000000000000000000000000000"},
{"040000000000000000000000000000000000", "0000000000000000000000000000000000040000000000000000000000000000"},
{"080000000000000000000000000000000000", "0000000000000000000000000000000000080000000000000000000000000000"},
{"100000000000000000000000000000000000", "0000000000000000000000000000000000100000000000000000000000000000"},
{"200000000000000000000000000000000000", "0000000000000000000000000000000000200000000000000000000000000000"},
{"400000000000000000000000000000000000", "0000000000000000000000000000000000400000000000000000000000000000"},
{"800000000000000000000000000000000000", "0000000000000000000000000000000000800000000000000000000000000000"},
{"01000000000000000000000000000000000000", "0000000000000000000000000000000000000100000000000000000000000000"},
{"02000000000000000000000000000000000000", "0000000000000000000000000000000000000200000000000000000000000000"},
{"04000000000000000000000000000000000000", "0000000000000000000000000000000000000400000000000000000000000000"},
{"08000000000000000000000000000000000000", "0000000000000000000000000000000000000800000000000000000000000000"},
{"10000000000000000000000000000000000000", "0000000000000000000000000000000000001000000000000000000000000000"},
{"20000000000000000000000000000000000000", "0000000000000000000000000000000000002000000000000000000000000000"},
{"40000000000000000000000000000000000000", "0000000000000000000000000000000000004000000000000000000000000000"},
{"80000000000000000000000000000000000000", "0000000000000000000000000000000000008000000000000000000000000000"},
{"0100000000000000000000000000000000000000", "0000000000000000000000000000000000000001000000000000000000000000"},
{"0200000000000000000000000000000000000000", "0000000000000000000000000000000000000002000000000000000000000000"},
{"0400000000000000000000000000000000000000", "0000000000000000000000000000000000000004000000000000000000000000"},
{"0800000000000000000000000000000000000000", "0000000000000000000000000000000000000008000000000000000000000000"},
{"1000000000000000000000000000000000000000", "0000000000000000000000000000000000000010000000000000000000000000"},
{"2000000000000000000000000000000000000000", "0000000000000000000000000000000000000020000000000000000000000000"},
{"4000000000000000000000000000000000000000", "0000000000000000000000000000000000000040000000000000000000000000"},
{"8000000000000000000000000000000000000000", "0000000000000000000000000000000000000080000000000000000000000000"},
{"010000000000000000000000000000000000000000", "0000000000000000000000000000000000000000010000000000000000000000"},
{"020000000000000000000000000000000000000000", "0000000000000000000000000000000000000000020000000000000000000000"},
{"040000000000000000000000000000000000000000", "0000000000000000000000000000000000000000040000000000000000000000"},
{"080000000000000000000000000000000000000000", "0000000000000000000000000000000000000000080000000000000000000000"},
{"100000000000000000000000000000000000000000", "0000000000000000000000000000000000000000100000000000000000000000"},
{"200000000000000000000000000000000000000000", "0000000000000000000000000000000000000000200000000000000000000000"},
{"400000000000000000000000000000000000000000", "0000000000000000000000000000000000000000400000000000000000000000"},
{"800000000000000000000000000000000000000000", "0000000000000000000000000000000000000000800000000000000000000000"},
{"01000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000100000000000000000000"},
{"02000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000200000000000000000000"},
{"04000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000400000000000000000000"},
{"08000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000800000000000000000000"},
{"10000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000001000000000000000000000"},
{"20000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000002000000000000000000000"},
{"40000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000004000000000000000000000"},
{"80000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000008000000000000000000000"},
{"0100000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000001000000000000000000"},
{"0200000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000002000000000000000000"},
{"0400000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000004000000000000000000"},
{"0800000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000008000000000000000000"},
{"1000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000010000000000000000000"},
{"2000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000020000000000000000000"},
{"4000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000040000000000000000000"},
{"8000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000080000000000000000000"},
{"010000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000010000000000000000"},
{"020000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000020000000000000000"},
{"040000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000040000000000000000"},
{"080000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000080000000000000000"},
{"100000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000100000000000000000"},
{"200000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000200000000000000000"},
{"400000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000400000000000000000"},
{"800000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000800000000000000000"},
{"01000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000100000000000000"},
{"02000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000200000000000000"},
{"04000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000400000000000000"},
{"08000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000800000000000000"},
{"10000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000001000000000000000"},
{"20000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000002000000000000000"},
{"40000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000004000000000000000"},
{"80000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000008000000000000000"},
{"0100000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000001000000000000"},
{"0200000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000002000000000000"},
{"0400000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000004000000000000"},
{"0800000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000008000000000000"},
{"1000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000010000000000000"},
{"2000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000020000000000000"},
{"4000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000040000000000000"},
{"8000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000080000000000000"},
{"010000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000010000000000"},
{"020000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000020000000000"},
{"040000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000040000000000"},
{"080000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000080000000000"},
{"100000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000100000000000"},
{"200000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000200000000000"},
{"400000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000400000000000"},
{"800000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000800000000000"},
{"01000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000100000000"},
{"02000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000200000000"},
{"04000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000400000000"},
{"08000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000800000000"},
{"10000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000001000000000"},
{"20000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000002000000000"},
{"40000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000004000000000"},
{"80000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000008000000000"},
{"0100000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000001000000"},
{"0200000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000002000000"},
{"0400000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000004000000"},
{"0800000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000008000000"},
{"1000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000010000000"},
{"2000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000020000000"},
{"4000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000040000000"},
{"8000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000080000000"},
{"010000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000010000"},
{"020000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000020000"},
{"040000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000040000"},
{"080000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000080000"},
{"100000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000100000"},
{"200000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000200000"},
{"400000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000400000"},
{"800000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000800000"},
{"01000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000100"},
{"02000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000200"},
{"04000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000400"},
{"08000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000800"},
{"10000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000001000"},
{"20000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000002000"},
{"40000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000004000"},
{"80000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000008000"},
{"0100000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000001"},
{"0200000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000002"},
{"0400000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000004"},
{"0800000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000008"},
{"1000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000010"},
{"2000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000020"},
{"4000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000040"},
{"8000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000080"},
} {
z := new(Int).SetBytes(hex2Bytes(tt.val))
if s := z.SizeSSZ(); s != 32 {
t.Errorf("testcase %d, size got: %d, exp: %d", i, s, 32)
}
b, err := z.MarshalSSZ()
if err != nil {
t.Fatal(err)
}
if exp := hex2Bytes(tt.exp); !bytes.Equal(b, exp) {
t.Errorf("testcase %d, encoding\nhave: %x\nwant: %x\n", i, b, exp)
}
z2 := new(Int)
if err := z2.UnmarshalSSZ(b); err != nil {
t.Fatal(err)
}
if !z2.Eq(z) {
t.Errorf("testcase %d, decoding got:\n%v\nexp:%v\n", i, z2, z)
}
r, err := z.HashTreeRoot()
if err != nil {
t.Fatal(err)
}
if exp := hex2Bytes(tt.exp); !bytes.Equal(r[:], exp) {
t.Errorf("testcase %d, hashing\nhave: %x\nwant: %x\n", i, r, exp)
}
}
}
func TestSSZEncodeDecodeErrors(t *testing.T) {
small := make([]byte, 31)
if _, err := new(Int).MarshalSSZInto(small); !errors.Is(err, ErrBadBufferLength) {
t.Fatalf("overflow marshal error mismatch: have %v, want %v", err, ErrBadBufferLength)
}
if err := new(Int).UnmarshalSSZ(small); !errors.Is(err, ErrBadEncodedLength) {
t.Fatalf("underflow unmarshal error mismatch: have %v, want %v", err, ErrBadEncodedLength)
}
large := make([]byte, 33)
if _, err := new(Int).MarshalSSZAppend(large); err != nil {
t.Fatalf("underflow marshal error mismatch: have %v, want %v", err, nil)
}
if err := new(Int).UnmarshalSSZ(large); !errors.Is(err, ErrBadEncodedLength) {
t.Fatalf("overflow unmarshal error mismatch: have %v, want %v", err, ErrBadEncodedLength)
}
if _, err := new(Int).MarshalSSZInto(large); err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
func TestRLPEncode(t *testing.T) {
type testcase struct {
val string
exp string
}
for i, tt := range []testcase{
{"", "80"},
{"01", "01"},
{"02", "02"},
{"04", "04"},
{"08", "08"},
{"10", "10"},
{"20", "20"},
{"40", "40"},
{"80", "8180"},
{"0100", "820100"},
{"0200", "820200"},
{"0400", "820400"},
{"0800", "820800"},
{"1000", "821000"},
{"2000", "822000"},
{"4000", "824000"},
{"8000", "828000"},
{"010000", "83010000"},
{"020000", "83020000"},
{"040000", "83040000"},
{"080000", "83080000"},
{"100000", "83100000"},
{"200000", "83200000"},
{"400000", "83400000"},
{"800000", "83800000"},
{"01000000", "8401000000"},
{"02000000", "8402000000"},
{"04000000", "8404000000"},
{"08000000", "8408000000"},
{"10000000", "8410000000"},
{"20000000", "8420000000"},
{"40000000", "8440000000"},
{"80000000", "8480000000"},
{"0100000000", "850100000000"},
{"0200000000", "850200000000"},
{"0400000000", "850400000000"},
{"0800000000", "850800000000"},
{"1000000000", "851000000000"},
{"2000000000", "852000000000"},
{"4000000000", "854000000000"},
{"8000000000", "858000000000"},
{"010000000000", "86010000000000"},
{"020000000000", "86020000000000"},
{"040000000000", "86040000000000"},
{"080000000000", "86080000000000"},
{"100000000000", "86100000000000"},
{"200000000000", "86200000000000"},
{"400000000000", "86400000000000"},
{"800000000000", "86800000000000"},
{"01000000000000", "8701000000000000"},
{"02000000000000", "8702000000000000"},
{"04000000000000", "8704000000000000"},
{"08000000000000", "8708000000000000"},
{"10000000000000", "8710000000000000"},
{"20000000000000", "8720000000000000"},
{"40000000000000", "8740000000000000"},
{"80000000000000", "8780000000000000"},
{"0100000000000000", "880100000000000000"},
{"0200000000000000", "880200000000000000"},
{"0400000000000000", "880400000000000000"},
{"0800000000000000", "880800000000000000"},
{"1000000000000000", "881000000000000000"},
{"2000000000000000", "882000000000000000"},
{"4000000000000000", "884000000000000000"},
{"8000000000000000", "888000000000000000"},
{"010000000000000000", "89010000000000000000"},
{"020000000000000000", "89020000000000000000"},
{"040000000000000000", "89040000000000000000"},
{"080000000000000000", "89080000000000000000"},
{"100000000000000000", "89100000000000000000"},
{"200000000000000000", "89200000000000000000"},
{"400000000000000000", "89400000000000000000"},
{"800000000000000000", "89800000000000000000"},
{"01000000000000000000", "8a01000000000000000000"},
{"02000000000000000000", "8a02000000000000000000"},
{"04000000000000000000", "8a04000000000000000000"},
{"08000000000000000000", "8a08000000000000000000"},
{"10000000000000000000", "8a10000000000000000000"},
{"20000000000000000000", "8a20000000000000000000"},
{"40000000000000000000", "8a40000000000000000000"},
{"80000000000000000000", "8a80000000000000000000"},
{"0100000000000000000000", "8b0100000000000000000000"},
{"0200000000000000000000", "8b0200000000000000000000"},
{"0400000000000000000000", "8b0400000000000000000000"},
{"0800000000000000000000", "8b0800000000000000000000"},
{"1000000000000000000000", "8b1000000000000000000000"},
{"2000000000000000000000", "8b2000000000000000000000"},
{"4000000000000000000000", "8b4000000000000000000000"},
{"8000000000000000000000", "8b8000000000000000000000"},
{"010000000000000000000000", "8c010000000000000000000000"},
{"020000000000000000000000", "8c020000000000000000000000"},
{"040000000000000000000000", "8c040000000000000000000000"},
{"080000000000000000000000", "8c080000000000000000000000"},
{"100000000000000000000000", "8c100000000000000000000000"},
{"200000000000000000000000", "8c200000000000000000000000"},
{"400000000000000000000000", "8c400000000000000000000000"},
{"800000000000000000000000", "8c800000000000000000000000"},
{"01000000000000000000000000", "8d01000000000000000000000000"},
{"02000000000000000000000000", "8d02000000000000000000000000"},
{"04000000000000000000000000", "8d04000000000000000000000000"},
{"08000000000000000000000000", "8d08000000000000000000000000"},
{"10000000000000000000000000", "8d10000000000000000000000000"},
{"20000000000000000000000000", "8d20000000000000000000000000"},
{"40000000000000000000000000", "8d40000000000000000000000000"},
{"80000000000000000000000000", "8d80000000000000000000000000"},
{"0100000000000000000000000000", "8e0100000000000000000000000000"},
{"0200000000000000000000000000", "8e0200000000000000000000000000"},
{"0400000000000000000000000000", "8e0400000000000000000000000000"},
{"0800000000000000000000000000", "8e0800000000000000000000000000"},
{"1000000000000000000000000000", "8e1000000000000000000000000000"},
{"2000000000000000000000000000", "8e2000000000000000000000000000"},
{"4000000000000000000000000000", "8e4000000000000000000000000000"},
{"8000000000000000000000000000", "8e8000000000000000000000000000"},
{"010000000000000000000000000000", "8f010000000000000000000000000000"},
{"020000000000000000000000000000", "8f020000000000000000000000000000"},
{"040000000000000000000000000000", "8f040000000000000000000000000000"},
{"080000000000000000000000000000", "8f080000000000000000000000000000"},
{"100000000000000000000000000000", "8f100000000000000000000000000000"},
{"200000000000000000000000000000", "8f200000000000000000000000000000"},
{"400000000000000000000000000000", "8f400000000000000000000000000000"},
{"800000000000000000000000000000", "8f800000000000000000000000000000"},
{"01000000000000000000000000000000", "9001000000000000000000000000000000"},
{"02000000000000000000000000000000", "9002000000000000000000000000000000"},
{"04000000000000000000000000000000", "9004000000000000000000000000000000"},
{"08000000000000000000000000000000", "9008000000000000000000000000000000"},
{"10000000000000000000000000000000", "9010000000000000000000000000000000"},
{"20000000000000000000000000000000", "9020000000000000000000000000000000"},
{"40000000000000000000000000000000", "9040000000000000000000000000000000"},
{"80000000000000000000000000000000", "9080000000000000000000000000000000"},
{"0100000000000000000000000000000000", "910100000000000000000000000000000000"},
{"0200000000000000000000000000000000", "910200000000000000000000000000000000"},
{"0400000000000000000000000000000000", "910400000000000000000000000000000000"},
{"0800000000000000000000000000000000", "910800000000000000000000000000000000"},
{"1000000000000000000000000000000000", "911000000000000000000000000000000000"},
{"2000000000000000000000000000000000", "912000000000000000000000000000000000"},
{"4000000000000000000000000000000000", "914000000000000000000000000000000000"},
{"8000000000000000000000000000000000", "918000000000000000000000000000000000"},
{"010000000000000000000000000000000000", "92010000000000000000000000000000000000"},
{"020000000000000000000000000000000000", "92020000000000000000000000000000000000"},
{"040000000000000000000000000000000000", "92040000000000000000000000000000000000"},
{"080000000000000000000000000000000000", "92080000000000000000000000000000000000"},
{"100000000000000000000000000000000000", "92100000000000000000000000000000000000"},
{"200000000000000000000000000000000000", "92200000000000000000000000000000000000"},
{"400000000000000000000000000000000000", "92400000000000000000000000000000000000"},
{"800000000000000000000000000000000000", "92800000000000000000000000000000000000"},
{"01000000000000000000000000000000000000", "9301000000000000000000000000000000000000"},
{"02000000000000000000000000000000000000", "9302000000000000000000000000000000000000"},
{"04000000000000000000000000000000000000", "9304000000000000000000000000000000000000"},
{"08000000000000000000000000000000000000", "9308000000000000000000000000000000000000"},
{"10000000000000000000000000000000000000", "9310000000000000000000000000000000000000"},
{"20000000000000000000000000000000000000", "9320000000000000000000000000000000000000"},
{"40000000000000000000000000000000000000", "9340000000000000000000000000000000000000"},
{"80000000000000000000000000000000000000", "9380000000000000000000000000000000000000"},
{"0100000000000000000000000000000000000000", "940100000000000000000000000000000000000000"},
{"0200000000000000000000000000000000000000", "940200000000000000000000000000000000000000"},
{"0400000000000000000000000000000000000000", "940400000000000000000000000000000000000000"},
{"0800000000000000000000000000000000000000", "940800000000000000000000000000000000000000"},
{"1000000000000000000000000000000000000000", "941000000000000000000000000000000000000000"},
{"2000000000000000000000000000000000000000", "942000000000000000000000000000000000000000"},
{"4000000000000000000000000000000000000000", "944000000000000000000000000000000000000000"},
{"8000000000000000000000000000000000000000", "948000000000000000000000000000000000000000"},
{"010000000000000000000000000000000000000000", "95010000000000000000000000000000000000000000"},
{"020000000000000000000000000000000000000000", "95020000000000000000000000000000000000000000"},
{"040000000000000000000000000000000000000000", "95040000000000000000000000000000000000000000"},
{"080000000000000000000000000000000000000000", "95080000000000000000000000000000000000000000"},
{"100000000000000000000000000000000000000000", "95100000000000000000000000000000000000000000"},
{"200000000000000000000000000000000000000000", "95200000000000000000000000000000000000000000"},
{"400000000000000000000000000000000000000000", "95400000000000000000000000000000000000000000"},
{"800000000000000000000000000000000000000000", "95800000000000000000000000000000000000000000"},
{"01000000000000000000000000000000000000000000", "9601000000000000000000000000000000000000000000"},
{"02000000000000000000000000000000000000000000", "9602000000000000000000000000000000000000000000"},
{"04000000000000000000000000000000000000000000", "9604000000000000000000000000000000000000000000"},
{"08000000000000000000000000000000000000000000", "9608000000000000000000000000000000000000000000"},
{"10000000000000000000000000000000000000000000", "9610000000000000000000000000000000000000000000"},
{"20000000000000000000000000000000000000000000", "9620000000000000000000000000000000000000000000"},
{"40000000000000000000000000000000000000000000", "9640000000000000000000000000000000000000000000"},
{"80000000000000000000000000000000000000000000", "9680000000000000000000000000000000000000000000"},
{"0100000000000000000000000000000000000000000000", "970100000000000000000000000000000000000000000000"},
{"0200000000000000000000000000000000000000000000", "970200000000000000000000000000000000000000000000"},
{"0400000000000000000000000000000000000000000000", "970400000000000000000000000000000000000000000000"},
{"0800000000000000000000000000000000000000000000", "970800000000000000000000000000000000000000000000"},
{"1000000000000000000000000000000000000000000000", "971000000000000000000000000000000000000000000000"},
{"2000000000000000000000000000000000000000000000", "972000000000000000000000000000000000000000000000"},
{"4000000000000000000000000000000000000000000000", "974000000000000000000000000000000000000000000000"},
{"8000000000000000000000000000000000000000000000", "978000000000000000000000000000000000000000000000"},
{"010000000000000000000000000000000000000000000000", "98010000000000000000000000000000000000000000000000"},
{"020000000000000000000000000000000000000000000000", "98020000000000000000000000000000000000000000000000"},
{"040000000000000000000000000000000000000000000000", "98040000000000000000000000000000000000000000000000"},