Add types test
This commit is contained in:
parent
0ee401ca60
commit
fd68052ffa
26
core/types_test.go
Normal file
26
core/types_test.go
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user