Skip to content

Commit

Permalink
nit: using NewPacketId helper and updating helper def to have correct…
Browse files Browse the repository at this point in the history
… params
  • Loading branch information
seantking committed Nov 24, 2021
1 parent 7581a7c commit 0421fd9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
31 changes: 20 additions & 11 deletions modules/apps/29-fee/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper_test
import (
"github.com/cosmos/ibc-go/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/testing"
)

Expand All @@ -12,11 +11,16 @@ func (suite *KeeperTestSuite) TestInitGenesis() {

// build PacketId & Fee
refundAcc := suite.chainA.SenderAccount.GetAddress()
ackFee := validCoins
receiveFee := validCoins2
timeoutFee := validCoins3
packetId := &channeltypes.PacketId{ChannelId: ibctesting.FirstChannelID, PortId: types.PortID, Sequence: uint64(1)}
fee := types.Fee{ackFee, receiveFee, timeoutFee}
packetId := types.NewPacketId(
ibctesting.FirstChannelID,
types.PortID,
uint64(1),
)
fee := types.Fee{
validCoins,
validCoins2,
validCoins3,
}

// relayer addresses
sender := suite.chainA.SenderAccount.GetAddress().String()
Expand Down Expand Up @@ -69,11 +73,16 @@ func (suite *KeeperTestSuite) TestExportGenesis() {

// setup & escrow the packet fee
refundAcc := suite.chainA.SenderAccount.GetAddress()
ackFee := validCoins
receiveFee := validCoins2
timeoutFee := validCoins3
packetId := &channeltypes.PacketId{ChannelId: ibctesting.FirstChannelID, PortId: types.PortID, Sequence: uint64(1)}
fee := types.Fee{ackFee, receiveFee, timeoutFee}
packetId := types.NewPacketId(
ibctesting.FirstChannelID,
types.PortID,
uint64(1),
)
fee := types.Fee{
validCoins,
validCoins2,
validCoins3,
}
identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}}
err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee)
suite.Require().NoError(err)
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/29-fee/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() {
)

// setup
validPacketId := types.NewPacketId(ibctesting.FirstChannelID, 1)
invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, 2)
validPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1)
invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2)
identifiedPacketFee := types.NewIdentifiedPacketFee(
validPacketId,
types.Fee{
Expand Down Expand Up @@ -110,9 +110,9 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() {
func() {
refundAcc := suite.chainA.SenderAccount.GetAddress()

fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 1), fee, refundAcc.String(), []string(nil))
fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 2), fee, refundAcc.String(), []string(nil))
fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 3), fee, refundAcc.String(), []string(nil))
fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1), fee, refundAcc.String(), []string(nil))
fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2), fee, refundAcc.String(), []string(nil))
fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 3), fee, refundAcc.String(), []string(nil))

expPackets = []*types.IdentifiedPacketFee{}
expPackets = append(expPackets, fee1, fee2, fee3)
Expand Down
6 changes: 4 additions & 2 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr
}
}

func NewPacketId(channelId string, id uint64) *channeltypes.PacketId {
return &channeltypes.PacketId{ChannelId: channelId, PortId: PortID, Sequence: id}
// NewPacketId returns a new instance of PacketId
// TODO: move to channeltypes
func NewPacketId(channelId, portId string, seq uint64) *channeltypes.PacketId {
return &channeltypes.PacketId{ChannelId: channelId, PortId: portId, Sequence: seq}
}

0 comments on commit 0421fd9

Please sign in to comment.