From fd68052ffa6113d7f697386e3b44ea0b103a334b Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Tue, 14 Sep 2021 13:32:05 -0500 Subject: [PATCH] Add types test --- core/types_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core/types_test.go diff --git a/core/types_test.go b/core/types_test.go new file mode 100644 index 0000000..8781647 --- /dev/null +++ b/core/types_test.go @@ -0,0 +1,26 @@ +package core + +import ( + "encoding/json" + "testing" +) + +func TestJSONUnMarshalAddress(t *testing.T) { + addr := Address{} + if err := json.Unmarshal([]byte(`"0x01"`), &addr); err != nil { + t.Fatalf(err.Error()) + } + if addr != HexToAddress("0x01") { + t.Errorf("Unexpected address, wanted %v got %v", HexToAddress("0x01"), addr) + } +} + +func TestJSONUnMarshalHash(t *testing.T) { + addr := Hash{} + if err := json.Unmarshal([]byte(`"0x01"`), &addr); err != nil { + t.Fatalf(err.Error()) + } + if addr != HexToHash("0x01") { + t.Errorf("Unexpected address, wanted %v got %v", HexToHash("0x01"), addr) + } +}