Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor 04-channel/keeper tests to ibc testing pkg #6400

Merged
merged 56 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
48adee9
update testing pkg and first keeper test
colin-axner Jun 11, 2020
b855979
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 11, 2020
4493ff7
fix version bug
colin-axner Jun 11, 2020
8154210
merge master
colin-axner Jun 12, 2020
59cbe4f
add more helper testing funcs
colin-axner Jun 12, 2020
57c8c90
merge master
colin-axner Jun 12, 2020
edcbd00
move create header to testing pkg
colin-axner Jun 12, 2020
190a885
fix connection state bug
colin-axner Jun 12, 2020
5378d54
add staking genesis state
colin-axner Jun 13, 2020
f22d3af
update simapp with setting validator helper func
colin-axner Jun 16, 2020
8019f55
merge master
colin-axner Jun 16, 2020
f6fe54f
update simapp with valset helper
colin-axner Jun 17, 2020
0c49a0c
fix app hash issue
colin-axner Jun 17, 2020
e1bbac7
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 17, 2020
2f3e1d0
update to query from correct iavl proof height
colin-axner Jun 17, 2020
6663892
first keeper test passing
colin-axner Jun 19, 2020
bc9125b
second test passing :tada:
colin-axner Jun 19, 2020
0cedb42
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 19, 2020
3d9a869
fix build
colin-axner Jun 19, 2020
28d3223
update tests in all keeper_test
colin-axner Jun 19, 2020
65074fb
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 19, 2020
ee6ce43
fix lint
colin-axner Jun 19, 2020
53a8433
begin refactoring querier test
colin-axner Jun 19, 2020
6adf52a
update first querier test and update testing helpers
colin-axner Jun 22, 2020
5fdda8e
finish updating rest of querier tests
colin-axner Jun 22, 2020
77db59b
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 22, 2020
e520bc1
rename ChannelID in TestChannel to ID
colin-axner Jun 22, 2020
b4d1781
remove usage of chain id for calling helper funcs
colin-axner Jun 22, 2020
5af92a6
update openinit and opentry tests
colin-axner Jun 22, 2020
10aae3b
finish opening channel handshake tests
colin-axner Jun 23, 2020
94ba817
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 23, 2020
05a64f8
finish handshake tests
colin-axner Jun 23, 2020
0faaf8c
general testing pkg cleanup
colin-axner Jun 23, 2020
50a7b25
finish packetsend refactor
colin-axner Jun 24, 2020
19bb14f
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 24, 2020
8c0912c
update recvpacket
colin-axner Jun 24, 2020
2021708
packet executed refactored
colin-axner Jun 24, 2020
e5f67ee
finish packet test :tada:
colin-axner Jun 25, 2020
c5754cf
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 25, 2020
bd4c112
all tests passing
colin-axner Jun 25, 2020
642529b
cleanup and increase code cov
colin-axner Jun 25, 2020
8072e13
remove todos in favor of opened issue #6509
colin-axner Jun 25, 2020
649b788
Merge branch 'master' into colin/5558-remove-dup-channel
colin-axner Jun 25, 2020
d1de17f
bump invalid id to meet validation requirements
colin-axner Jun 25, 2020
a804ce0
Merge branch 'colin/5558-remove-dup-channel' of github.com:cosmos/cos…
colin-axner Jun 25, 2020
b55c2eb
bubble up proof height + 1
colin-axner Jun 25, 2020
2d96bc4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/5558…
colin-axner Jun 26, 2020
fb89629
Apply suggestions from code review
colin-axner Jun 26, 2020
8123337
fix uninit conn test
colin-axner Jun 26, 2020
ce1c268
Merge branch 'colin/5558-remove-dup-channel' of github.com:cosmos/cos…
colin-axner Jun 26, 2020
cbab3ea
fix compile and address various pr review issues
colin-axner Jun 26, 2020
42ee985
Update x/ibc/04-channel/keeper/handshake_test.go
colin-axner Jun 26, 2020
5c8a180
Update x/ibc/04-channel/keeper/handshake_test.go
colin-axner Jun 26, 2020
9e208ce
address @AdityaSripal comments and increase cov
colin-axner Jun 26, 2020
3327a88
Merge branch 'master' into colin/5558-remove-dup-channel
colin-axner Jun 26, 2020
5c62ddf
Merge branch 'master' into colin/5558-remove-dup-channel
colin-axner Jun 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"strconv"
"testing"
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -21,6 +22,7 @@ import (
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"
)

// DefaultConsensusParams defines the default Tendermint consensus params used in
Expand Down Expand Up @@ -67,6 +69,79 @@ func Setup(isCheckTx bool) *SimApp {
return app
}

// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit (10^6) in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
db := dbm.NewMemDB()
app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5)

genesisState := NewDefaultGenesisState()

// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
genesisState[authtypes.ModuleName] = app.Codec().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 {
validator := stakingtypes.Validator{
OperatorAddress: val.Address.Bytes(),
ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, val.PubKey),
Jailed: false,
Status: sdk.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] = app.Codec().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().SendEnabled, balances, totalSupply)
genesisState[banktypes.ModuleName] = app.Codec().MustMarshalJSON(bankGenesis)

stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
if err != nil {
panic(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: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}})

return app
}

// SetupWithGenesisAccounts initializes a new SimApp with the provided genesis
// accounts and possible balances.
func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
Expand Down
Loading