diff --git a/package.json b/package.json index 144a27b..77e8141 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "coverage": "nyc report --reporter=text-lcov | coveralls", "coverage:report": "export NETWORK=mainnet && nyc --reporter=html mocha --timeout 25000 test/v4/", "docs": "./node_modules/.bin/apidoc -i src/routes/v4 -o docs", - "test:temp1": "export NETWORK=mainnet && export TEST=integration && mocha --exit --timeout 25000 -g '#getNftChildren' test/v4/integration/", + "test:temp1": "export NETWORK=mainnet && export TEST=integration && export SLPDB_URL=https://slpdb.fountainhead.cash/ && mocha --exit --timeout 25000 -g '#nft' test/v4/integration/", "test:temp2": "mocha -g '#getNftGroup' --exit --timeout 30000 test/v4/" }, "engines": { diff --git a/src/routes/v4/slp.js b/src/routes/v4/slp.js index 1538e98..6509118 100644 --- a/src/routes/v4/slp.js +++ b/src/routes/v4/slp.js @@ -2284,7 +2284,8 @@ class Slp { const childrenRes = await _this.axios.request(opt) // console.log(`childrenRes.data: ${JSON.stringify(childrenRes.data, null, 2)}`) if (!childrenRes || !childrenRes.data || !childrenRes.data.t) { - return { error: 'No children data in the group' } + res.status(400) + return res.json({ error: 'No children data in the group' }) } childrenRes.data.t.forEach(function (token) { diff --git a/test/v4/integration/nft.js b/test/v4/integration/nft.js index f26e686..563b4f2 100644 --- a/test/v4/integration/nft.js +++ b/test/v4/integration/nft.js @@ -35,6 +35,31 @@ describe('#nft', () => { }) describe('#getNftChildren', () => { + it('should return error on non-existing NFT group token', async () => { + req.params.tokenId = + '68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0b' + const result = await slp.getNftChildren(req, res) + // console.log(`result: ${util.inspect(result)}`) + + assert.include( + result.error, + 'NFT group does not exists', + 'Error message expected' + ) + }) + it('should return error on non-group NFT token', async () => { + req.params.tokenId = + '45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9' + + const result = await slp.getNftChildren(req, res) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) + + assert.include( + result.error, + 'NFT group does not exists', + 'Error message expected' + ) + }) it('should get NFT children list', async () => { req.params.tokenId = '68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a' @@ -56,6 +81,18 @@ describe('#nft', () => { }) describe('#getNftGroup', () => { + it('should return error on non-existing NFT child token', async () => { + req.params.tokenId = + '45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a8' + const result = await slp.getNftGroup(req, res) + // console.log(`result: ${util.inspect(result)}`) + + assert.include( + result.error, + 'NFT child does not exists', + 'Error message expected' + ) + }) it('should get NFT group token info', async () => { req.params.tokenId = '45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'