apply request finalize, fix lint
This commit is contained in:
parent
7a68b376bd
commit
4bf14c5650
|
@ -53,9 +53,11 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
|
||||||
Coins: coins,
|
Coins: coins,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
govGenesis := gov.DefaultGenesisState()
|
|
||||||
// Default genesis state
|
// Default genesis state
|
||||||
|
govGenesis := gov.DefaultGenesisState()
|
||||||
stakeGenesis := stake.DefaultGenesisState()
|
stakeGenesis := stake.DefaultGenesisState()
|
||||||
|
slashingGenesis := slashing.DefaultGenesisState()
|
||||||
var validators []stake.Validator
|
var validators []stake.Validator
|
||||||
var delegations []stake.Delegation
|
var delegations []stake.Delegation
|
||||||
// XXX Try different numbers of initially bonded validators
|
// XXX Try different numbers of initially bonded validators
|
||||||
|
@ -77,7 +79,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
|
||||||
genesis := GenesisState{
|
genesis := GenesisState{
|
||||||
Accounts: genesisAccounts,
|
Accounts: genesisAccounts,
|
||||||
StakeData: stakeGenesis,
|
StakeData: stakeGenesis,
|
||||||
SlashingData: slashing.DefaultGenesisState(),
|
SlashingData: slashingGenesis,
|
||||||
GovData: govGenesis,
|
GovData: govGenesis,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package assoc
|
package assoc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -53,9 +53,6 @@ func TestValidatorSet(t *testing.T) {
|
||||||
require.Equal(t, base.Validator(ctx, addr1), valset.Validator(ctx, addr1))
|
require.Equal(t, base.Validator(ctx, addr1), valset.Validator(ctx, addr1))
|
||||||
require.Equal(t, base.Validator(ctx, addr2), valset.Validator(ctx, addr2))
|
require.Equal(t, base.Validator(ctx, addr2), valset.Validator(ctx, addr2))
|
||||||
|
|
||||||
// XXX: Will be fixed by #2248
|
|
||||||
// Associations is broken because of prefixstore iterator
|
|
||||||
/*
|
|
||||||
assocs := valset.Associations(ctx, addr1)
|
assocs := valset.Associations(ctx, addr1)
|
||||||
require.Equal(t, 1, len(assocs))
|
require.Equal(t, 1, len(assocs))
|
||||||
require.True(t, bytes.Equal(assoc1, assocs[0]))
|
require.True(t, bytes.Equal(assoc1, assocs[0]))
|
||||||
|
@ -71,5 +68,4 @@ func TestValidatorSet(t *testing.T) {
|
||||||
|
|
||||||
require.Nil(t, valset.Validator(ctx, assoc1))
|
require.Nil(t, valset.Validator(ctx, assoc1))
|
||||||
require.Nil(t, valset.Validator(ctx, assoc2))
|
require.Nil(t, valset.Validator(ctx, assoc2))
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ var (
|
||||||
ParamStoreKeyTallyingProcedure = []byte("tallyingprocedure")
|
ParamStoreKeyTallyingProcedure = []byte("tallyingprocedure")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Type declaration for parameters
|
||||||
func ParamTable() params.Table {
|
func ParamTable() params.Table {
|
||||||
return params.NewTable(
|
return params.NewTable(
|
||||||
ParamStoreKeyDepositProcedure, DepositProcedure{},
|
ParamStoreKeyDepositProcedure, DepositProcedure{},
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package store
|
package store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
@ -101,9 +100,8 @@ func (s Store) Modified(ctx sdk.Context, key []byte) bool {
|
||||||
func (s Store) Set(ctx sdk.Context, key []byte, param interface{}) {
|
func (s Store) Set(ctx sdk.Context, key []byte, param interface{}) {
|
||||||
store := s.kvStore(ctx)
|
store := s.kvStore(ctx)
|
||||||
|
|
||||||
ty, ok := s.table.m[string(key)]
|
ty, ok := s.table[string(key)]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println(string(key), ty, param, reflect.TypeOf(param))
|
|
||||||
panic("Parameter not registered")
|
panic("Parameter not registered")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,20 +4,16 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Table struct {
|
// Table stores appropriate type for each parameter key
|
||||||
m map[string]reflect.Type
|
type Table map[string]reflect.Type
|
||||||
sealed bool
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Constructs new table
|
||||||
func NewTable(keytypes ...interface{}) (res Table) {
|
func NewTable(keytypes ...interface{}) (res Table) {
|
||||||
if len(keytypes)%2 != 0 {
|
if len(keytypes)%2 != 0 {
|
||||||
panic("odd number arguments in NewTypeTable")
|
panic("odd number arguments in NewTypeTable")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Table{
|
res = make(map[string]reflect.Type)
|
||||||
m: make(map[string]reflect.Type),
|
|
||||||
sealed: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < len(keytypes); i += 2 {
|
for i := 0; i < len(keytypes); i += 2 {
|
||||||
res = res.RegisterType(keytypes[i].([]byte), keytypes[i+1])
|
res = res.RegisterType(keytypes[i].([]byte), keytypes[i+1])
|
||||||
|
@ -26,13 +22,10 @@ func NewTable(keytypes ...interface{}) (res Table) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register single key-type pair
|
||||||
func (t Table) RegisterType(key []byte, ty interface{}) Table {
|
func (t Table) RegisterType(key []byte, ty interface{}) Table {
|
||||||
if t.sealed {
|
|
||||||
panic("RegisterType() on sealed Table")
|
|
||||||
}
|
|
||||||
|
|
||||||
keystr := string(key)
|
keystr := string(key)
|
||||||
if _, ok := t.m[keystr]; ok {
|
if _, ok := t[keystr]; ok {
|
||||||
panic("duplicate parameter key")
|
panic("duplicate parameter key")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +36,12 @@ func (t Table) RegisterType(key []byte, ty interface{}) Table {
|
||||||
rty = rty.Elem()
|
rty = rty.Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
t.m[keystr] = rty
|
t[keystr] = rty
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register multiple pairs from ParamStruct
|
||||||
func (t Table) RegisterParamStruct(ps ParamStruct) Table {
|
func (t Table) RegisterParamStruct(ps ParamStruct) Table {
|
||||||
for _, kvp := range ps.KeyValuePairs() {
|
for _, kvp := range ps.KeyValuePairs() {
|
||||||
t = t.RegisterType(kvp.Key, kvp.Value)
|
t = t.RegisterType(kvp.Key, kvp.Value)
|
||||||
|
|
|
@ -23,6 +23,7 @@ var (
|
||||||
KeySlashFractionDowntime = []byte("SlashFractionDowntime")
|
KeySlashFractionDowntime = []byte("SlashFractionDowntime")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ParamTable for slashing module
|
||||||
func ParamTable() params.Table {
|
func ParamTable() params.Table {
|
||||||
return params.NewTable().RegisterParamStruct(&Params{})
|
return params.NewTable().RegisterParamStruct(&Params{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ const (
|
||||||
DefaultParamspace = "stake"
|
DefaultParamspace = "stake"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ParamTable for stake module
|
||||||
func ParamTable() params.Table {
|
func ParamTable() params.Table {
|
||||||
return params.NewTable().RegisterParamStruct(&types.Params{})
|
return params.NewTable().RegisterParamStruct(&types.Params{})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue