xeth: added address hex check and length check

This commit is contained in:
Jeffrey Wilcke
2015-08-07 09:52:12 +02:00
parent 9a02f53726
commit d051274691
2 changed files with 37 additions and 0 deletions

26
xeth/xeth_test.go Normal file
View File

@ -0,0 +1,26 @@
package xeth
import "testing"
func TestIsAddress(t *testing.T) {
for _, invalid := range []string{
"0x00",
"0xNN",
"0x00000000000000000000000000000000000000NN",
"0xAAar000000000000000000000000000000000000",
} {
if isAddress(invalid) {
t.Error("Expected", invalid, "to be invalid")
}
}
for _, valid := range []string{
"0x0000000000000000000000000000000000000000",
"0xAABBbbCCccff9900000000000000000000000000",
"AABBbbCCccff9900000000000000000000000000",
} {
if !isAddress(valid) {
t.Error("Expected", valid, "to be valid")
}
}
}