Add more test cases
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/magiconair/properties/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm"
|
||||
)
|
||||
|
||||
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 {
|
||||
genesisState := simapp.NewDefaultGenesisState()
|
||||
genesisState[wasm.ModuleName] = wasm.AppModuleBasic{}.DefaultGenesis()
|
||||
|
||||
@@ -11,28 +11,33 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultParamspace = types.DefaultParamspace
|
||||
ModuleName = types.ModuleName
|
||||
StoreKey = types.StoreKey
|
||||
TStoreKey = types.TStoreKey
|
||||
QuerierRoute = types.QuerierRoute
|
||||
RouterKey = types.RouterKey
|
||||
MaxWasmSize = types.MaxWasmSize
|
||||
MaxLabelSize = types.MaxLabelSize
|
||||
BuildTagRegexp = types.BuildTagRegexp
|
||||
MaxBuildTagSize = types.MaxBuildTagSize
|
||||
CustomEventType = types.CustomEventType
|
||||
AttributeKeyContractAddr = types.AttributeKeyContractAddr
|
||||
GasMultiplier = keeper.GasMultiplier
|
||||
MaxGas = keeper.MaxGas
|
||||
QueryListContractByCode = keeper.QueryListContractByCode
|
||||
QueryGetContract = keeper.QueryGetContract
|
||||
QueryGetContractState = keeper.QueryGetContractState
|
||||
QueryGetCode = keeper.QueryGetCode
|
||||
QueryListCode = keeper.QueryListCode
|
||||
QueryMethodContractStateSmart = keeper.QueryMethodContractStateSmart
|
||||
QueryMethodContractStateAll = keeper.QueryMethodContractStateAll
|
||||
QueryMethodContractStateRaw = keeper.QueryMethodContractStateRaw
|
||||
DefaultParamspace = types.DefaultParamspace
|
||||
ModuleName = types.ModuleName
|
||||
StoreKey = types.StoreKey
|
||||
TStoreKey = types.TStoreKey
|
||||
QuerierRoute = types.QuerierRoute
|
||||
RouterKey = types.RouterKey
|
||||
MaxWasmSize = types.MaxWasmSize
|
||||
MaxLabelSize = types.MaxLabelSize
|
||||
BuildTagRegexp = types.BuildTagRegexp
|
||||
MaxBuildTagSize = types.MaxBuildTagSize
|
||||
CustomEventType = types.CustomEventType
|
||||
AttributeKeyContractAddr = types.AttributeKeyContractAddr
|
||||
ProposalTypeStoreCode = types.ProposalTypeStoreCode
|
||||
ProposalTypeInstantiateContract = types.ProposalTypeInstantiateContract
|
||||
ProposalTypeMigrateContract = types.ProposalTypeMigrateContract
|
||||
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin
|
||||
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin
|
||||
GasMultiplier = keeper.GasMultiplier
|
||||
MaxGas = keeper.MaxGas
|
||||
QueryListContractByCode = keeper.QueryListContractByCode
|
||||
QueryGetContract = keeper.QueryGetContract
|
||||
QueryGetContractState = keeper.QueryGetContractState
|
||||
QueryGetCode = keeper.QueryGetCode
|
||||
QueryListCode = keeper.QueryListCode
|
||||
QueryMethodContractStateSmart = keeper.QueryMethodContractStateSmart
|
||||
QueryMethodContractStateAll = keeper.QueryMethodContractStateAll
|
||||
QueryMethodContractStateRaw = keeper.QueryMethodContractStateRaw
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -636,7 +636,7 @@ func TestConvertToProposals(t *testing.T) {
|
||||
isError: true,
|
||||
},
|
||||
"invalid item": {
|
||||
input: "StoreCode,InstanceContract",
|
||||
input: "StoreCode,InvalidProposalType",
|
||||
isError: true,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user