Skip to content

Commit

Permalink
Merge pull request #81 from terra-money/fix/simulation
Browse files Browse the repository at this point in the history
fix: simulation to register interfaces
  • Loading branch information
emidev98 authored Feb 1, 2023
2 parents fe9a716 + 9297db0 commit 31553f0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
17 changes: 8 additions & 9 deletions app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
abci "github.com/tendermint/tendermint/abci/types"

"github.com/terra-money/alliance/app"
"github.com/terra-money/alliance/app/params"
)

func init() {
Expand Down Expand Up @@ -53,9 +52,9 @@ func BenchmarkSimulation(b *testing.B) {
require.NoError(b, err)
})

encoding := params.MakeEncodingConfig()
encoding := app.MakeTestEncodingConfig()

app := app.New(
simApp := app.New(
logger,
db,
nil,
Expand All @@ -71,17 +70,17 @@ func BenchmarkSimulation(b *testing.B) {
_, simParams, simErr := simulation.SimulateFromSeed(
b,
os.Stdout,
app.GetBaseApp(),
simapp.AppStateFn(app.AppCodec(), app.SimulationManager()),
simApp.GetBaseApp(),
simapp.AppStateFn(simApp.AppCodec(), simApp.SimulationManager()),
simulationtypes.RandomAccounts,
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
simapp.SimulationOperations(simApp, simApp.AppCodec(), config),
simApp.ModuleAccountAddrs(),
config,
app.AppCodec(),
simApp.AppCodec(),
)

// export state and simParams before the simulation error is checked
err = simapp.CheckExportSimulation(app, config, simParams)
err = simapp.CheckExportSimulation(simApp, config, simParams)
require.NoError(b, err)
require.NoError(b, simErr)

Expand Down
53 changes: 37 additions & 16 deletions x/alliance/keeper/tests/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,21 +899,42 @@ func TestQueryValidators(t *testing.T) {
})

require.NoError(t, queryErr)
require.Equal(t, &types.QueryAllianceValidatorsResponse{
Validators: []types.QueryAllianceValidatorResponse{
{
ValidatorAddr: val2.GetOperator().String(),
TotalDelegationShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000000)),
),
ValidatorShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000000)),
),
TotalStaked: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000_000)),
),
// Order in which validators are returned is not deterministic since we randomly generate validator addresses
if queryVal2.Validators[0].ValidatorAddr == val.GetOperator().String() {
require.Equal(t, &types.QueryAllianceValidatorsResponse{
Validators: []types.QueryAllianceValidatorResponse{
{
ValidatorAddr: val.GetOperator().String(),
TotalDelegationShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenom, sdk.NewDec(1000000)),
),
ValidatorShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenom, sdk.NewDec(1000000)),
),
TotalStaked: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenom, sdk.NewDec(1000_000)),
),
},
},
},
Pagination: queryVal2.Pagination,
}, queryVal2)
Pagination: queryVal2.Pagination,
}, queryVal2)
} else {
require.Equal(t, &types.QueryAllianceValidatorsResponse{
Validators: []types.QueryAllianceValidatorResponse{
{
ValidatorAddr: val2.GetOperator().String(),
TotalDelegationShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000000)),
),
ValidatorShares: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000000)),
),
TotalStaked: sdk.NewDecCoins(
sdk.NewDecCoinFromDec(AllianceDenomTwo, sdk.NewDec(1000_000)),
),
},
},
Pagination: queryVal2.Pagination,
}, queryVal2)
}
}

0 comments on commit 31553f0

Please sign in to comment.