@@ -16,6 +16,7 @@ import (
16
16
17
17
transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
18
18
channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"
19
+ channeltypesv2 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/v2/types"
19
20
)
20
21
21
22
const (
@@ -391,6 +392,51 @@ func (s *KeeperTestSuite) TestAcknowledgeRateLimitedPacket_AckFailure() {
391
392
s .Require ().Equal (initialOutflow .Sub (packetAmount ).Int64 (), rateLimit .Flow .Outflow .Int64 (), "outflow" )
392
393
}
393
394
395
+ func (s * KeeperTestSuite ) TestAcknowledgeRateLimitedPacket_UniversalErrorAck () {
396
+ // For ack packets, the source will be stride and the destination will be the host
397
+ denom := ustrd
398
+ sourceChannel := channelOnStride
399
+ destinationChannel := channelOnHost
400
+ initialOutflow := sdkmath .NewInt (100 )
401
+ packetAmount := sdkmath .NewInt (10 )
402
+ sequence := uint64 (10 )
403
+
404
+ // Create rate limit - only outflow is needed to this tests
405
+ s .App .RatelimitKeeper .SetRateLimit (s .Ctx , types.RateLimit {
406
+ Path : & types.Path {Denom : denom , ChannelOrClientId : channelId },
407
+ Flow : & types.Flow {Outflow : initialOutflow },
408
+ })
409
+
410
+ // Store the pending packet for this sequence number
411
+ s .App .RatelimitKeeper .SetPendingSendPacket (s .Ctx , sourceChannel , sequence )
412
+
413
+ // Build the ack packet
414
+ packetData , err := json .Marshal (transfertypes.FungibleTokenPacketData {Denom : denom , Amount : packetAmount .String ()})
415
+ s .Require ().NoError (err )
416
+ packet := channeltypes.Packet {
417
+ SourcePort : transferPort ,
418
+ SourceChannel : sourceChannel ,
419
+ DestinationPort : transferPort ,
420
+ DestinationChannel : destinationChannel ,
421
+ Data : packetData ,
422
+ Sequence : sequence ,
423
+ }
424
+ ackFailure := channeltypesv2 .ErrorAcknowledgement [:]
425
+
426
+ // Call OnTimeoutPacket with the failed ack
427
+ err = s .App .RatelimitKeeper .AcknowledgeRateLimitedPacket (s .Ctx , packet , ackFailure )
428
+ s .Require ().NoError (err , "no error expected during AckPacket" )
429
+
430
+ // Confirm the pending packet was removed
431
+ found := s .App .RatelimitKeeper .CheckPacketSentDuringCurrentQuota (s .Ctx , sourceChannel , sequence )
432
+ s .Require ().False (found , "send packet should have been removed" )
433
+
434
+ // Confirm the flow was adjusted
435
+ rateLimit , found := s .App .RatelimitKeeper .GetRateLimit (s .Ctx , denom , sourceChannel )
436
+ s .Require ().True (found )
437
+ s .Require ().Equal (initialOutflow .Sub (packetAmount ).Int64 (), rateLimit .Flow .Outflow .Int64 (), "outflow" )
438
+ }
439
+
394
440
func (s * KeeperTestSuite ) TestTimeoutRateLimitedPacket () {
395
441
// For timeout packets, the source will be stride and the destination will be the host
396
442
denom := ustrd
0 commit comments