|
|
|
@ -35,6 +35,30 @@ func TestBytesConversion(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestIsHexAddress(t *testing.T) { |
|
|
|
|
tests := []struct { |
|
|
|
|
str string |
|
|
|
|
exp bool |
|
|
|
|
}{ |
|
|
|
|
{"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed", true}, |
|
|
|
|
{"5aaeb6053f3e94c9b9a09f33669435e7ef1beaed", true}, |
|
|
|
|
{"0X5aaeb6053f3e94c9b9a09f33669435e7ef1beaed", true}, |
|
|
|
|
{"0XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", true}, |
|
|
|
|
{"0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", true}, |
|
|
|
|
{"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed1", false}, |
|
|
|
|
{"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beae", false}, |
|
|
|
|
{"5aaeb6053f3e94c9b9a09f33669435e7ef1beaed11", false}, |
|
|
|
|
{"0xxaaeb6053f3e94c9b9a09f33669435e7ef1beaed", false}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
if result := IsHexAddress(test.str); result != test.exp { |
|
|
|
|
t.Errorf("IsHexAddress(%s) == %v; expected %v", |
|
|
|
|
test.str, result, test.exp) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestHashJsonValidation(t *testing.T) { |
|
|
|
|
var tests = []struct { |
|
|
|
|
Prefix string |
|
|
|
|