-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 x/staking Validation and Delegation tests based on MsgCreateValidator.Pubkey type change. #7526
Merged
Merged
Refactor x/staking Validation and Delegation tests based on MsgCreateValidator.Pubkey type change. #7526
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
425cec7
testing: refactore Validation and Delegation handling of x/staking
robert-zaremba 744e299
add validator checks
robert-zaremba 1741fe0
type change fixes
robert-zaremba a29648d
use deprecated
robert-zaremba 0090ab3
adding test slashing
robert-zaremba d527c77
new network comment update
robert-zaremba 1a29257
working on tests
robert-zaremba 819c52e
Fix TestMsgPkDecode test
blushi 11924dd
Add UnpackInterfaces to MsgCreateValidator
blushi e36a543
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into robe…
amaury1093 883ced6
Fix tests
amaury1093 9b7d36e
Convert bech32 pubkey to proto
amaury1093 f2c4dc9
Fix test
amaury1093 9f8b828
fix v039/migrate_test/TestMigrate
clevinson b610de8
fix tests
robert-zaremba 16448b8
testslashing: rename Service to Helper
robert-zaremba b741a6d
file rename
robert-zaremba b7eef7d
update TestMsgDecode
robert-zaremba 826e771
Merge branch 'master' into robert/staking-test-service
robert-zaremba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 | ||
---|---|---|---|---|
|
@@ -9,12 +9,15 @@ import ( | |||
"strings" | ||||
|
||||
"github.com/tendermint/tendermint/crypto" | ||||
tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" | ||||
yaml "gopkg.in/yaml.v2" | ||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy" | ||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" | ||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | ||||
"github.com/cosmos/cosmos-sdk/types/bech32" | ||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||||
) | ||||
|
||||
const ( | ||||
|
@@ -674,12 +677,32 @@ func GetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) (crypto.PubKey, | |||
return nil, err | ||||
} | ||||
|
||||
pk, err := cryptocodec.PubKeyFromBytes(bz) | ||||
aminoPk, err := cryptocodec.PubKeyFromBytes(bz) | ||||
if err != nil { | ||||
return nil, err | ||||
} | ||||
|
||||
return pk, nil | ||||
var protoPk crypto.PubKey | ||||
switch aminoPk.(type) { | ||||
|
||||
// We are bech32ifying some secp256k1 keys in tests. | ||||
case *secp256k1.PubKey: | ||||
protoPk = aminoPk | ||||
robert-zaremba marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
case *ed25519.PubKey: | ||||
protoPk = aminoPk | ||||
|
||||
// Real-life case. | ||||
case tmed25519.PubKey: | ||||
protoPk = &ed25519.PubKey{ | ||||
Key: aminoPk.Bytes(), | ||||
} | ||||
|
||||
default: | ||||
// We only allow ed25519 pubkeys to be bech32-ed right now. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm removing this in other PR. |
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "bech32 pubkey does not support %T", aminoPk) | ||||
} | ||||
|
||||
return protoPk, nil | ||||
} | ||||
|
||||
// MustGetPubKeyFromBech32 calls GetPubKeyFromBech32 except it panics on error. | ||||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should clearly indicate that this is only for legacy code. I would even add a deprecated comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've market this function as deprecated.