forked from cerc-io/laconicd-deprecated
evm: fixed commented out simulations, pubsub, and handler tests (#655)
* evm: fixed commented out simulations, pubsub, and handler tests fixes #640 simulations are very basic: they can be built and executed, but they don't generate any EVM-related transactions yet. (It should be a matter of adding simulation-related code to the modules + potentially extra helpers to the simulation.) handler tests miss some extra assertions due to changes in the return values snapshotting logic (ADR-001 and ADR-002). Besides the test suites identified in the audit, there's also "importer_test.go" which wasn't yet fixed. (it'd require major rewriting + extra test resources) * gofumpt
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
@@ -16,9 +17,11 @@ import (
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
|
||||
"github.com/tharsis/ethermint/x/feemarket/client/cli"
|
||||
"github.com/tharsis/ethermint/x/feemarket/keeper"
|
||||
"github.com/tharsis/ethermint/x/feemarket/simulation"
|
||||
"github.com/tharsis/ethermint/x/feemarket/types"
|
||||
)
|
||||
|
||||
@@ -155,3 +158,26 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
|
||||
gs := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
// RandomizedParams creates randomized fee market param changes for the simulator.
|
||||
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder registers a decoder for fee market module's types
|
||||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {}
|
||||
|
||||
// ProposalContents doesn't return any content functions for governance proposals.
|
||||
func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenerateGenesisState creates a randomized GenState of the fee market module.
|
||||
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
||||
simulation.RandomizedGenState(simState)
|
||||
}
|
||||
|
||||
// WeightedOperations returns the all the fee market module operations with their respective weights.
|
||||
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/feemarket/types"
|
||||
)
|
||||
|
||||
// RandomizedGenState generates a random GenesisState for nft
|
||||
func RandomizedGenState(simState *module.SimulationState) {
|
||||
params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Int63(), simState.Rand.Int63())
|
||||
baseFee := sdk.NewInt(simState.Rand.Int63())
|
||||
blockGas := simState.Rand.Uint64()
|
||||
feemarketGenesis := types.NewGenesisState(params, baseFee, blockGas)
|
||||
|
||||
bz, err := json.MarshalIndent(feemarketGenesis, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
|
||||
|
||||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feemarketGenesis)
|
||||
}
|
||||
@@ -15,6 +15,15 @@ func DefaultGenesisState() *GenesisState {
|
||||
}
|
||||
}
|
||||
|
||||
// NewGenesisState creates a new genesis state.
|
||||
func NewGenesisState(params Params, baseFee sdk.Int, blockGas uint64) *GenesisState {
|
||||
return &GenesisState{
|
||||
Params: params,
|
||||
BaseFee: baseFee,
|
||||
BlockGas: blockGas,
|
||||
}
|
||||
}
|
||||
|
||||
// Validate performs basic genesis state validation returning an error upon any
|
||||
// failure.
|
||||
func (gs GenesisState) Validate() error {
|
||||
|
||||
Reference in New Issue
Block a user