-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v0.54.0
- v0.53.2
- v0.53.1
- v0.53.0
- v0.52.0
- v0.51.0
- v0.51.0-rc.5
- v0.51.0-rc.4
- v0.51.0-rc.3
- v0.51.0-rc.2
- v0.51.0-rc.1
- v0.51.0-rc.0
- v0.50.0
- v0.50.0-rc.2
- v0.50.0-rc.1
- v0.50.0-rc.0
- v0.46.0
- v0.45.0
- v0.44.0
- v0.43.0
- v0.42.0
- v0.42.0-rc.1
- v0.42.0-rc.0
- v0.41.0
- v0.41.0-rc.3
- v0.41.0-rc.2
- v0.41.0-rc.1
- v0.41.0-rc.0
- v0.40.2
- v0.40.1
- v0.40.0
- v0.40.0-rc.2
- v0.40.0-rc.1
- v0.40.0-rc.0
- v0.34.1
- v0.34.0
- v0.33.0
- v0.33.0-rc.0
- v0.32.1
- v0.32.0
- v0.31.0
- v0.31.0-rc2
- v0.31.0-rc1
- v0.31.0-rc0
- v0.30.0
- v0.30.0-rc0
- v0.29.2
- v0.29.1
- v0.29.0
- v0.29.0-rc2
- v0.29.0-rc1
- v0.29.0-rc0
- v0.28.0
- v0.27.0
- v0.27.0.rc3
- v0.27.0-rc3
- v0.27.0-rc2
- v0.27.0-rc0
- v0.27.0-junity.0
- v0.26.0
- v0.25.0
- v0.25.0-ica
- v0.24.0
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
- v0.20.0-rc1
- v0.19.0
- v0.18.0
- v0.18.0-rc4
- v0.18.0-rc3
- v0.18.0-rc2
- v0.18.0-rc1
- v0.17.0
- v0.16.0
- v0.16.0-rc1
- v0.16.0-alpha2
- v0.16.0-alpha1
- v0.15.1
- v0.15.0
- v0.14.2
- v0.14.1
- v0.14.0
- v0.14.0-rc2
- v0.14.0-rc1
- v0.14.0-alpha2
- v0.13.0
- v0.12.1
- v0.12.0
- musselnet-v1.0.0
- list
Showing
24 changed files
with
569 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
package integration | ||
|
||
/** | ||
This file is full of test helper functions, taken from simapp | ||
**/ | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
|
||
wasmd "github.com/CosmWasm/wasmd/app" | ||
"github.com/CosmWasm/wasmd/x/wasm" | ||
bam "github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" | ||
"github.com/cosmos/cosmos-sdk/simapp/helpers" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/crypto" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
dbm "github.com/tendermint/tm-db" | ||
) | ||
|
||
// Setup initializes a new wasmd.WasmApp. A Nop logger is set in WasmApp. | ||
func Setup(isCheckTx bool, homeDir string) *wasmd.WasmApp { | ||
db := dbm.NewMemDB() | ||
app := wasmd.NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, homeDir, 5, wasm.EnableAllProposals, wasmd.EmptyAppOptions{}) | ||
// app := wasmd.NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, 0) | ||
if !isCheckTx { | ||
// init chain must be called to stop deliverState from being nil | ||
genesisState := wasmd.NewDefaultGenesisState() | ||
stateBytes, err := json.Marshal(genesisState) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Initialize the chain | ||
app.InitChain( | ||
abci.RequestInitChain{ | ||
Validators: []abci.ValidatorUpdate{}, | ||
AppStateBytes: stateBytes, | ||
}, | ||
) | ||
} | ||
|
||
return app | ||
} | ||
|
||
type GenesisState map[string]json.RawMessage | ||
|
||
// NewDefaultGenesisState generates the default state for the application. | ||
func NewDefaultGenesisState() GenesisState { | ||
encCfg := wasmd.MakeEncodingConfig() | ||
return wasmd.ModuleBasics.DefaultGenesis(encCfg.Marshaler) | ||
} | ||
|
||
func SetupWithGenesisValSet(t *testing.T, homeDir string, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *wasmd.WasmApp { | ||
db := dbm.NewMemDB() | ||
app := wasmd.NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, homeDir, 5, wasm.EnableAllProposals, wasmd.EmptyAppOptions{}) | ||
genesisState := NewDefaultGenesisState() | ||
|
||
// set genesis accounts | ||
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) | ||
appCodec := wasmd.NewTestSupport(t, app).AppCodec() | ||
genesisState[authtypes.ModuleName] = appCodec.MustMarshalJSON(authGenesis) | ||
|
||
validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) | ||
delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) | ||
|
||
bondAmt := sdk.NewInt(1000000) | ||
|
||
for _, val := range valSet.Validators { | ||
// Currently validator requires tmcrypto.ed25519 keys, which don't support | ||
// our Marshaling interfaces, so we need to pack them into our version of ed25519. | ||
// There is ongoing work to add secp256k1 keys (https://github.com/cosmos/cosmos-sdk/pull/7604). | ||
pk, err := ed25519.FromTmEd25519(val.PubKey) | ||
require.NoError(t, err) | ||
pkAny, err := codectypes.PackAny(pk) | ||
require.NoError(t, err) | ||
validator := stakingtypes.Validator{ | ||
OperatorAddress: sdk.ValAddress(val.Address).String(), | ||
ConsensusPubkey: pkAny, | ||
Jailed: false, | ||
Status: stakingtypes.Bonded, | ||
Tokens: bondAmt, | ||
DelegatorShares: sdk.OneDec(), | ||
Description: stakingtypes.Description{}, | ||
UnbondingHeight: int64(0), | ||
UnbondingTime: time.Unix(0, 0).UTC(), | ||
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), | ||
MinSelfDelegation: sdk.ZeroInt(), | ||
} | ||
validators = append(validators, validator) | ||
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) | ||
|
||
} | ||
|
||
// set validators and delegations | ||
stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) | ||
genesisState[stakingtypes.ModuleName] = appCodec.MustMarshalJSON(stakingGenesis) | ||
|
||
totalSupply := sdk.NewCoins() | ||
for _, b := range balances { | ||
// add genesis acc tokens and delegated tokens to total supply | ||
totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt))...) | ||
} | ||
|
||
// update total supply | ||
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}) | ||
genesisState[banktypes.ModuleName] = appCodec.MustMarshalJSON(bankGenesis) | ||
|
||
stateBytes, err := json.MarshalIndent(genesisState, "", " ") | ||
require.NoError(t, err) | ||
|
||
// init chain will set the validator set and initialize the genesis accounts | ||
app.InitChain( | ||
abci.RequestInitChain{ | ||
Validators: []abci.ValidatorUpdate{}, | ||
ConsensusParams: DefaultConsensusParams, | ||
AppStateBytes: stateBytes, | ||
}, | ||
) | ||
|
||
// commit genesis changes | ||
app.Commit() | ||
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ | ||
Height: app.LastBlockHeight() + 1, | ||
AppHash: app.LastCommitID().Hash, | ||
ValidatorsHash: valSet.Hash(), | ||
NextValidatorsHash: valSet.Hash(), | ||
}}) | ||
|
||
return app | ||
} | ||
|
||
var DefaultConsensusParams = &abci.ConsensusParams{ | ||
Block: &abci.BlockParams{ | ||
MaxBytes: 200000, | ||
MaxGas: 2000000, | ||
}, | ||
Evidence: &tmproto.EvidenceParams{ | ||
MaxAgeNumBlocks: 302400, | ||
MaxAgeDuration: 1814400, | ||
}, | ||
Validator: &tmproto.ValidatorParams{ | ||
PubKeyTypes: []string{ | ||
tmtypes.ABCIPubKeyTypeEd25519, | ||
}, | ||
}, | ||
} | ||
|
||
// SignCheckDeliver checks a generated signed transaction and simulates a | ||
// block commitment with the given transaction. A test assertion is made using | ||
// the parameter 'expPass' against the result. A corresponding result is | ||
// returned. | ||
func SignCheckDeliver( | ||
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, | ||
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey, | ||
) (sdk.GasInfo, *sdk.Result, error) { | ||
|
||
tx, err := helpers.GenTx( | ||
txCfg, | ||
msgs, | ||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, | ||
helpers.DefaultGenTxGas, | ||
chainID, | ||
accNums, | ||
accSeqs, | ||
priv..., | ||
) | ||
require.NoError(t, err) | ||
txBytes, err := txCfg.TxEncoder()(tx) | ||
require.Nil(t, err) | ||
|
||
// Must simulate now as CheckTx doesn't run Msgs anymore | ||
_, res, err := app.Simulate(txBytes) | ||
|
||
if expSimPass { | ||
require.NoError(t, err) | ||
require.NotNil(t, res) | ||
} else { | ||
require.Error(t, err) | ||
require.Nil(t, res) | ||
} | ||
|
||
// Simulate a sending a transaction and committing a block | ||
app.BeginBlock(abci.RequestBeginBlock{Header: header}) | ||
gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx) | ||
|
||
if expPass { | ||
require.NoError(t, err) | ||
require.NotNil(t, res) | ||
} else { | ||
require.Error(t, err) | ||
require.Nil(t, res) | ||
} | ||
|
||
app.EndBlock(abci.RequestEndBlock{}) | ||
app.Commit() | ||
|
||
return gInfo, res, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/CosmWasm/wasmd/x/wasm" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" | ||
ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/keeper" | ||
ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper" | ||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" | ||
) | ||
|
||
type TestSupport struct { | ||
t *testing.T | ||
app *WasmApp | ||
} | ||
|
||
func NewTestSupport(t *testing.T, app *WasmApp) *TestSupport { | ||
return &TestSupport{t: t, app: app} | ||
} | ||
|
||
func (s TestSupport) IBCKeeper() ibckeeper.Keeper { | ||
return *s.app.ibcKeeper | ||
} | ||
|
||
func (s TestSupport) WasmKeeper() wasm.Keeper { | ||
return s.app.wasmKeeper | ||
} | ||
|
||
func (s TestSupport) AppCodec() codec.Marshaler { | ||
return s.app.appCodec | ||
} | ||
|
||
func (s TestSupport) StakingKeeper() stakingkeeper.Keeper { | ||
return s.app.stakingKeeper | ||
} | ||
|
||
func (s TestSupport) BankKeeper() bankkeeper.Keeper { | ||
return s.app.bankKeeper | ||
} | ||
|
||
func (s TestSupport) TransferKeeper() ibctransferkeeper.Keeper { | ||
return s.app.transferKeeper | ||
} | ||
|
||
// EmptyAppOptions is a stub implementing AppOptions | ||
type EmptyAppOptions struct{} | ||
|
||
// Get implements AppOptions | ||
func (ao EmptyAppOptions) Get(o string) interface{} { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters