Skip to content

Commit

Permalink
chore: fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Jul 7, 2023
1 parent 2d03e3a commit f35a783
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tests/integration/genutil/gentx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"cosmossdk.io/math"
"github.com/cometbft/cometbft/crypto/tmhash"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1"
Expand Down Expand Up @@ -86,17 +87,21 @@ func (suite *GenTxTestSuite) SetupTest() {
amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)
one := math.OneInt()
blsSecretKey1, _ := bls.RandKey()
blsProofBuf := blsSecretKey1.Sign(tmhash.Sum(blsSecretKey1.PublicKey().Marshal()))
blsProof1 := hex.EncodeToString(blsProofBuf.Marshal())
blsPk1 := hex.EncodeToString(blsSecretKey1.PublicKey().Marshal())

suite.msg1, err = stakingtypes.NewMsgCreateValidator(
sdk.AccAddress(pk1.Address()), pk1, amount, desc, comm, one, sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), blsPk1)
sdk.AccAddress(pk1.Address()), pk1, amount, desc, comm, one, sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), sdk.AccAddress(pk1.Address()), blsPk1, blsProof1)
suite.NoError(err)

blsSecretKey2, _ := bls.RandKey()
blsPk2 := hex.EncodeToString(blsSecretKey2.PublicKey().Marshal())
blsProofBuf = blsSecretKey2.Sign(tmhash.Sum(blsSecretKey2.PublicKey().Marshal()))
blsProof2 := hex.EncodeToString(blsProofBuf.Marshal())

suite.msg2, err = stakingtypes.NewMsgCreateValidator(
sdk.AccAddress(pk2.Address()), pk1, amount, desc, comm, one, sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), blsPk2)
sdk.AccAddress(pk2.Address()), pk1, amount, desc, comm, one, sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), sdk.AccAddress(pk2.Address()), blsPk2, blsProof2)
suite.NoError(err)
}

Expand Down
2 changes: 1 addition & 1 deletion x/staking/testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewHelper(t *testing.T, ctx sdk.Context, k *keeper.Keeper) *Helper {
}

// CreateValidator calls staking module `MsgServer/CreateValidator` to create a new validator
func (sh *Helper) CreateValidator(addr sdk.AccAddress, pk cryptotypes.PubKey, pv cryptotypes.PrivKey, stakeAmount math.Int, ok bool) {
func (sh *Helper) CreateValidator(addr sdk.AccAddress, pk cryptotypes.PubKey, stakeAmount math.Int, ok bool) {
coin := sdk.NewCoin(sh.Denom, stakeAmount)
sh.createValidator(addr, pk, coin, ok)
}
Expand Down
4 changes: 2 additions & 2 deletions x/staking/types/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
Expand All @@ -41,7 +41,7 @@ func TestMsgDecode(t *testing.T) {
var pkUnmarshaled cryptotypes.PubKey
err = cdc.UnmarshalInterface(pk1bz, &pkUnmarshaled)
require.NoError(t, err)
require.True(t, pk1.Equals(pkUnmarshaled.(*ethsecp256k1.PubKey)))
require.True(t, pk1.Equals(pkUnmarshaled.(*ed25519.PubKey)))

// now let's try to serialize the whole message
blsSecretKey, _ := bls.RandKey()
Expand Down

0 comments on commit f35a783

Please sign in to comment.