Skip to content

Commit

Permalink
NODE-2618 Fixed GRPC getNFTList
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 committed Oct 23, 2023
1 parent d711d9a commit 6f08aac
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 6f08aac

Please sign in to comment.