Skip to content

Commit

Permalink
improved UT
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Oct 11, 2024
1 parent b3288d4 commit a64c2cf
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions x/sequencer/keeper/msg_server_create_sequencer_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package keeper_test

import (
"errors"
"fmt"
"reflect"
"time"

errorsmod "cosmossdk.io/errors"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -25,6 +27,8 @@ const (
var bond = types.DefaultParams().MinBond

func (suite *SequencerTestSuite) TestMinBond() {
panicErr := errors.New("panic")

testCases := []struct {
name string
requiredBond sdk.Coin
Expand All @@ -37,12 +41,6 @@ func (suite *SequencerTestSuite) TestMinBond() {
bond: bond,
expectedError: nil,
},
{
name: "Bad denom",
requiredBond: bond,
bond: sdk.NewCoin("invalid", sdk.NewInt(100)),
expectedError: types.ErrInvalidCoinDenom,
},
{
name: "Insufficient bond",
requiredBond: bond,
Expand All @@ -52,8 +50,8 @@ func (suite *SequencerTestSuite) TestMinBond() {
{
name: "wrong bond denom",
requiredBond: bond,
bond: sdk.NewCoin("eth", bond.Amount),
expectedError: types.ErrInvalidCoinDenom,
bond: sdk.NewCoin("nonbonddenom", bond.Amount),
expectedError: panicErr,
},
}

Expand Down Expand Up @@ -87,7 +85,7 @@ func (suite *SequencerTestSuite) TestMinBond() {
func() {
defer func() {
if r := recover(); r != nil {
createErr = fmt.Errorf("panic in CreateSequencer: %v", r)
createErr = errorsmod.Wrapf(panicErr, "panic: %v", r)
}
}()
_, createErr = suite.msgServer.CreateSequencer(suite.Ctx, &sequencerMsg1)
Expand Down

0 comments on commit a64c2cf

Please sign in to comment.