mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Merge pull request #137 from Permissionless-Software-Foundation/fix-error-return
Fix error response format
This commit is contained in:
+1
-1
@@ -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": {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user