aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2014-11-06 00:11:40 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2014-11-06 00:11:40 +0800
commitcb32f52b9cdc0f44c7c25f956b9de8c62e24f275 (patch)
tree30ad5222746e44b7184ec6a797cbe59bb3bff2b6
parent4f009290847dea29e7ea050244418b8b14c3aa61 (diff)
downloaddexon-cb32f52b9cdc0f44c7c25f956b9de8c62e24f275.tar.gz
dexon-cb32f52b9cdc0f44c7c25f956b9de8c62e24f275.tar.zst
dexon-cb32f52b9cdc0f44c7c25f956b9de8c62e24f275.zip
added test for parsing bytes
-rw-r--r--ethutil/bytes_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/ethutil/bytes_test.go b/ethutil/bytes_test.go
index 27b31c0c8..cbc38da77 100644
--- a/ethutil/bytes_test.go
+++ b/ethutil/bytes_test.go
@@ -5,7 +5,7 @@ import (
"testing"
)
-func TestParseData(t *testing.T) {
+func TestParseDataString(t *testing.T) {
data := ParseData("hello", "world", "0x0106")
exp := "68656c6c6f000000000000000000000000000000000000000000000000000000776f726c640000000000000000000000000000000000000000000000000000000106000000000000000000000000000000000000000000000000000000000000"
if bytes.Compare(data, Hex2Bytes(exp)) != 0 {
@@ -13,6 +13,16 @@ func TestParseData(t *testing.T) {
}
}
+func TestParseDataBytes(t *testing.T) {
+ data := []byte{232, 212, 165, 16, 0}
+ exp := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 212, 165, 16, 0}
+
+ res := ParseData(data)
+ if bytes.Compare(res, exp) != 0 {
+ t.Errorf("Expected %x got %x", exp, res)
+ }
+}
+
func TestLeftPadBytes(t *testing.T) {
val := []byte{1, 2, 3, 4}
exp := []byte{0, 0, 0, 0, 1, 2, 3, 4}