forked from cerc-io/laconicd-deprecated
4ea9b6dc6d
* add note fix note * add TestAppStateFn TestRandomAccounts * marshal int slice to json * add paramschange for enableCreate and enableCall * AppStateFn -> StateFn * add TestDecodeStore * update github actions to run evm simulation * add TestParamChanges * add TestRandomizedGenState * use go install for runsim * resolve conflict * use random gasCap to estimate gas * use estimateGas to calculate max transferableAmount * update godoc * TestAppStateFn -> TestStateFn * Update x/evm/simulation/genesis.go * comment Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
32 lines
896 B
Go
32 lines
896 B
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/tharsis/ethermint/x/evm/types"
|
|
)
|
|
|
|
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
|
|
// value to the corresponding EVM type.
|
|
func NewDecodeStore() func(kvA, kvB kv.Pair) string {
|
|
return func(kvA, kvB kv.Pair) string {
|
|
switch {
|
|
case bytes.Equal(kvA.Key[:1], types.KeyPrefixStorage):
|
|
storageA := common.BytesToHash(kvA.Value).Hex()
|
|
storageB := common.BytesToHash(kvB.Value).Hex()
|
|
|
|
return fmt.Sprintf("%v\n%v", storageA, storageB)
|
|
case bytes.Equal(kvA.Key[:1], types.KeyPrefixCode):
|
|
codeHashA := common.Bytes2Hex(kvA.Value)
|
|
codeHashB := common.Bytes2Hex(kvB.Value)
|
|
|
|
return fmt.Sprintf("%v\n%v", codeHashA, codeHashB)
|
|
default:
|
|
panic(fmt.Sprintf("invalid evm key prefix %X", kvA.Key[:1]))
|
|
}
|
|
}
|
|
}
|