cosmos-sdk/x/simulation/params_test.go
Marko 8de96d16f9
tendermint: update to rc3 (#6892)
* modify light imports

* change abci.header to tmproto.header

* use rc

* rc

* fix import

* Merge PR #6893: fix key imports

* fix rc2

* tendermint: update 3 (#6899)

* tendermint: update 4 (#6919)

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* tendermint: update 5 (#6923)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* bump to latest master

* tendermint: update (#6972)

Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>

* Update x/ibc/07-tendermint/types/test_utils.go

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* address comment

* go mod

* bring back things

* fix test

* update tm proto files

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>
Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-08-14 13:58:53 -04:00

55 lines
1.5 KiB
Go

package simulation
import (
"fmt"
"math/rand"
"testing"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
func TestParamChange(t *testing.T) {
subspace, key := "theSubspace", "key"
f := func(r *rand.Rand) string {
return "theResult"
}
pChange := NewSimParamChange(subspace, key, f)
require.Equal(t, subspace, pChange.Subspace())
require.Equal(t, key, pChange.Key())
require.Equal(t, f(nil), pChange.SimValue()(nil))
require.Equal(t, fmt.Sprintf("%s/%s", subspace, key), pChange.ComposedKey())
}
func TestNewWeightedProposalContent(t *testing.T) {
key := "theKey"
weight := 1
content := &testContent{}
f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content {
return content
}
pContent := NewWeightedProposalContent(key, weight, f)
require.Equal(t, key, pContent.AppParamsKey())
require.Equal(t, weight, pContent.DefaultWeight())
ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil)
require.Equal(t, content, pContent.ContentSimulatorFn()(nil, ctx, nil))
}
type testContent struct {
}
func (t testContent) GetTitle() string { return "" }
func (t testContent) GetDescription() string { return "" }
func (t testContent) ProposalRoute() string { return "" }
func (t testContent) ProposalType() string { return "" }
func (t testContent) ValidateBasic() error { return nil }
func (t testContent) String() string { return "" }