@@ -1112,7 +1112,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
1112
1112
func (suite * KeeperTestSuite ) TestQueryUnreceivedPackets () {
1113
1113
var (
1114
1114
req * types.QueryUnreceivedPacketsRequest
1115
- expSeq = []uint64 {}
1115
+ expSeq = []uint64 ( nil )
1116
1116
)
1117
1117
1118
1118
testCases := []struct {
@@ -1158,6 +1158,46 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
1158
1158
},
1159
1159
false ,
1160
1160
},
1161
+ {
1162
+ "invalid seq, ordered channel" ,
1163
+ func () {
1164
+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1165
+ path .SetChannelOrdered ()
1166
+ suite .coordinator .Setup (path )
1167
+
1168
+ req = & types.QueryUnreceivedPacketsRequest {
1169
+ PortId : path .EndpointA .ChannelConfig .PortID ,
1170
+ ChannelId : path .EndpointA .ChannelID ,
1171
+ PacketCommitmentSequences : []uint64 {0 },
1172
+ }
1173
+ },
1174
+ false ,
1175
+ },
1176
+ {
1177
+ "channel not found" ,
1178
+ func () {
1179
+ req = & types.QueryUnreceivedPacketsRequest {
1180
+ PortId : "invalid-port-id" ,
1181
+ ChannelId : "invalid-channel-id" ,
1182
+ }
1183
+ },
1184
+ false ,
1185
+ },
1186
+ {
1187
+ "basic success empty packet commitments" ,
1188
+ func () {
1189
+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1190
+ suite .coordinator .Setup (path )
1191
+
1192
+ expSeq = []uint64 (nil )
1193
+ req = & types.QueryUnreceivedPacketsRequest {
1194
+ PortId : path .EndpointA .ChannelConfig .PortID ,
1195
+ ChannelId : path .EndpointA .ChannelID ,
1196
+ PacketCommitmentSequences : []uint64 {},
1197
+ }
1198
+ },
1199
+ true ,
1200
+ },
1161
1201
{
1162
1202
"basic success unreceived packet commitments" ,
1163
1203
func () {
@@ -1183,7 +1223,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
1183
1223
1184
1224
suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetPacketReceipt (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , 1 )
1185
1225
1186
- expSeq = []uint64 {}
1226
+ expSeq = []uint64 ( nil )
1187
1227
req = & types.QueryUnreceivedPacketsRequest {
1188
1228
PortId : path .EndpointA .ChannelConfig .PortID ,
1189
1229
ChannelId : path .EndpointA .ChannelID ,
@@ -1197,7 +1237,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
1197
1237
func () {
1198
1238
path := ibctesting .NewPath (suite .chainA , suite .chainB )
1199
1239
suite .coordinator .Setup (path )
1200
- expSeq = []uint64 {} // reset
1240
+ expSeq = []uint64 ( nil ) // reset
1201
1241
packetCommitments := []uint64 {}
1202
1242
1203
1243
// set packet receipt for every other sequence
@@ -1219,6 +1259,60 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
1219
1259
},
1220
1260
true ,
1221
1261
},
1262
+ {
1263
+ "basic success empty packet commitments, ordered channel" ,
1264
+ func () {
1265
+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1266
+ path .SetChannelOrdered ()
1267
+ suite .coordinator .Setup (path )
1268
+
1269
+ expSeq = []uint64 (nil )
1270
+ req = & types.QueryUnreceivedPacketsRequest {
1271
+ PortId : path .EndpointA .ChannelConfig .PortID ,
1272
+ ChannelId : path .EndpointA .ChannelID ,
1273
+ PacketCommitmentSequences : []uint64 {},
1274
+ }
1275
+ },
1276
+ true ,
1277
+ },
1278
+ {
1279
+ "basic success unreceived packet commitments, ordered channel" ,
1280
+ func () {
1281
+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1282
+ path .SetChannelOrdered ()
1283
+ suite .coordinator .Setup (path )
1284
+
1285
+ // Note: NextSequenceRecv is set to 1 on channel creation.
1286
+ expSeq = []uint64 {1 }
1287
+ req = & types.QueryUnreceivedPacketsRequest {
1288
+ PortId : path .EndpointA .ChannelConfig .PortID ,
1289
+ ChannelId : path .EndpointA .ChannelID ,
1290
+ PacketCommitmentSequences : []uint64 {1 },
1291
+ }
1292
+ },
1293
+ true ,
1294
+ },
1295
+ {
1296
+ "basic success multiple unreceived packet commitments, ordered channel" ,
1297
+ func () {
1298
+ path := ibctesting .NewPath (suite .chainA , suite .chainB )
1299
+ path .SetChannelOrdered ()
1300
+ suite .coordinator .Setup (path )
1301
+
1302
+ // Exercise scenario from issue #1532. NextSequenceRecv is 5, packet commitments provided are 2, 7, 9, 10.
1303
+ // Packet sequence 2 is already received so only sequences 7, 9, 10 should be considered unreceived.
1304
+ expSeq = []uint64 {7 , 9 , 10 }
1305
+ packetCommitments := []uint64 {2 , 7 , 9 , 10 }
1306
+ suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetNextSequenceRecv (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , 5 )
1307
+
1308
+ req = & types.QueryUnreceivedPacketsRequest {
1309
+ PortId : path .EndpointA .ChannelConfig .PortID ,
1310
+ ChannelId : path .EndpointA .ChannelID ,
1311
+ PacketCommitmentSequences : packetCommitments ,
1312
+ }
1313
+ },
1314
+ true ,
1315
+ },
1222
1316
}
1223
1317
1224
1318
for _ , tc := range testCases {
0 commit comments