@@ -1110,7 +1110,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
11101110func (suite * KeeperTestSuite ) TestQueryUnreceivedPackets () {
11111111 var (
11121112 req * types.QueryUnreceivedPacketsRequest
1113- expSeq = []uint64 {}
1113+ expSeq = []uint64 ( nil )
11141114 )
11151115
11161116 testCases := []struct {
@@ -1156,6 +1156,46 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
11561156 },
11571157 false ,
11581158 },
1159+ {
1160+ "invalid seq, ordered channel" ,
1161+ func () {
1162+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1163+ path .SetChannelOrdered ()
1164+ suite .coordinator .Setup (path )
1165+
1166+ req = & types.QueryUnreceivedPacketsRequest {
1167+ PortId : path .EndpointA .ChannelConfig .PortID ,
1168+ ChannelId : path .EndpointA .ChannelID ,
1169+ PacketCommitmentSequences : []uint64 {0 },
1170+ }
1171+ },
1172+ false ,
1173+ },
1174+ {
1175+ "channel not found" ,
1176+ func () {
1177+ req = & types.QueryUnreceivedPacketsRequest {
1178+ PortId : "invalid-port-id" ,
1179+ ChannelId : "invalid-channel-id" ,
1180+ }
1181+ },
1182+ false ,
1183+ },
1184+ {
1185+ "basic success empty packet commitments" ,
1186+ func () {
1187+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1188+ suite .coordinator .Setup (path )
1189+
1190+ expSeq = []uint64 (nil )
1191+ req = & types.QueryUnreceivedPacketsRequest {
1192+ PortId : path .EndpointA .ChannelConfig .PortID ,
1193+ ChannelId : path .EndpointA .ChannelID ,
1194+ PacketCommitmentSequences : []uint64 {},
1195+ }
1196+ },
1197+ true ,
1198+ },
11591199 {
11601200 "basic success unreceived packet commitments" ,
11611201 func () {
@@ -1181,7 +1221,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
11811221
11821222 suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetPacketReceipt (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , 1 )
11831223
1184- expSeq = []uint64 {}
1224+ expSeq = []uint64 ( nil )
11851225 req = & types.QueryUnreceivedPacketsRequest {
11861226 PortId : path .EndpointA .ChannelConfig .PortID ,
11871227 ChannelId : path .EndpointA .ChannelID ,
@@ -1195,7 +1235,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
11951235 func () {
11961236 path := ibctesting .NewPath (suite .chainA , suite .chainB )
11971237 suite .coordinator .Setup (path )
1198- expSeq = []uint64 {} // reset
1238+ expSeq = []uint64 ( nil ) // reset
11991239 packetCommitments := []uint64 {}
12001240
12011241 // set packet receipt for every other sequence
@@ -1217,6 +1257,60 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
12171257 },
12181258 true ,
12191259 },
1260+ {
1261+ "basic success empty packet commitments, ordered channel" ,
1262+ func () {
1263+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1264+ path .SetChannelOrdered ()
1265+ suite .coordinator .Setup (path )
1266+
1267+ expSeq = []uint64 (nil )
1268+ req = & types.QueryUnreceivedPacketsRequest {
1269+ PortId : path .EndpointA .ChannelConfig .PortID ,
1270+ ChannelId : path .EndpointA .ChannelID ,
1271+ PacketCommitmentSequences : []uint64 {},
1272+ }
1273+ },
1274+ true ,
1275+ },
1276+ {
1277+ "basic success unreceived packet commitments, ordered channel" ,
1278+ func () {
1279+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1280+ path .SetChannelOrdered ()
1281+ suite .coordinator .Setup (path )
1282+
1283+ // Note: NextSequenceRecv is set to 1 on channel creation.
1284+ expSeq = []uint64 {1 }
1285+ req = & types.QueryUnreceivedPacketsRequest {
1286+ PortId : path .EndpointA .ChannelConfig .PortID ,
1287+ ChannelId : path .EndpointA .ChannelID ,
1288+ PacketCommitmentSequences : []uint64 {1 },
1289+ }
1290+ },
1291+ true ,
1292+ },
1293+ {
1294+ "basic success multiple unreceived packet commitments, ordered channel" ,
1295+ func () {
1296+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1297+ path .SetChannelOrdered ()
1298+ suite .coordinator .Setup (path )
1299+
1300+ // Exercise scenario from issue #1532. NextSequenceRecv is 5, packet commitments provided are 2, 7, 9, 10.
1301+ // Packet sequence 2 is already received so only sequences 7, 9, 10 should be considered unreceived.
1302+ expSeq = []uint64 {7 , 9 , 10 }
1303+ packetCommitments := []uint64 {2 , 7 , 9 , 10 }
1304+ suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetNextSequenceRecv (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , 5 )
1305+
1306+ req = & types.QueryUnreceivedPacketsRequest {
1307+ PortId : path .EndpointA .ChannelConfig .PortID ,
1308+ ChannelId : path .EndpointA .ChannelID ,
1309+ PacketCommitmentSequences : packetCommitments ,
1310+ }
1311+ },
1312+ true ,
1313+ },
12201314 }
12211315
12221316 for _ , tc := range testCases {
@@ -1451,4 +1545,4 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() {
14511545 }
14521546 })
14531547 }
1454- }
1548+ }
0 commit comments