Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: simulation to register interfaces #81

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}