aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/abi_test.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2016-04-01 05:54:47 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2016-04-05 02:30:59 +0800
commita306e17a26e96e383afe86a2f1cdfa2320ec0f2f (patch)
treee594fab043b0936864b6578f2d1db2239a75ace3 /accounts/abi/abi_test.go
parent968d8ffe942f6ef3776b43a73fb0fe85eb955a68 (diff)
downloadgo-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar.gz
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar.bz2
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar.lz
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar.xz
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.tar.zst
go-tangerine-a306e17a26e96e383afe86a2f1cdfa2320ec0f2f.zip
abi: removed implicit type casting & refactored type parsing
Diffstat (limited to 'accounts/abi/abi_test.go')
-rw-r--r--accounts/abi/abi_test.go33
1 files changed, 22 insertions, 11 deletions
diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go
index a0f0d1034..a1b3e62d9 100644
--- a/accounts/abi/abi_test.go
+++ b/accounts/abi/abi_test.go
@@ -59,7 +59,7 @@ func TestType(t *testing.T) {
if err != nil {
t.Error(err)
}
- if typ.Kind != reflect.Ptr {
+ if typ.Kind != reflect.Uint {
t.Error("expected uint32 to have kind Ptr")
}
@@ -67,8 +67,8 @@ func TestType(t *testing.T) {
if err != nil {
t.Error(err)
}
- if typ.Kind != reflect.Slice {
- t.Error("expected uint32[] to have type slice")
+ if !typ.IsSlice {
+ t.Error("expected uint32[] to be slice")
}
if typ.Type != ubig_t {
t.Error("expcted uith32[] to have type uint64")
@@ -78,13 +78,13 @@ func TestType(t *testing.T) {
if err != nil {
t.Error(err)
}
- if typ.Kind != reflect.Slice {
- t.Error("expected uint32[2] to have kind slice")
+ if !typ.IsSlice {
+ t.Error("expected uint32[2] to be slice")
}
if typ.Type != ubig_t {
t.Error("expcted uith32[2] to have type uint64")
}
- if typ.Size != 2 {
+ if typ.SliceSize != 2 {
t.Error("expected uint32[2] to have a size of 2")
}
}
@@ -149,10 +149,6 @@ func TestTestNumbers(t *testing.T) {
t.Errorf("expected send( ptr ) to throw, requires *big.Int instead of *int")
}
- if _, err := abi.Pack("send", 1000); err != nil {
- t.Error("expected send(1000) to cast to big")
- }
-
if _, err := abi.Pack("test", uint32(1000)); err != nil {
t.Error(err)
}
@@ -204,7 +200,7 @@ func TestTestSlice(t *testing.T) {
t.FailNow()
}
- slice := make([]byte, 2)
+ slice := make([]uint64, 2)
if _, err := abi.Pack("uint64[2]", slice); err != nil {
t.Error(err)
}
@@ -214,6 +210,21 @@ func TestTestSlice(t *testing.T) {
}
}
+func TestImplicitTypeCasts(t *testing.T) {
+ abi, err := JSON(strings.NewReader(jsondata2))
+ if err != nil {
+ t.Error(err)
+ t.FailNow()
+ }
+
+ slice := make([]uint8, 2)
+ _, err = abi.Pack("uint64[2]", slice)
+ expStr := "`uint64[2]` abi: cannot use type uint8 as type uint64"
+ if err.Error() != expStr {
+ t.Errorf("expected %v, got %v", expStr, err)
+ }
+}
+
func TestMethodSignature(t *testing.T) {
String, _ := NewType("string")
String32, _ := NewType("string32")