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>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package simulation
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/tharsis/ethermint/x/evm/types"
|
|
)
|
|
|
|
// TestDecodeStore tests that evm simulation decoder decodes the key value pairs as expected.
|
|
func TestDecodeStore(t *testing.T) {
|
|
dec := NewDecodeStore()
|
|
|
|
hash := common.BytesToHash([]byte("hash"))
|
|
code := common.Bytes2Hex([]byte{1, 2, 3})
|
|
|
|
kvPairs := kv.Pairs{
|
|
Pairs: []kv.Pair{
|
|
{Key: types.KeyPrefixCode, Value: common.FromHex(code)},
|
|
{Key: types.KeyPrefixStorage, Value: hash.Bytes()},
|
|
},
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
expectedLog string
|
|
}{
|
|
{"Code", fmt.Sprintf("%v\n%v", code, code)},
|
|
{"Storage", fmt.Sprintf("%v\n%v", hash, hash)},
|
|
{"other", ""},
|
|
}
|
|
for i, tt := range tests {
|
|
i, tt := i, tt
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
switch i {
|
|
case len(tests) - 1:
|
|
require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name)
|
|
default:
|
|
require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name)
|
|
}
|
|
})
|
|
}
|
|
}
|