forked from lombard-finance/deposit-address
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aux_data_test.go
66 lines (63 loc) · 1.48 KB
/
aux_data_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
package deposit_address
import (
"encoding/hex"
"github.com/stretchr/testify/require"
"math"
"reflect"
"testing"
)
func TestComputeAuxDataV0(t *testing.T) {
referalData, err := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
type args struct {
nonce uint32
referrerId []byte
}
tests := []struct {
name string
args args
want string
}{
{
name: "successful with max uint32",
args: args{
nonce: math.MaxUint32,
referrerId: referalData,
},
want: "57302e91d7d3252be7c273a0041848c13c00b6d0782fef778f2ecab26fb0c0f8",
},
{
name: "successful with max uint32 - 1",
args: args{
nonce: math.MaxUint32 - 1,
referrerId: referalData,
},
want: "ad4abce054b9882828ac0c8003164660fd8ffc6e7005180e3e182770d4ae02c0",
},
{
name: "successful with 0",
args: args{
nonce: 0,
referrerId: referalData,
},
want: "2137aefeb756a435f07fceff39a061bd2a062b617bd8857e9c32b44ef2596bc8",
},
{
name: "successful with 1",
args: args{
nonce: 1,
referrerId: referalData,
},
want: "58bd0e282e046b08c0d395ea701678a1161f8f46362abc4a25b37dce12e57fcf",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ComputeAuxDataV0(tt.args.nonce, tt.args.referrerId)
require.NoError(t, err)
if !reflect.DeepEqual(hex.EncodeToString(got), tt.want) {
t.Errorf("ComputeAuxDataV0() = %x, want %v", got, tt.want)
}
})
}
}