Add types test

This commit is contained in:
Austin Roberts 2021-09-14 13:32:05 -05:00
parent 0ee401ca60
commit fd68052ffa

26
core/types_test.go Normal file
View File

@ -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)
}
}