Add more test cases
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/magiconair/properties/assert"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/CosmWasm/wasmd/x/wasm"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
db "github.com/tendermint/tm-db"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/simapp"
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
db "github.com/tendermint/tm-db"
|
||||||
|
|
||||||
|
"github.com/CosmWasm/wasmd/x/wasm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWasmdExport(t *testing.T) {
|
func TestWasmdExport(t *testing.T) {
|
||||||
@@ -37,6 +38,37 @@ func TestBlackListedAddrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetEnabledProposals(t *testing.T) {
|
||||||
|
cases := map[string]struct {
|
||||||
|
proposalsEnabled string
|
||||||
|
specificEnabled string
|
||||||
|
expected []wasm.ProposalType
|
||||||
|
}{
|
||||||
|
"all disabled": {
|
||||||
|
proposalsEnabled: "false",
|
||||||
|
expected: wasm.DisableAllProposals,
|
||||||
|
},
|
||||||
|
"all enabled": {
|
||||||
|
proposalsEnabled: "true",
|
||||||
|
expected: wasm.EnableAllProposals,
|
||||||
|
},
|
||||||
|
"some enabled": {
|
||||||
|
proposalsEnabled: "okay",
|
||||||
|
specificEnabled: "StoreCode,InstantiateContract",
|
||||||
|
expected: []wasm.ProposalType{wasm.ProposalTypeStoreCode, wasm.ProposalTypeInstantiateContract},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, tc := range cases {
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
ProposalsEnabled = tc.proposalsEnabled
|
||||||
|
EnableSpecificProposals = tc.specificEnabled
|
||||||
|
proposals := GetEnabledProposals()
|
||||||
|
assert.Equal(t, tc.expected, proposals)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func setGenesis(gapp *WasmApp) error {
|
func setGenesis(gapp *WasmApp) error {
|
||||||
genesisState := simapp.NewDefaultGenesisState()
|
genesisState := simapp.NewDefaultGenesisState()
|
||||||
genesisState[wasm.ModuleName] = wasm.AppModuleBasic{}.DefaultGenesis()
|
genesisState[wasm.ModuleName] = wasm.AppModuleBasic{}.DefaultGenesis()
|
||||||
|
|||||||
@@ -11,28 +11,33 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultParamspace = types.DefaultParamspace
|
DefaultParamspace = types.DefaultParamspace
|
||||||
ModuleName = types.ModuleName
|
ModuleName = types.ModuleName
|
||||||
StoreKey = types.StoreKey
|
StoreKey = types.StoreKey
|
||||||
TStoreKey = types.TStoreKey
|
TStoreKey = types.TStoreKey
|
||||||
QuerierRoute = types.QuerierRoute
|
QuerierRoute = types.QuerierRoute
|
||||||
RouterKey = types.RouterKey
|
RouterKey = types.RouterKey
|
||||||
MaxWasmSize = types.MaxWasmSize
|
MaxWasmSize = types.MaxWasmSize
|
||||||
MaxLabelSize = types.MaxLabelSize
|
MaxLabelSize = types.MaxLabelSize
|
||||||
BuildTagRegexp = types.BuildTagRegexp
|
BuildTagRegexp = types.BuildTagRegexp
|
||||||
MaxBuildTagSize = types.MaxBuildTagSize
|
MaxBuildTagSize = types.MaxBuildTagSize
|
||||||
CustomEventType = types.CustomEventType
|
CustomEventType = types.CustomEventType
|
||||||
AttributeKeyContractAddr = types.AttributeKeyContractAddr
|
AttributeKeyContractAddr = types.AttributeKeyContractAddr
|
||||||
GasMultiplier = keeper.GasMultiplier
|
ProposalTypeStoreCode = types.ProposalTypeStoreCode
|
||||||
MaxGas = keeper.MaxGas
|
ProposalTypeInstantiateContract = types.ProposalTypeInstantiateContract
|
||||||
QueryListContractByCode = keeper.QueryListContractByCode
|
ProposalTypeMigrateContract = types.ProposalTypeMigrateContract
|
||||||
QueryGetContract = keeper.QueryGetContract
|
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin
|
||||||
QueryGetContractState = keeper.QueryGetContractState
|
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin
|
||||||
QueryGetCode = keeper.QueryGetCode
|
GasMultiplier = keeper.GasMultiplier
|
||||||
QueryListCode = keeper.QueryListCode
|
MaxGas = keeper.MaxGas
|
||||||
QueryMethodContractStateSmart = keeper.QueryMethodContractStateSmart
|
QueryListContractByCode = keeper.QueryListContractByCode
|
||||||
QueryMethodContractStateAll = keeper.QueryMethodContractStateAll
|
QueryGetContract = keeper.QueryGetContract
|
||||||
QueryMethodContractStateRaw = keeper.QueryMethodContractStateRaw
|
QueryGetContractState = keeper.QueryGetContractState
|
||||||
|
QueryGetCode = keeper.QueryGetCode
|
||||||
|
QueryListCode = keeper.QueryListCode
|
||||||
|
QueryMethodContractStateSmart = keeper.QueryMethodContractStateSmart
|
||||||
|
QueryMethodContractStateAll = keeper.QueryMethodContractStateAll
|
||||||
|
QueryMethodContractStateRaw = keeper.QueryMethodContractStateRaw
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ func TestConvertToProposals(t *testing.T) {
|
|||||||
isError: true,
|
isError: true,
|
||||||
},
|
},
|
||||||
"invalid item": {
|
"invalid item": {
|
||||||
input: "StoreCode,InstanceContract",
|
input: "StoreCode,InvalidProposalType",
|
||||||
isError: true,
|
isError: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user