aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/xeth_test.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-08-07 15:52:12 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-08-07 15:52:12 +0800
commitcf7cef4293cf1b1a9b393f1030f8c8e648c2975b (patch)
tree47228d592884c208e7c31ed5318f2cb513b0fb2d /xeth/xeth_test.go
parent698e98d9814605bfea98ba3ad2fe7fda073cb2b1 (diff)
downloadgo-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar.gz
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar.bz2
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar.lz
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar.xz
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.tar.zst
go-tangerine-cf7cef4293cf1b1a9b393f1030f8c8e648c2975b.zip
xeth: added address hex check and length check
Diffstat (limited to 'xeth/xeth_test.go')
-rw-r--r--xeth/xeth_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/xeth/xeth_test.go b/xeth/xeth_test.go
new file mode 100644
index 000000000..e649d20ef
--- /dev/null
+++ b/xeth/xeth_test.go
@@ -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")
+ }
+ }
+}