aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/types_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-08-04 07:40:50 +0800
committerFelix Lange <fjl@twurst.com>2016-08-04 07:40:50 +0800
commitb0d9f7372a04fa8f0ffc391f0997e2e062d465ef (patch)
treec78c4ee8bd261cd1b1d8b896a39c8612f435f154 /rpc/types_test.go
parent704fde01e8ed28877fe0f69fc8059b1f0c850d04 (diff)
downloadgo-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar.gz
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar.bz2
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar.lz
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar.xz
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.tar.zst
go-tangerine-b0d9f7372a04fa8f0ffc391f0997e2e062d465ef.zip
internal/ethapi: add missing output fields
- returned headers didn't include mixHash - returned transactions didn't include signature fields - empty transaction input was returned as "", but should be "0x" - returned receipts didn't include the bloom filter - "root" in receipts was missing 0x prefix
Diffstat (limited to 'rpc/types_test.go')
-rw-r--r--rpc/types_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/rpc/types_test.go b/rpc/types_test.go
index c2c5c6db6..5482557b8 100644
--- a/rpc/types_test.go
+++ b/rpc/types_test.go
@@ -71,3 +71,25 @@ func TestHexNumberMarshalJSON(t *testing.T) {
t.Fatalf("Invalid json.Marshal, expected '%s', got '%s'", exp, got)
}
}
+
+var hexBytesTests = []struct{ in, out []byte }{
+ {in: []byte(`"0x"`), out: []byte{}},
+ {in: []byte(`"0x00"`), out: []byte{0}},
+ {in: []byte(`"0x01ff"`), out: []byte{0x01, 0xFF}},
+}
+
+func TestHexBytes(t *testing.T) {
+ for i, test := range hexBytesTests {
+ var dec HexBytes
+ if err := json.Unmarshal(test.in, &dec); err != nil {
+ t.Fatalf("test %d: can't decode: %v", i, err)
+ }
+ enc, _ := json.Marshal(HexBytes(test.out))
+ if !bytes.Equal(dec, test.out) {
+ t.Errorf("test %d: wrong decoded value 0x%x", i, dec)
+ }
+ if !bytes.Equal(enc, test.in) {
+ t.Errorf("test %d: wrong encoded value %#q", i, enc)
+ }
+ }
+}