eth/tracers: simplify test framework (#25973)
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This commit is contained in:
co-authored by
Sina Mahmoodi
parent
a404195c7b
commit
5f70f9fd37
@@ -16,14 +16,14 @@ var _ = (*accountMarshaling)(nil)
|
||||
func (a account) MarshalJSON() ([]byte, error) {
|
||||
type account struct {
|
||||
Balance *hexutil.Big `json:"balance,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Code hexutil.Bytes `json:"code,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||
}
|
||||
var enc account
|
||||
enc.Balance = (*hexutil.Big)(a.Balance)
|
||||
enc.Nonce = a.Nonce
|
||||
enc.Code = a.Code
|
||||
enc.Nonce = a.Nonce
|
||||
enc.Storage = a.Storage
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
@@ -31,10 +31,10 @@ func (a account) MarshalJSON() ([]byte, error) {
|
||||
// UnmarshalJSON unmarshals from JSON.
|
||||
func (a *account) UnmarshalJSON(input []byte) error {
|
||||
type account struct {
|
||||
Balance *hexutil.Big `json:"balance"`
|
||||
Nonce *uint64 `json:"nonce"`
|
||||
Code *hexutil.Bytes `json:"code"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage"`
|
||||
Balance *hexutil.Big `json:"balance,omitempty"`
|
||||
Code *hexutil.Bytes `json:"code,omitempty"`
|
||||
Nonce *uint64 `json:"nonce,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||
}
|
||||
var dec account
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
@@ -43,12 +43,12 @@ func (a *account) UnmarshalJSON(input []byte) error {
|
||||
if dec.Balance != nil {
|
||||
a.Balance = (*big.Int)(dec.Balance)
|
||||
}
|
||||
if dec.Nonce != nil {
|
||||
a.Nonce = *dec.Nonce
|
||||
}
|
||||
if dec.Code != nil {
|
||||
a.Code = *dec.Code
|
||||
}
|
||||
if dec.Nonce != nil {
|
||||
a.Nonce = *dec.Nonce
|
||||
}
|
||||
if dec.Storage != nil {
|
||||
a.Storage = dec.Storage
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ type state = map[common.Address]*account
|
||||
|
||||
type account struct {
|
||||
Balance *big.Int `json:"balance,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Code []byte `json:"code,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ func (t *prestateTracer) GetResult() (json.RawMessage, error) {
|
||||
var err error
|
||||
if t.config.DiffMode {
|
||||
res, err = json.Marshal(struct {
|
||||
Pre state `json:"pre"`
|
||||
Post state `json:"post"`
|
||||
}{t.pre, t.post})
|
||||
Pre state `json:"pre"`
|
||||
}{t.post, t.pre})
|
||||
} else {
|
||||
res, err = json.Marshal(t.pre)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user