diff --git a/grpc-server/src/main/scala/com/wavesplatform/api/grpc/AssetsApiGrpcImpl.scala b/grpc-server/src/main/scala/com/wavesplatform/api/grpc/AssetsApiGrpcImpl.scala index 5d847bea2a..47623258b7 100644 --- a/grpc-server/src/main/scala/com/wavesplatform/api/grpc/AssetsApiGrpcImpl.scala +++ b/grpc-server/src/main/scala/com/wavesplatform/api/grpc/AssetsApiGrpcImpl.scala @@ -35,7 +35,7 @@ class AssetsApiGrpcImpl(assetsApi: CommonAssetsApi, accountsApi: CommonAccountsA .concatMapIterable(_.map { case (a, d) => NFTResponse(a.id.toByteString, Some(assetInfoResponse(d))) }) - .take(request.limit) + .takeLast(request.limit) case _ => Observable.empty } diff --git a/grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AssetsApiGrpcSpec.scala b/grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AssetsApiGrpcSpec.scala index 3ecbc270e4..1070d89cd0 100644 --- a/grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AssetsApiGrpcSpec.scala +++ b/grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AssetsApiGrpcSpec.scala @@ -55,6 +55,47 @@ class AssetsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatcher } } + "NODE-999. GetNftList limit should take last entries" in withDomain( + RideV6.addFeatures(BlockchainFeatures.ReduceNFTFee), + AddrWithBalance.enoughBalances(sender) + ) { d => + val grpcApi = getGrpcApi(d) + val nftIssues = (1 to 10).map(idx => TxHelpers.issue(sender, 1, name = s"nft$idx", reissuable = false)) + d.appendBlock(nftIssues*) + + d.liquidAndSolidAssert { () => + val (observer, result) = createObserver[NFTResponse] + val limitParam = 5 + grpcApi.getNFTList( + NFTRequest.of(ByteString.copyFrom(sender.toAddress.bytes), limitParam, ByteString.copyFrom(nftIssues(limitParam - 1).asset.id.arr)), + observer + ) + val response = result.runSyncUnsafe() + response.size shouldBe limitParam + response shouldBe nftIssues.drop(limitParam).zipWithIndex.map { case (nftTx, i) => + NFTResponse.of( + ByteString.copyFrom(nftTx.asset.id.arr), + Some( + AssetInfoResponse.of( + ByteString.copyFrom(sender.publicKey.arr), + nftTx.name.toStringUtf8, + nftTx.description.toStringUtf8, + nftTx.decimals.value, + nftTx.reissuable, + nftTx.quantity.value, + None, + 0, + None, + 0, + sequenceInBlock = i + 1 + limitParam, + issueHeight = 2 + ) + ) + ) + } + } + } + private def getGrpcApi(d: Domain) = new AssetsApiGrpcImpl(d.assetsApi, d.accountsApi) }