mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
accounts: added TestUnmarshalJSON
This commit is contained in:
parent
7bb3fb1481
commit
38d10f7ccd
1 changed files with 26 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue