Refactor x/staking Validation and Delegation tests based on MsgCreateValidator.Pubkey type change. (#7526)

* testing: refactore Validation and Delegation handling of x/staking

This Changeset introduces set of improvements for writing tests.

The idea is to create a testing subpackage which will provide functions
to make tests more dev-friendly and wrap higher level use-cases.
Here is a show-up of of creating a service for staking module
for tests.

This PR also changes the `x/staking/types.MsgCreateValidator.Pubkey` from string
to types.Any. This change motivated the other change to show the pattern I'm describing here.

* add validator checks

* type change fixes

* use deprecated

* adding test slashing

* new network comment update

* working on tests

* Fix TestMsgPkDecode test

* Add UnpackInterfaces to MsgCreateValidator

* Fix tests

* Convert bech32 pubkey to proto

* Fix test

* fix v039/migrate_test/TestMigrate

* fix tests

* testslashing: rename Service to Helper

* file rename

* update TestMsgDecode

Co-authored-by: blushi <marie.gauthier63@gmail.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>
This commit is contained in:
Robert Zaremba
2020-10-19 13:04:55 +00:00
committed by GitHub
co-authored by blushi Amaury Martiny Cory Levinson
parent 0f8fdf60df
commit 8eaf2ececc
39 changed files with 778 additions and 1092 deletions
+3 -1
View File
@@ -162,6 +162,7 @@ type (
}
)
// New creates a new Network for integration tests.
func New(t *testing.T, cfg Config) *Network {
// only one caller/test can create and use a network at a time
t.Log("acquiring test network lock")
@@ -293,7 +294,7 @@ func New(t *testing.T, cfg Config) *Network {
commission, err := sdk.NewDecFromStr("0.5")
require.NoError(t, err)
createValMsg := stakingtypes.NewMsgCreateValidator(
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valPubKeys[i],
sdk.NewCoin(sdk.DefaultBondDenom, cfg.BondedTokens),
@@ -301,6 +302,7 @@ func New(t *testing.T, cfg Config) *Network {
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
)
require.NoError(t, err)
p2pURL, err := url.Parse(p2pAddr)
require.NoError(t, err)