diff options
author | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-02-18 23:04:45 +0800 |
---|---|---|
committer | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-02-18 23:04:45 +0800 |
commit | bbcf304b99b6bc9e2a2a8f49cda5e5b77917dd0a (patch) | |
tree | f3b2a45c0612e5210f35b864a14f81a27524252f /ethutil | |
parent | c866fcc5b37b53e0d11c1fd7e6cb971859537f2c (diff) | |
parent | c5b009ba6f153aa65fa25126bea41d899a436299 (diff) | |
download | go-tangerine-bbcf304b99b6bc9e2a2a8f49cda5e5b77917dd0a.tar.gz go-tangerine-bbcf304b99b6bc9e2a2a8f49cda5e5b77917dd0a.tar.zst go-tangerine-bbcf304b99b6bc9e2a2a8f49cda5e5b77917dd0a.zip |
Merge pull request #3 from josephyzhou/develop
Migrated to here
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/config.go | 2 | ||||
-rw-r--r-- | ethutil/encoding_test.go | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/ethutil/config.go b/ethutil/config.go index df1772d81..e3b5f0275 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -38,7 +38,7 @@ func ReadConfig(base string) *config { _, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { - log.Printf("Debug logging directory %s doesn't exist, creating it", path) + log.Printf("Debug logging directory %s doesn't exist, creating it\n", path) os.Mkdir(path, 0777) } } diff --git a/ethutil/encoding_test.go b/ethutil/encoding_test.go index bcabab0b1..cbfbc0eaf 100644 --- a/ethutil/encoding_test.go +++ b/ethutil/encoding_test.go @@ -35,3 +35,33 @@ func TestCompactHexDecode(t *testing.T) { t.Error("Error compact hex decode. Expected", exp, "got", res) } } + +func TestCompactDecode(t *testing.T) { + exp := []int{1, 2, 3, 4, 5} + res := CompactDecode("\x11\x23\x45") + + if !CompareIntSlice(res, exp) { + t.Error("odd compact decode. Expected", exp, "got", res) + } + + exp = []int{0, 1, 2, 3, 4, 5} + res = CompactDecode("\x00\x01\x23\x45") + + if !CompareIntSlice(res, exp) { + t.Error("even compact decode. Expected", exp, "got", res) + } + + exp = []int{0, 15, 1, 12, 11, 8 /*term*/, 16} + res = CompactDecode("\x20\x0f\x1c\xb8") + + if !CompareIntSlice(res, exp) { + t.Error("even terminated compact decode. Expected", exp, "got", res) + } + + exp = []int{15, 1, 12, 11, 8 /*term*/, 16} + res = CompactDecode("\x3f\x1c\xb8") + + if !CompareIntSlice(res, exp) { + t.Error("even terminated compact decode. Expected", exp, "got", res) + } +}
\ No newline at end of file |