Skip to content

Commit

Permalink
Add endpoint.ChanUpgradeAck.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim committed May 31, 2023
1 parent 289e624 commit 305f177
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,33 @@ func (endpoint *Endpoint) ChanUpgradeTry(timeout channeltypes.Timeout) error {
return endpoint.Chain.sendMsgs(msg)
}

// ChanUpgradeAck sends a MsgChannelUpgradeAck to the associated endpoint.
func (endpoint *Endpoint) ChanUpgradeAck() error {
counterpartyChannelID := endpoint.Counterparty.ChannelID
counterpartyPortID := endpoint.Counterparty.ChannelConfig.PortID

channelKey := host.ChannelKey(counterpartyPortID, counterpartyChannelID)
proofChannel, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
upgradeKey := host.ChannelUpgradeKey(counterpartyPortID, counterpartyChannelID)
proofUpgrade, _ := endpoint.Counterparty.Chain.QueryProof(upgradeKey)

counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), counterpartyPortID, counterpartyChannelID)
require.True(endpoint.Chain.TB, found)

msg := channeltypes.NewMsgChannelUpgradeAck(
endpoint.ChannelConfig.PortID,
endpoint.ChannelID,
endpoint.Counterparty.GetChannel().FlushStatus,
counterpartyUpgrade,
proofChannel,
proofUpgrade,
height,
endpoint.Chain.SenderAccount.GetAddress().String(),
)

return endpoint.Chain.sendMsgs(msg)
}

// SetChannelState sets a channel state
func (endpoint *Endpoint) SetChannelState(state channeltypes.State) error {
channel := endpoint.GetChannel()
Expand Down

0 comments on commit 305f177

Please sign in to comment.