Skip to content

Commit

Permalink
gofumpt for v2.2.x (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat authored Jul 27, 2022
1 parent b7a7231 commit 989dcd0
Show file tree
Hide file tree
Showing 78 changed files with 175 additions and 228 deletions.
2 changes: 0 additions & 2 deletions modules/apps/transfer/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest)
}

hash, err := types.ParseHexHash(strings.TrimPrefix(req.Hash, "ibc/"))

if err != nil {
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", hash.String(), err))
}
Expand Down Expand Up @@ -63,7 +62,6 @@ func (q Keeper) DenomTraces(c context.Context, req *types.QueryDenomTracesReques
traces = append(traces, result)
return nil
})

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion modules/apps/transfer/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (suite *KeeperTestSuite) TestQueryParams() {
}

func (suite *KeeperTestSuite) TestQueryDenomHash() {

reqTrace := types.DenomTrace{
Path: "transfer/channelToA/transfer/channelToB",
BaseDenom: "uatom",
Expand Down
1 change: 0 additions & 1 deletion modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func NewKeeper(
channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper,
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
) Keeper {

// ensure ibc transfer module account is set
if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil {
panic("the IBC transfer module account has not been set")
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/mbt_relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() {
panic(fmt.Errorf("Failed to read model-based test files: %w", err))
}
for _, file_info := range files {
var tlaTestCases = []TlaOnRecvPacketTestCase{}
tlaTestCases := []TlaOnRecvPacketTestCase{}
if !strings.HasSuffix(file_info.Name(), ".json") {
continue
}
Expand Down
1 change: 0 additions & 1 deletion modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (k Keeper) SendTransfer(
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
) error {

if !k.GetSendEnabled(ctx) {
return types.ErrSendDisabled
}
Expand Down
84 changes: 56 additions & 28 deletions modules/apps/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,32 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
sendFromSource bool
expPass bool
}{
{"successful transfer from source chain",
{
"successful transfer from source chain",
func() {
suite.coordinator.CreateTransferChannels(path)
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
}, true, true},
{"successful transfer with coin from counterparty chain",
}, true, true,
},
{
"successful transfer with coin from counterparty chain",
func() {
// send coin from chainA back to chainB
suite.coordinator.CreateTransferChannels(path)
amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom, sdk.NewInt(100))
}, false, true},
{"source channel not found",
}, false, true,
},
{
"source channel not found",
func() {
// channel references wrong ID
suite.coordinator.CreateTransferChannels(path)
path.EndpointA.ChannelID = ibctesting.InvalidID
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
}, true, false},
{"next seq send not found",
}, true, false,
},
{
"next seq send not found",
func() {
path.EndpointA.ChannelID = "channel-0"
path.EndpointB.ChannelID = "channel-0"
Expand All @@ -58,30 +65,37 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
)
suite.chainA.CreateChannelCapability(suite.chainA.GetSimApp().ScopedIBCMockKeeper, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
}, true, false},
}, true, false,
},

// createOutgoingPacket tests
// - source chain
{"send coin failed",
{
"send coin failed",
func() {
suite.coordinator.CreateTransferChannels(path)
amount = sdk.NewCoin("randomdenom", sdk.NewInt(100))
}, true, false},
}, true, false,
},
// - receiving chain
{"send from module account failed",
{
"send from module account failed",
func() {
suite.coordinator.CreateTransferChannels(path)
amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, " randomdenom", sdk.NewInt(100))
}, false, false},
{"channel capability not found",
}, false, false,
},
{
"channel capability not found",
func() {
suite.coordinator.CreateTransferChannels(path)
cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)

// Release channel capability
suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap)
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
}, true, false},
}, true, false,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -265,18 +279,22 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() {

suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin)))
}, false, true},
{"unsuccessful refund from source", failedAck,
{
"unsuccessful refund from source", failedAck,
func() {
trace = types.ParseDenomTrace(sdk.DefaultBondDenom)
}, false, false},
{"successful refund from with coin from external chain", failedAck,
}, false, false,
},
{
"successful refund from with coin from external chain", failedAck,
func() {
escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom))
coin := sdk.NewCoin(trace.IBCDenom(), amount)

suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin)))
}, false, true},
}, false, true,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -331,36 +349,46 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() {
malleate func()
expPass bool
}{
{"successful timeout from sender as source chain",
{
"successful timeout from sender as source chain",
func() {
escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
trace = types.ParseDenomTrace(sdk.DefaultBondDenom)
coin := sdk.NewCoin(trace.IBCDenom(), amount)

suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin)))
}, true},
{"successful timeout from external chain",
}, true,
},
{
"successful timeout from external chain",
func() {
escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom))
coin := sdk.NewCoin(trace.IBCDenom(), amount)

suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin)))
}, true},
{"no balance for coin denom",
}, true,
},
{
"no balance for coin denom",
func() {
trace = types.ParseDenomTrace("bitcoin")
}, false},
{"unescrow failed",
}, false,
},
{
"unescrow failed",
func() {
trace = types.ParseDenomTrace(sdk.DefaultBondDenom)
}, false},
{"mint failed",
}, false,
},
{
"mint failed",
func() {
trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom))
amount = sdk.OneInt()
sender = "invalid address"
}, false},
}, false,
},
}

for _, tc := range testCases {
Expand Down
6 changes: 0 additions & 6 deletions modules/apps/transfer/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() {
malleate func()
expPass bool
}{

{
"success", func() {}, true,
},
Expand Down Expand Up @@ -92,7 +91,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() {
} else {
suite.Require().Error(err)
}

})
}
}
Expand All @@ -110,7 +108,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {
malleate func()
expPass bool
}{

{
"success", func() {}, true,
},
Expand Down Expand Up @@ -187,7 +184,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {
} else {
suite.Require().Error(err)
}

})
}
}
Expand All @@ -200,7 +196,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() {
malleate func()
expPass bool
}{

{
"success", func() {}, true,
},
Expand Down Expand Up @@ -237,7 +232,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() {
} else {
suite.Require().Error(err)
}

})
}
}
1 change: 0 additions & 1 deletion modules/apps/transfer/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestRandomizedGenState(t *testing.T) {
require.True(t, ibcTransferGenesis.Params.SendEnabled)
require.True(t, ibcTransferGenesis.Params.ReceiveEnabled)
require.Len(t, ibcTransferGenesis.DenomTraces, 0)

}

// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState.
Expand Down
1 change: 0 additions & 1 deletion modules/apps/transfer/types/ack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ func (suite *TypesTestSuite) TestAcknowledgementError() {

suite.Require().Equal(ack, ackSameABCICode)
suite.Require().NotEqual(ack, ackDifferentABCICode)

}
1 change: 0 additions & 1 deletion modules/apps/transfer/types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func ReceiverChainIsSource(sourcePort, sourceChannel, denom string) bool {

voucherPrefix := GetDenomPrefix(sourcePort, sourceChannel)
return strings.HasPrefix(denom, voucherPrefix)

}

// GetDenomPrefix returns the receiving denomination prefix
Expand Down
3 changes: 2 additions & 1 deletion modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
// UpgradeClient upgrades the client to a new client state if this new client was committed to
// by the old client at the specified upgrade height
func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState,
proofUpgradeClient, proofUpgradeConsState []byte) error {
proofUpgradeClient, proofUpgradeConsState []byte,
) error {
clientState, found := k.GetClientState(ctx, clientID)
if !found {
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
Expand Down
3 changes: 0 additions & 3 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
suite.Require().Error(err, "verify upgrade passed on invalid case: %s", tc.name)
}
}

}

func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
Expand Down Expand Up @@ -695,8 +694,6 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() {
suite.Require().NoError(err)
suite.Require().Equal(header, emittedHeader)
}

}
suite.Require().True(contains)

}
2 changes: 0 additions & 2 deletions modules/core/02-client/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ
clientStates = append(clientStates, identifiedClient)
return nil
})

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -177,7 +176,6 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat
consensusStates = append(consensusStates, types.NewConsensusStateWithHeight(height, consensusState))
return true, nil
})

if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 989dcd0

Please sign in to comment.