|
7 | 7 | "github.com/sencha-dev/powkit/internal/common/testutil"
|
8 | 8 | )
|
9 | 9 |
|
10 |
| -func TestCalcN(t *testing.T) { |
| 10 | +func TestCalcNErgo(t *testing.T) { |
11 | 11 | tests := []struct {
|
12 | 12 | height uint64
|
13 | 13 | value uint32
|
@@ -51,31 +51,42 @@ func TestCalcN(t *testing.T) {
|
51 | 51 | }
|
52 | 52 |
|
53 | 53 | for i, tt := range tests {
|
54 |
| - value := New(32, 26).calcN(tt.height) |
| 54 | + value := NewErgo().calcN(tt.height) |
55 | 55 | if value != tt.value {
|
56 | 56 | t.Errorf("failed on %d: have %d, want %d", i, value, tt.value)
|
57 | 57 | }
|
58 | 58 | }
|
59 | 59 | }
|
60 | 60 |
|
61 |
| -func TestCompute(t *testing.T) { |
| 61 | +func TestComputeErgo(t *testing.T) { |
62 | 62 | tests := []struct {
|
63 | 63 | msg []byte
|
64 | 64 | nonce uint64
|
65 | 65 | height uint64
|
66 | 66 | result []byte
|
67 | 67 | }{
|
68 |
| - // https://www.ergoforum.org/t/test-vectors-for-increased-n-values/2887 |
69 | 68 | {
|
70 | 69 | msg: testutil.MustDecodeHex("548c3e602a8f36f8f2738f5f643b02425038044d98543a51cabaa9785e7e864f"),
|
71 | 70 | nonce: 0x3105,
|
72 | 71 | height: 614400,
|
73 | 72 | result: testutil.MustDecodeHex("0002fcb113fe65e5754959872dfdbffea0489bf830beb4961ddc0e9e66a1412a"),
|
74 | 73 | },
|
| 74 | + { |
| 75 | + msg: testutil.MustDecodeHex("8e26ba46cd2516cce5c0573dc92c6de8f1b7f110bee9aca4d196e5e0e391d029"), |
| 76 | + nonce: 0x062360e36e133e4d, |
| 77 | + height: 771223, |
| 78 | + result: testutil.MustDecodeHex("000000006b216892578fad42f928c9a19638a2abb667a5a8113311393dcca017"), |
| 79 | + }, |
| 80 | + { |
| 81 | + msg: testutil.MustDecodeHex("8e26ba46cd2516cce5c0573dc92c6de8f1b7f110bee9aca4d196e5e0e391d029"), |
| 82 | + nonce: 0x062360e385ffa5ce, |
| 83 | + height: 771223, |
| 84 | + result: testutil.MustDecodeHex("0000000005353a7890377419c1ddfdec0e185fa445886597a4ed69e376190aa1"), |
| 85 | + }, |
75 | 86 | }
|
76 | 87 |
|
77 | 88 | for i, tt := range tests {
|
78 |
| - result := New(32, 26).Compute(tt.msg, tt.nonce, tt.height) |
| 89 | + result := NewErgo().Compute(tt.msg, tt.nonce, tt.height) |
79 | 90 | if bytes.Compare(result, tt.result) != 0 {
|
80 | 91 | t.Errorf("failed on %d: have %x, want %x", i, result, tt.result)
|
81 | 92 | }
|
|
0 commit comments