|
1 | 1 | package util
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "math" |
5 | 4 | "reflect"
|
6 | 5 | "testing"
|
7 | 6 | )
|
8 | 7 |
|
9 |
| -func TestGetAccountIDByPublicKey(t *testing.T) { |
10 |
| - type args struct { |
11 |
| - accountType uint32 |
12 |
| - publicKey []byte |
13 |
| - } |
14 |
| - tests := []struct { |
15 |
| - name string |
16 |
| - args args |
17 |
| - want []byte |
18 |
| - }{ |
19 |
| - { |
20 |
| - name: "GetAccountIDByPublicKey:success", |
21 |
| - args: args{ |
22 |
| - accountType: 0, |
23 |
| - publicKey: []byte{4, 38, 103, 73, 250, 169, 63, 155, 106, 21, 9, 76, 77, 137, 3, 120, 21, 69, 90, 118, 242, |
24 |
| - 84, 174, 239, 46, 190, 78, 68, 90, 83, 142, 11}, |
25 |
| - }, |
26 |
| - want: []byte{61, 173, 177, 191, 183, 169, 194, 0, 147, 155, 147, 2, 103, 251, 133, 203, 243, 56, 197, 6, 238, 74, |
27 |
| - 226, 190, 77, 169, 58, 218, 234, 86, 88, 130}, |
28 |
| - }, |
29 |
| - } |
30 |
| - for _, tt := range tests { |
31 |
| - t.Run(tt.name, func(t *testing.T) { |
32 |
| - if got := GetAccountIDByPublicKey(tt.args.accountType, tt.args.publicKey); !reflect.DeepEqual(got, tt.want) { |
33 |
| - t.Errorf("GetAccountIDByPublicKey() = %v, want %v", got, tt.want) |
34 |
| - } |
35 |
| - }) |
36 |
| - } |
37 |
| -} |
38 |
| - |
39 | 8 | func TestGetChecksumByte(t *testing.T) {
|
40 | 9 | type args struct {
|
41 | 10 | bytes []byte
|
@@ -203,76 +172,3 @@ func TestGetPublicKeyFromAddress(t *testing.T) {
|
203 | 172 | })
|
204 | 173 | }
|
205 | 174 | }
|
206 |
| - |
207 |
| -func TestCreateAccountIDFromAddress(t *testing.T) { |
208 |
| - type args struct { |
209 |
| - accountType uint32 |
210 |
| - address string |
211 |
| - } |
212 |
| - tests := []struct { |
213 |
| - name string |
214 |
| - args args |
215 |
| - want []byte |
216 |
| - }{ |
217 |
| - { |
218 |
| - name: "CreateAccountIDFromAddress:success", |
219 |
| - args: args{ |
220 |
| - accountType: 0, |
221 |
| - address: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN", |
222 |
| - }, |
223 |
| - want: []byte{136, 106, 141, 253, 44, 34, 145, 81, 166, 229, 33, 209, 150, 188, 204, 28, 239, 33, 152, 158, 4, 187, |
224 |
| - 13, 109, 173, 223, 169, 232, 50, 200, 169, 25}, |
225 |
| - }, |
226 |
| - } |
227 |
| - for _, tt := range tests { |
228 |
| - t.Run(tt.name, func(t *testing.T) { |
229 |
| - if got := CreateAccountIDFromAddress(tt.args.accountType, tt.args.address); !reflect.DeepEqual(got, tt.want) { |
230 |
| - t.Errorf("CreateAccountIDFromAddress() = %v, want %v", got, tt.want) |
231 |
| - } |
232 |
| - }) |
233 |
| - } |
234 |
| -} |
235 |
| - |
236 |
| -func TestValidateAccountAddress(t *testing.T) { |
237 |
| - type args struct { |
238 |
| - accType uint32 |
239 |
| - address string |
240 |
| - } |
241 |
| - tests := []struct { |
242 |
| - name string |
243 |
| - args args |
244 |
| - wantErr bool |
245 |
| - }{ |
246 |
| - { |
247 |
| - name: "TestValidateAccountAddress:Default", |
248 |
| - args: args{ |
249 |
| - accType: math.MaxUint32, |
250 |
| - address: "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0J", |
251 |
| - }, |
252 |
| - wantErr: true, |
253 |
| - }, |
254 |
| - { |
255 |
| - name: "TestValidateAccountAddress:0:success", |
256 |
| - args: args{ |
257 |
| - accType: 0, |
258 |
| - address: "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0J", |
259 |
| - }, |
260 |
| - wantErr: false, |
261 |
| - }, |
262 |
| - { |
263 |
| - name: "TestValidateAccountAddress:0:wantErr", |
264 |
| - args: args{ |
265 |
| - accType: 0, |
266 |
| - address: "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0", |
267 |
| - }, |
268 |
| - wantErr: true, |
269 |
| - }, |
270 |
| - } |
271 |
| - for _, tt := range tests { |
272 |
| - t.Run(tt.name, func(t *testing.T) { |
273 |
| - if err := ValidateAccountAddress(tt.args.accType, tt.args.address); (err != nil) != tt.wantErr { |
274 |
| - t.Errorf("ValidateAccountAddress() error = %v, wantErr %v", err, tt.wantErr) |
275 |
| - } |
276 |
| - }) |
277 |
| - } |
278 |
| -} |
0 commit comments