accounts: added TestUnmarshalJSON

This commit is contained in:
web3santa 2024-04-16 02:08:23 +09:00
parent 7bb3fb1481
commit 38d10f7ccd

View file

@ -19,6 +19,7 @@ package abi
import (
"bytes"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/big"
@ -1218,3 +1219,28 @@ func TestUnpackRevert(t *testing.T) {
})
}
}
func TestUnmarshalJSON(t *testing.T) {
t.Parallel()
jsonData := `{"name": "Alice", "age": 30}`
reader := bytes.NewReader([]byte(jsonData))
dec := json.NewDecoder(reader)
type ABI struct {
Constructor Method
Methods map[string]Method
Events map[string]Event
Errors map[string]Error
Fallback Method // Note it's also used to represent legacy fallback before v0.6.0
Receive Method
}
var abi ABI
if err := dec.Decode(&abi); err != nil {
t.Fatalf("Output mismatch, want %v, got %v", err, dec)
}
}