Compare commits

...
44 Commits
Author SHA1 Message Date
Chris Troutner 9463afcbc3 Merge pull request #135 from Permissionless-Software-Foundation/ct-unstable
fix(send tx): Fixing bug in the sendTxOptions()
2021-05-13 10:25:15 -07:00
Chris Troutner 13a1e1b1db fix(send tx): Fixing bug in the sendTxOptions() 2021-05-13 10:23:01 -07:00
Chris Troutner 6e19738d1e Merge pull request #134 from Permissionless-Software-Foundation/ct-unstable
feat(send transaction): Allowing specific node for broadcasting txs
2021-05-13 09:38:34 -07:00
Chris Troutner 2a3baf39b9 feat(send transaction): Allowing specific node for broadcasting txs 2021-05-13 09:27:50 -07:00
Chris Troutner d58c98030d Merge pull request #132 from Permissionless-Software-Foundation/nft-get-calls
NFT group and children GET calls + tests
2021-05-09 21:27:01 -07:00
Chris Troutner 5c4f6802b3 Ensured integration tests pass for abc and bchn 2021-05-09 21:23:32 -07:00
Chris Troutner fd51f82dbc Got integration tests in BCH passing 2021-05-09 16:42:41 -07:00
Chris Troutner a77cb3c249 Merge branch 'master' into nft-get-calls 2021-05-09 15:40:38 -07:00
Chris Troutner 015c33faff Merge pull request #133 from Permissionless-Software-Foundation/ct-unstable
Updating example start shell script
2021-05-09 15:39:36 -07:00
Chris Troutner 738c643c1b formatting 2021-05-08 21:12:58 -07:00
Chris Troutner 69ce039882 fix(shell script): Fixing example to use 10000 rate limit points 2021-05-08 19:48:12 -07:00
Chris Troutner 1642603b78 Adding shell-script folder 2021-05-08 19:00:00 -07:00
Stoyan Zhekov 85a170073d NFT group and children GET calls + tests 2021-05-05 12:08:34 +09:00
Chris Troutner a8882bd618 Merge pull request #131 from Permissionless-Software-Foundation/ct-unstable
fix(winston): Switching max files from 5 days to 250 files
2021-04-29 10:25:38 -07:00
Chris Troutner a6b139e0c4 fix(winston): Switching max files from 5 days to 250 files 2021-04-29 10:24:28 -07:00
Chris Troutner 5880f14e07 Adding curl example for jwt token, to README 2021-04-29 08:54:18 -07:00
Chris Troutner 9bf271b4c2 Merge pull request #130 from Permissionless-Software-Foundation/ct-unstable
fix(rate limits): Making internal rate limits an env var
2021-04-20 16:01:45 -07:00
Chris Troutner 82af58e8b3 fix(rate limits): Making internal rate limits an env var 2021-04-20 15:57:37 -07:00
Chris Troutner 6d00681d6e Merge pull request #129 from Permissionless-Software-Foundation/joey
Removing BigNumber reset
2021-04-13 11:07:15 -07:00
Chris Troutner 59043bc154 Updating npm dependencies 2021-04-13 10:59:42 -07:00
Chris Troutner ffb63125e1 Merge pull request #128 from BytesOfMan/remove-bignumber-decimal-mod
URGENT: Remove bignumberjs mod to 8 decimal places
2021-04-13 10:57:46 -07:00
Joey King a3cd832c63 Remove bignumberjs mod to 8 decimal places 2021-04-12 13:27:45 -07:00
Chris Troutner 12d88e8846 Adding info about rate limits. 2021-04-05 12:08:39 -07:00
Chris Troutner 17fe219773 Merge pull request #126 from Permissionless-Software-Foundation/ct-unstable
fix(error handling): Hanling 429 rate limit error better with hyrateU…
2021-04-01 08:47:44 -08:00
Chris Troutner d76c663f25 fix(error handling): Hanling 429 rate limit error better with hyrateUtxos() 2021-04-01 09:46:33 -07:00
Chris Troutner b1655e843e Merge pull request #125 from Permissionless-Software-Foundation/ct-unstable
fix(route-utils): Adding unit tests for route-utils
2021-03-31 04:06:16 -08:00
Chris Troutner af5d44c278 fix(route-utils): Adding unit tests for route-utils 2021-03-31 05:04:35 -07:00
Chris Troutner 0d9caca8b0 Merge pull request #124 from Permissionless-Software-Foundation/ct-unstable
fix(blockbook): Removing final piece of blockbook
2021-03-30 06:53:22 -08:00
Chris Troutner 0cdb9572f1 fix(blockbook): Removing final piece of blockbook 2021-03-30 07:52:02 -07:00
Chris Troutner 8507abd5db Merge pull request #123 from Permissionless-Software-Foundation/dh-apidocs
fix(docs): Fixed bch-api API docs
2021-03-30 06:40:10 -08:00
Daniel Gonzalez fae9a75f6a fix(docs): Fixed bch-api API docs 2021-03-29 21:04:51 -04:00
Chris Troutner fc6da588ee Merge pull request #120 from Permissionless-Software-Foundation/dh-getblock-endpoint
feat(getblock): Added getblock endpoint
2021-03-29 12:17:45 -08:00
Chris Troutner 6f8c00bab9 Making sure integration tests work 2021-03-29 13:08:55 -07:00
Chris Troutner a2ab88adab Merge branch 'master' into dh-getblock-endpoint 2021-03-29 12:13:16 -07:00
Chris Troutner 60528dbd6e Merge pull request #122 from Permissionless-Software-Foundation/timeout
fix(timout): Increasing API timeout from 30 seconds to 5 minutes
2021-03-26 18:11:44 -08:00
Chris Troutner cebf1ea1d6 fix(timout): Increasing API timeout from 30 seconds to 5 minutes 2021-03-26 19:10:33 -07:00
Chris Troutner 11a62af39b Merge pull request #121 from Permissionless-Software-Foundation/ct-unstable
fix(rate limits): Quieting noisy tests
2021-03-26 08:01:45 -07:00
Chris Troutner 83aeabd913 fix(rate limits): Quieting noisy tests 2021-03-26 07:50:41 -07:00
Daniel Gonzalez 7acb778470 feat(getblock): Added getblock endpoint 2021-03-25 17:30:30 -04:00
Chris Troutner 766925c9a8 Merge pull request #119 from Permissionless-Software-Foundation/ct-unstable
Fixing test for BVT
2021-03-16 11:07:00 -07:00
Chris Troutner 51c37e1371 Merge branch 'master' into ct-unstable 2021-03-16 11:03:16 -07:00
Chris Troutner 244acfb26b fix(test): Fixing test for BVT 2021-03-16 11:03:06 -07:00
Chris Troutner d03303728c Merge pull request #118 from Permissionless-Software-Foundation/ct-unstable
fix(test): still trying to fix the same test
2021-03-16 10:33:10 -07:00
Chris Troutner 9fa16aea78 fix(test): still trying to fix the same test 2021-03-16 10:28:38 -07:00
24 changed files with 2114 additions and 3157 deletions
+1
View File
@@ -30,6 +30,7 @@ start-fullstack-abc.sh
start-fullstack-bchn.sh
start-ss-main.sh
start-decatur-bchn.sh
shell-scripts/
coverage
start-my-infra
+14
View File
@@ -82,6 +82,20 @@ installation.
`docker-compose up`
## Rate Limits
The rate limits for [api.fullstack.cash](https://api.fullstack.cash) are controlled by a JWT token. You can increase your rate limits by [purchasing a JWT token](https://https://fullstack.cash). If you're using bch-js, [check the readme for instructions on increasing rate limits](https://github.com/Permissionless-Software-Foundation/bch-js#api-key). For interacting with bch-api directly, you can then include the JWT token in the HTTP header like this:
- `Authorization: Token <JWT token>`
### cURL example
Here is an example using curl for using the JWT token when making a call to the REST API:
```
export BCHJSTOKEN=eyJhbGciOiJ....
curl "https://bchn.fullstack.cash/v4/electrumx/balance/bitcoincash:qr69kyzha07dcecrsvjwsj4s6slnlq4r8c30lxnur3" -X GET -H "Content-Type: application/json" -H "Authorization: Token ${BCHJSTOKEN}"
```
## Support
Have questions? Need help? Join our community support
[Telegram channel](https://t.me/bch_js_toolkit)
+4
View File
@@ -0,0 +1,4 @@
{
"sampleUrl": null
}
+3
View File
@@ -16,6 +16,9 @@ const config = {
whitelistRateLimit: process.env.WHITELIST_RATE_LIMIT
? Number(process.env.WHITELIST_RATE_LIMIT)
: 10,
internalRateLimit: process.env.INTERNAL_RATE_LIMIT
? Number(process.env.INTERNAL_RATE_LIMIT)
: 10,
pointsPerMinute: process.env.POINTS_PER_MINUTE
? Number(process.env.POINTS_PER_MINUTE)
: 10000,
+1084 -2583
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -16,20 +16,21 @@
"dev": "nodemon ./dist/app.js",
"test": "npm run lint && npm run test-v4",
"lint": "standard --env mocha --fix",
"test-v4": "export NETWORK=mainnet && nyc --reporter=text mocha --timeout 60000 test/v4/",
"test-v4": "export NETWORK=mainnet && nyc --reporter=text mocha --exit --timeout 60000 test/v4/",
"test:integration": "mocha test/v4/integration",
"test:integration:slpdb": "mocha --timeout 25000 -g '#validate2Single' test/v4/integration/slp*.js",
"test:integration:nft": "mocha --timeout 25000 -g '#nft' test/v4/integration/nft.js",
"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 '#hydrateUtxos-' test/v4/integration/",
"test:temp2": "mocha test/v4/rate-limit2-unit.js"
"test:temp1": "export NETWORK=mainnet && export TEST=integration && mocha --exit --timeout 25000 -g '#getNftChildren' test/v4/integration/",
"test:temp2": "mocha -g '#getNftGroup' --exit --timeout 30000 test/v4/"
},
"engines": {
"node": ">=10.15.1"
},
"dependencies": {
"@psf/bch-js": "^4.16.1",
"@psf/bch-js": "^4.18.0",
"apidoc": "^0.26.0",
"axios": "^0.21.1",
"bitcore-lib-cash": "^8.23.1",
@@ -70,7 +71,7 @@
"nock": "^13.0.5",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"semantic-release": "^17.3.9",
"semantic-release": "^17.4.2",
"sinon": "^9.0.0",
"standard": "^14.3.1"
},
+5 -3
View File
@@ -189,9 +189,11 @@ server.listen(port)
server.on('error', onError)
server.on('listening', onListening)
// Set the time before a timeout error is generated. This impacts testing and
// the handling of timeout errors. Is 10 seconds too agressive?
server.setTimeout(30 * 1000)
// Set the time before a timeout error is generated.
// 10 seconds is way too agressive. 30 Seconds was used for a while, but with
// being able to set a timeout between UTXOs for tokenUtxoDetails, the timeout
// needed to be extended.
server.setTimeout(1000 * 60 * 5) // 5 minutes
/**
* Normalize a port into a number, string, or false.
+28 -17
View File
@@ -56,7 +56,7 @@ const ANON_LIMITS = config.anonRateLimit
const WHITELIST_DOMAINS = config.whitelistDomains
const WHITELIST_POINTS_TO_CONSUME = config.whitelistRateLimit
const POINTS_PER_MINUTE = config.pointsPerMinute
const INTERNAL_POINTS_TO_CONSUME = 10
const INTERNAL_POINTS_TO_CONSUME = config.internalRateLimit
class RateLimits {
constructor () {
@@ -82,11 +82,11 @@ class RateLimits {
// Determine if the call is an external or internal API call.
const isInternal = _this.checkInternalIp(req)
console.log(`isInternal: ${isInternal}`)
// console.log(`isInternal: ${isInternal}`)
// Determine if the call originates from another computer on the intranet.
const isWhitelistOrigin = _this.isInWhitelist(req)
console.log('isWhitelistOrigin: ', isWhitelistOrigin)
// console.log('isWhitelistOrigin: ', isWhitelistOrigin)
// Handle the use case of internally-generated requests.
if (isInternal) {
@@ -94,15 +94,15 @@ class RateLimits {
// the usrObj in the body.
if (req.body && req.body.usrObj) {
if (req.body.usrObj.proLimit) {
console.log('Internal call, basic auth, skipping rate limits.')
// console.log('Internal call, basic auth, skipping rate limits.')
// If this is an internal call that originated from a user using
// Basic Authentication, then skip rate-limits.
return next()
} else {
console.log(
'Internal call, applying rate limits. Using JWT if available.'
)
// console.log(
// 'Internal call, applying rate limits. Using JWT if available.'
// )
// Determine if user has exceeded their rate limits. Pass in the
// JWT token if one exists.
@@ -130,10 +130,10 @@ class RateLimits {
// and avoid this code path. This code path is 'pooled': all users
// share the same rate limits. Even at 1000 RPM, this pool will get
// exhausted easily.
const warnMsg =
'Internal call. req.body.usrObj does not exist. Applying high-speed internal rate limits.'
console.log(warnMsg)
wlogger.info(warnMsg)
// const warnMsg =
// 'Internal call. req.body.usrObj does not exist. Applying high-speed internal rate limits.'
// console.log(warnMsg)
// wlogger.info(warnMsg)
const defaultPayload = {
id: '98.76.54.32',
@@ -154,6 +154,7 @@ class RateLimits {
res,
defaultJwt
)
// console.log(`hasExceededRateLimit: `, hasExceededRateLimit)
if (!hasExceededRateLimit) {
// Rate limits have not been exceeded. Processing can continue.
@@ -168,9 +169,9 @@ class RateLimits {
//
} else {
// Handle the normal use-case of external requests
console.log(
'External call, applying rate limits. Using JWT if available.'
)
// console.log(
// 'External call, applying rate limits. Using JWT if available.'
// )
// For calls originating from a whitelist domain, apply a high-RPM
// JWT token to the call.
@@ -195,6 +196,7 @@ class RateLimits {
res,
req.locals.jwtToken
)
// console.log('hasExceededRateLimit: ', hasExceededRateLimit)
if (!hasExceededRateLimit) {
// Rate limits have not been exceeded. Processing can continue.
@@ -220,8 +222,12 @@ class RateLimits {
async trackRateLimits (req, res, jwtToken) {
// Anonymous rate limits are used by default.
let pointsToConsume = ANON_LIMITS
// console.log('pointsToConsume: ', pointsToConsume)
let key = req.ip // Use the IP address as the key, by default.
// console.log('jwtToken: ', jwtToken)
try {
// Decode the JWT token if it exists
if (jwtToken) {
@@ -233,18 +239,22 @@ class RateLimits {
pointsToConsume = decoded.pointsToConsume
}
console.log(`rate limit key: ${key}`)
// console.log(`rate limit key: ${key}`)
// This function will throw an error if the user exceeds the rate limit.
// The 429 error response is handled by the catch().
await _this.rateLimiter.consume(key, pointsToConsume)
// Debugging
// const rateLimitData = await _this.rateLimiter.consume(key, pointsToConsume)
// console.log(`rateLimitData: `, rateLimitData)
res.locals.pointsToConsume = pointsToConsume // Feedback for tests.
// Signal that the user has not exceeded their rate limits.
return false
} catch (err) {
console.log('err: ', err)
// console.log('err: ', err)
const rateLimit = Math.floor(POINTS_PER_MINUTE / pointsToConsume)
@@ -307,7 +317,8 @@ class RateLimits {
// Retrieve the origin.
const origin = req.get('origin')
console.log(`origin: ${origin}`)
if (!process.env.TEST) console.log('origin:', origin)
// If the origin is not determinable, return false.
if (!origin) return false
-521
View File
@@ -1,521 +0,0 @@
/*
Blockbook API route
*/
'use strict'
const express = require('express')
const axios = require('axios')
const wlogger = require('../../util/winston-logging')
const RouteUtils = require('../../util/route-utils')
const routeUtils = new RouteUtils()
// Library for easily switching the API paths to use different instances of
// Blockbook.
const BlockbookPath = require('../../util/blockbook-path')
const BLOCKBOOKPATH = new BlockbookPath()
// BLOCKBOOKPATH.toOpenBazaar()
const router = express.Router()
// Used for processing error messages before sending them to the user.
const util = require('util')
util.inspect.defaultOptions = { depth: 1 }
const BCHJS = require('@psf/bch-js')
const bchjs = new BCHJS()
let _this
class Blockbook {
constructor () {
_this = this
_this.axios = axios
_this.routeUtils = routeUtils
_this.bchjs = bchjs
_this.BLOCKBOOKPATH = BLOCKBOOKPATH
_this.router = router
_this.router.get('/', _this.root)
_this.router.get('/balance/:address', _this.balanceSingle)
_this.router.post('/balance', _this.balanceBulk)
_this.router.get('/utxos/:address', _this.utxosSingle)
_this.router.post('/utxos', _this.utxosBulk)
_this.router.get('/tx/:txid', _this.txSingle)
_this.router.post('/tx', _this.txBulk)
}
// DRY error handler.
errorHandler (err, res) {
// Attempt to decode the error message.
const { msg, status } = _this.routeUtils.decodeError(err)
if (msg) {
res.status(status)
return res.json({ error: msg })
}
res.status(500)
return res.json({ error: util.inspect(err) })
}
// Root API endpoint. Simply acknowledges that it exists.
root (req, res, next) {
return res.json({ status: 'address' })
}
// Query the Blockbook Node API for a balance on a single BCH address.
// Returns a Promise.
async balanceFromBlockbook (thisAddress) {
try {
// console.log(`BLOCKBOOK_URL: ${BLOCKBOOK_URL}`)
// Convert the address to a cashaddr without a prefix.
const addr = _this.bchjs.Address.toCashAddress(thisAddress)
const path = `${_this.BLOCKBOOKPATH.addrPath}${addr}`
// console.log(`path: ${path}`)
// Query the Blockbook Node API.
const options = {
method: 'get',
baseURL: path
}
const axiosResponse = await _this.axios.request(options)
const retData = axiosResponse.data
// console.log(`retData: ${util.inspect(retData)}`)
return retData
} catch (err) {
// Dev Note: Do not log error messages here. Throw them instead and let the
// parent function handle it.
wlogger.debug('Error in blockbook.js/balanceFromBlockbook()')
throw err
}
}
async balanceSingle (req, res, next) {
try {
const address = req.params.address
if (!address || address === '') {
res.status(400)
return res.json({ error: 'address can not be empty' })
}
// Reject if address is an array.
if (Array.isArray(address)) {
res.status(400)
return res.json({
error: 'address can not be an array. Use POST for bulk upload.'
})
}
wlogger.debug(
'Executing blockbook/balanceSingle with this address: ',
address
)
// Ensure the input is a valid BCH address.
try {
// const legacyAddr = bchjs.Address.toLegacyAddress(address)
_this.bchjs.Address.toLegacyAddress(address)
} catch (err) {
res.status(400)
return res.json({
error: `Invalid BCH address. Double check your address is valid: ${address}`
})
}
// Prevent a common user error. Ensure they are using the correct network address.
const networkIsValid = _this.routeUtils.validateNetwork(address)
if (!networkIsValid) {
res.status(400)
return res.json({
error:
'Invalid network. Trying to use a testnet address on mainnet, or vice versa.'
})
}
// Query the Blockbook Node API.
const retData = await _this.balanceFromBlockbook(address)
// Return the retrieved address information.
res.status(200)
return res.json(retData)
} catch (err) {
// Write out error to error log.
wlogger.error('Error in blockbook.js/balanceSingle().', err)
return _this.errorHandler(err, res)
}
}
// POST handler for bulk queries on address details
async balanceBulk (req, res, next) {
try {
let addresses = req.body.addresses
// const currentPage = req.body.page ? parseInt(req.body.page, 10) : 0
// Reject if addresses is not an array.
if (!Array.isArray(addresses)) {
res.status(400)
return res.json({
error: 'addresses needs to be an array. Use GET for single address.'
})
}
// Enforce array size rate limits
if (!_this.routeUtils.validateArraySize(req, addresses)) {
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
return res.json({
error: 'Array too large.'
})
}
wlogger.debug(
'Executing blockbook.js/balanceBulk with these addresses: ',
addresses
)
// Validate each element in the address array.
for (let i = 0; i < addresses.length; i++) {
const thisAddress = addresses[i]
// Ensure the input is a valid BCH address.
try {
_this.bchjs.Address.toLegacyAddress(thisAddress)
} catch (err) {
res.status(400)
return res.json({
error: `Invalid BCH address. Double check your address is valid: ${thisAddress}`
})
}
// Prevent a common user error. Ensure they are using the correct network address.
const networkIsValid = _this.routeUtils.validateNetwork(thisAddress)
if (!networkIsValid) {
res.status(400)
return res.json({
error: `Invalid network for address ${thisAddress}. Trying to use a testnet address on mainnet, or vice versa.`
})
}
}
// Loops through each address and creates an array of Promises, querying
// Insight API in parallel.
addresses = addresses.map(async (address, index) =>
// console.log(`address: ${address}`)
_this.balanceFromBlockbook(address)
)
// Wait for all parallel Insight requests to return.
const result = await _this.axios.all(addresses)
// Return the array of retrieved address information.
res.status(200)
return res.json(result)
} catch (err) {
wlogger.error('Error in blockbook.js/balanceBulk().', err)
return _this.errorHandler(err, res)
}
}
// Query the Blockbook API for utxos associated with a BCH address.
// Returns a Promise.
async utxosFromBlockbook (thisAddress) {
try {
// console.log(`BLOCKBOOK_URL: ${BLOCKBOOK_URL}`)
// Convert the address to a cashaddr without a prefix.
const addr = _this.bchjs.Address.toCashAddress(thisAddress)
const path = `${_this.BLOCKBOOKPATH.utxoPath}${addr}`
// console.log(`path: ${path}`)
// Query the Blockbook API.
// Query the Blockbook Node API.
const options = {
method: 'get',
baseURL: path
}
const axiosResponse = await _this.axios.request(options)
const retData = axiosResponse.data
// console.log(`retData: ${util.inspect(retData)}`)
// Add the satoshis property to each UTXO.
for (let i = 0; i < retData.length; i++) {
retData[i].satoshis = Number(retData[i].value)
}
return retData
} catch (err) {
// Dev Note: Do not log error messages here. Throw them instead and let the
// parent function handle it.
wlogger.debug('Error in blockbook.js/utxosFromBlockbook()')
throw err
}
}
// GET handler for single balance
async utxosSingle (req, res, next) {
try {
const address = req.params.address
if (!address || address === '') {
res.status(400)
return res.json({ error: 'address can not be empty' })
}
// Reject if address is an array.
if (Array.isArray(address)) {
res.status(400)
return res.json({
error: 'address can not be an array. Use POST for bulk upload.'
})
}
wlogger.debug(
'Executing blockbook/utxosSingle with this address: ',
address
)
// Ensure the input is a valid BCH address.
try {
// const legacyAddr = bchjs.Address.toLegacyAddress(address)
_this.bchjs.Address.toLegacyAddress(address)
} catch (err) {
res.status(400)
return res.json({
error: `Invalid BCH address. Double check your address is valid: ${address}`
})
}
// Prevent a common user error. Ensure they are using the correct network address.
const networkIsValid = _this.routeUtils.validateNetwork(address)
if (!networkIsValid) {
res.status(400)
return res.json({
error:
'Invalid network. Trying to use a testnet address on mainnet, or vice versa.'
})
}
// Query the Blockbook API.
const retData = await _this.utxosFromBlockbook(address)
// Return the retrieved address information.
res.status(200)
return res.json(retData)
} catch (err) {
// Write out error to error log.
wlogger.error('Error in blockbook.js/utxosSingle().', err)
return _this.errorHandler(err, res)
}
}
// POST handler for bulk queries on address utxos
async utxosBulk (req, res, next) {
try {
let addresses = req.body.addresses
// const currentPage = req.body.page ? parseInt(req.body.page, 10) : 0
// Reject if addresses is not an array.
if (!Array.isArray(addresses)) {
res.status(400)
return res.json({
error: 'addresses needs to be an array. Use GET for single address.'
})
}
// Enforce array size rate limits
if (!_this.routeUtils.validateArraySize(req, addresses)) {
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
return res.json({
error: 'Array too large.'
})
}
wlogger.debug(
'Executing blockbook.js/utxosBulk with these addresses: ',
addresses
)
// Validate each element in the address array.
for (let i = 0; i < addresses.length; i++) {
const thisAddress = addresses[i]
// Ensure the input is a valid BCH address.
try {
_this.bchjs.Address.toLegacyAddress(thisAddress)
} catch (err) {
res.status(400)
return res.json({
error: `Invalid BCH address. Double check your address is valid: ${thisAddress}`
})
}
// Prevent a common user error. Ensure they are using the correct network address.
const networkIsValid = _this.routeUtils.validateNetwork(thisAddress)
if (!networkIsValid) {
res.status(400)
return res.json({
error: `Invalid network for address ${thisAddress}. Trying to use a testnet address on mainnet, or vice versa.`
})
}
}
// Loops through each address and creates an array of Promises, querying
// Insight API in parallel.
addresses = addresses.map(async (address, index) =>
// console.log(`address: ${address}`)
_this.utxosFromBlockbook(address)
)
// Wait for all parallel Insight requests to return.
const result = await _this.axios.all(addresses)
// Return the array of retrieved address information.
res.status(200)
return res.json(result)
} catch (err) {
wlogger.error('Error in blockbook.js/utxosBulk().', err)
return _this.errorHandler(err, res)
}
}
// Query the Blockbook Node API for transactions on a single TXID.
// Returns a Promise.
async transactionsFromBlockbook (txid) {
try {
// console.log(`BLOCKBOOK_URL: ${BLOCKBOOK_URL}`)
const path = `${_this.BLOCKBOOKPATH.txPath}${txid}`
// console.log(`path: ${path}`)
// Query the Blockbook Node API.
const options = {
method: 'get',
baseURL: path
}
const axiosResponse = await _this.axios.request(options)
const retPromise = axiosResponse.data
// console.log(`retData: ${util.inspect(retData)}`)
return retPromise
} catch (err) {
// Dev Note: Do not log error messages here. Throw them instead and let the
// parent function handle it.
wlogger.debug('Error in blockbook.js/transactionsFromBlockbook()')
throw err
}
}
// GET handler for single transaction details.
async txSingle (req, res, next) {
try {
const txid = req.params.txid
if (!txid || txid === '') {
res.status(400)
return res.json({ error: 'txid can not be empty' })
}
// Reject if address is an array.
if (Array.isArray(txid)) {
res.status(400)
return res.json({
error: 'txid can not be an array. Use POST for bulk upload.'
})
}
// TODO: Add regex comparison of txid to ensure it's valid.
if (txid.length !== 64) {
res.status(400)
return res.json({
error: `txid must be of length 64 (not ${txid.length})`
})
}
wlogger.debug('Executing blockbook/txSingle with this txid: ', txid)
// Query the Blockbook Node API.
const retData = await _this.transactionsFromBlockbook(txid)
// Return the retrieved address information.
res.status(200)
return res.json(retData)
} catch (err) {
// Write out error to error log.
wlogger.error('Error in blockbook.js/txSingle().', err)
return _this.errorHandler(err, res)
}
}
// POST handler for bulk queries on tx details
async txBulk (req, res, next) {
try {
let txids = req.body.txids
// const currentPage = req.body.page ? parseInt(req.body.page, 10) : 0
// Reject if txids is not an array.
if (!Array.isArray(txids)) {
res.status(400)
return res.json({
error: 'txids need to be an array. Use GET for single address.'
})
}
// Enforce array size rate limits
if (!_this.routeUtils.validateArraySize(req, txids)) {
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
return res.json({
error: 'Array too large.'
})
}
wlogger.debug('Executing blockbook.js/txBulk with these txids: ', txids)
// Validate each element in the txids array.
for (let i = 0; i < txids.length; i++) {
const thisTxid = txids[i]
if (!thisTxid || thisTxid === '') {
res.status(400)
return res.json({ error: 'txid can not be empty' })
}
// TODO: Add regex comparison of txid to ensure it's valid.
if (thisTxid.length !== 64) {
res.status(400)
return res.json({
error: `txid must be of length 64 (not ${thisTxid.length})`
})
}
}
// Loops through each address and creates an array of Promises, querying
// Insight API in parallel.
txids = txids.map(async (txid, index) =>
// console.log(`address: ${address}`)
_this.transactionsFromBlockbook(txid)
)
// Wait for all parallel Insight requests to return.
const result = await _this.axios.all(txids)
// Return the array of retrieved address information.
res.status(200)
return res.json(result)
} catch (err) {
wlogger.error('Error in blockbook.js/txBulk().', err)
return _this.errorHandler(err, res)
}
}
}
module.exports = Blockbook
+1 -1
View File
@@ -181,7 +181,7 @@ class Encryption {
publicKey: 'not found'
})
} catch (err) {
console.log('Error in encryption.js/getPublicKey().', err)
// console.log('Error in encryption.js/getPublicKey().', err)
wlogger.error('Error in encryption.js/getPublicKey().', err)
return _this.errorHandler(err, res)
+47
View File
@@ -53,6 +53,7 @@ class Blockchain {
this.router.post('/getTxOutProof', this.getTxOutProofBulk)
this.router.get('/verifyTxOutProof/:proof', this.verifyTxOutProofSingle)
this.router.post('/verifyTxOutProof', this.verifyTxOutProofBulk)
this.router.post('/getBlock', this.getBlock)
}
root (req, res, next) {
@@ -937,6 +938,52 @@ class Blockchain {
return _this.errorHandler(err, res)
}
}
/**
* @api {post} /blockchain/getBlock/ Get block details
* @apiName getBlock
* @apiGroup Blockchain
* @apiDescription Returns block details
*
* @apiExample Example usage:
* curl "https://api.fullstack.cash/v4/blockchain/getblock/" -X POST -H "Content-Type: application/json" --data-binary '{"blockhash":"000000000000000002a5fe0bdd6e3f04342a975c0f55e57f97e73bb90041676b","verbosity":0 }'
*
* @apiParam {String} blockhash Block hash (required)
* @apiParam {Number} verbosity Default 1 (optional)
*
*/
async getBlock (req, res, next) {
try {
// Validate input parameter
const blockhash = req.body.blockhash
let verbosity = req.body.verbosity
// Default to a value of 1 if another verbosity level is not defined.
if (!verbosity && verbosity !== 0) verbosity = 1
if (!blockhash || blockhash === '') {
res.status(400)
return res.json({ error: 'blockhash can not be empty' })
}
// Axios options
const options = _this.routeUtils.getAxiosOptions()
options.data.id = 'getblock'
options.data.method = 'getblock'
options.data.params = [blockhash, verbosity]
const response = await _this.axios.request(options)
return res.json(response.data.result)
} catch (err) {
// Write out error to error log.
// logger.error(`Error in rawtransactions/decodeRawTransaction: `, err)
wlogger.error('Error in blockchain.js/getBlock()', err)
return _this.errorHandler(err, res)
}
}
}
module.exports = Blockchain
+34 -7
View File
@@ -140,7 +140,7 @@ class RawTransactions {
const options = _this.routeUtils.getAxiosOptions()
// Loop through each height and creates an array of requests to call in parallel
const promises = hexes.map(async hex => {
const promises = hexes.map(async (hex) => {
options.data.id = 'decoderawtransaction'
options.data.method = 'decoderawtransaction'
options.data.params = [hex]
@@ -152,7 +152,7 @@ class RawTransactions {
const axiosResult = await _this.axios.all(promises)
// Retrieve the data part of the result.
const result = axiosResult.map(x => x.data.result)
const result = axiosResult.map((x) => x.data.result)
res.status(200)
return res.json(result)
@@ -254,7 +254,7 @@ class RawTransactions {
const options = _this.routeUtils.getAxiosOptions()
// Loop through each hex and create an array of promises
const promises = hexes.map(async hex => {
const promises = hexes.map(async (hex) => {
options.data.id = 'decodescript'
options.data.method = 'decodescript'
options.data.params = [hex]
@@ -267,7 +267,7 @@ class RawTransactions {
const resolved = await Promise.all(promises)
// Retrieve the data from each resolved promise.
const result = resolved.map(x => x.data.result)
const result = resolved.map((x) => x.data.result)
res.status(200)
return res.json(result)
@@ -348,7 +348,7 @@ class RawTransactions {
}
// Loop through each txid and create an array of promises
const promises = txids.map(async txid =>
const promises = txids.map(async (txid) =>
_this.getRawTransactionsFromNode(txid, verbose)
)
@@ -436,7 +436,8 @@ class RawTransactions {
return res.json({ error: 'hex must be an array' })
}
const options = _this.routeUtils.getAxiosOptions()
let options = _this.routeUtils.getAxiosOptions()
options = _this.sendTxOptions(options)
// Enforce array size rate limits
if (!_this.routeUtils.validateArraySize(req, hexes)) {
@@ -536,7 +537,8 @@ class RawTransactions {
})
}
const options = _this.routeUtils.getAxiosOptions()
let options = _this.routeUtils.getAxiosOptions()
options = _this.sendTxOptions(options)
// RPC call
options.data.id = 'sendrawtransaction'
@@ -557,6 +559,31 @@ class RawTransactions {
return _this.errorHandler(err, res)
}
}
// This method modifies the default axios options. It attempts to inject
// a specific full node to use when broadcasting transactions. This is useful
// because it leverages the built-in protections that a full node has against
// accidental double spends. It mitigates a corner-case when rapidly spending
// TXs on load balanced nodes. By piping all TX sends through a single node,
// accidental double spends can be reduced.
sendTxOptions (options) {
try {
const sendUrl = process.env.RPC_SENDURL
if (sendUrl !== 'undefined' && sendUrl !== undefined) {
// console.log(`original options: ${JSON.stringify(options, null, 2)}`)
options.baseURL = process.env.RPC_SENDURL
// console.log(`modified options: ${JSON.stringify(options, null, 2)}`)
}
return options
} catch (err) {
wlogger.error('Error in rawtransactions.js/sendTxOptions()')
throw err
}
}
}
module.exports = RawTransactions
+122 -3
View File
@@ -100,6 +100,8 @@ class Slp {
_this.router.post('/hydrateUtxos', _this.hydrateUtxos)
_this.router.post('/hydrateUtxosWL', _this.hydrateUtxosWL)
_this.router.get('/status', _this.getStatus)
_this.router.get('/nftChildren/:tokenId', _this.getNftChildren)
_this.router.get('/nftGroup/:tokenId', _this.getNftGroup)
}
// DRY error handler.
@@ -133,6 +135,10 @@ class Slp {
delete token.tokenDetails.batonVout
delete token.tokenDetails.sendOutputs
if (token.tokenDetails.versionType === 65 && token.nftParentId) {
token.tokenDetails.nftParentId = token.nftParentId
}
token.tokenDetails.blockCreated = token.tokenStats.block_created
token.tokenDetails.blockLastActiveSend =
token.tokenStats.block_last_active_send
@@ -296,7 +302,7 @@ class Slp {
'tokenDetails.tokenIdHex': tokenId
}
},
project: { tokenDetails: 1, tokenStats: 1, _id: 0 },
project: { tokenDetails: 1, tokenStats: 1, nftParentId: 1, _id: 0 },
limit: 1000
}
}
@@ -1780,8 +1786,6 @@ class Slp {
// Format the response from SLPDB into an object.
async formatToRestObject (slpDBFormat) {
_this.BigNumber.set({ DECIMAL_PLACES: 8 })
// console.log(`slpDBFormat.data: ${JSON.stringify(slpDBFormat.data, null, 2)}`)
const transaction = slpDBFormat.data.u.length
@@ -2224,6 +2228,121 @@ class Slp {
return _this.errorHandler(err, res)
}
}
/**
* @api {get} /slp/nftChildren/{tokenId} Get all NFT children for a given NFT group
* @apiName Get all NFT children for a given NFT group
* @apiGroup SLP
* @apiDescription Get all NFT children for a given NFT group
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v4/slp/nftChildren/68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a" -H "accept:application/json"
*
*/
async getNftChildren (req, res, next) {
try {
// Validate the input data.
const tokenId = req.params.tokenId
if (!tokenId || tokenId === '') {
res.status(400)
return res.json({ error: 'tokenId can not be empty' })
}
const token = await _this.lookupToken(tokenId)
// console.log(`token: ${JSON.stringify(token, null, 2)}`)
if (!token || token.id === 'not found' || token.versionType !== 129) {
res.status(400)
return res.json({ error: 'NFT group does not exists' })
}
const query = {
v: 3,
q: {
db: ['t'],
aggregate: [
{ $match: { nftParentId: tokenId } },
{ $skip: 0 }, // TODO: pass start point
{ $limit: 100 } // TODO: pass count limit
]
}
}
const s = JSON.stringify(query)
const b64 = Buffer.from(s).toString('base64')
const url = `${process.env.SLPDB_URL}q/${b64}`
// Request options
const opt = {
method: 'get',
baseURL: url
}
const childrenIds = []
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(200)
childrenRes.data.t.forEach(function (token) {
// console.log(`info: ${JSON.stringify(token, null, 2)}`)
if (token.tokenDetails.versionType === 65 && token.tokenDetails.transactionType === 'GENESIS') {
childrenIds.push(token.tokenDetails.tokenIdHex)
}
})
return res.json({ nftChildren: childrenIds })
} catch (err) {
// console.log(err)
wlogger.error('Error in slp.js/getNftChildren().', err)
return _this.errorHandler(err, res)
}
}
/**
* @api {get} /slp/nftGroup/{tokenId} Get the NFT group for a given NFT child token
* @apiName Get the NFT group for a given NFT child token
* @apiGroup SLP
* @apiDescription Get the NFT group for a given NFT child token
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v4/slp/nftGroup/45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9" -H "accept:application/json"
*
*/
async getNftGroup (req, res, next) {
try {
// Validate the input data.
const tokenId = req.params.tokenId
if (!tokenId || tokenId === '') {
res.status(400)
return res.json({ error: 'tokenId can not be empty' })
}
const token = await _this.lookupToken(tokenId)
// console.log(`token: ${JSON.stringify(token, null, 2)}`)
if (!token || token.id === 'not found' || token.versionType !== 65 || !token.nftParentId) {
res.status(400)
return res.json({ error: 'NFT child does not exists' })
}
const parentToken = await _this.lookupToken(token.nftParentId)
// console.log(`parentToken: ${JSON.stringify(token, null, 2)}`)
if (!parentToken || parentToken.id === 'not found' || parentToken.versionType !== 129) {
res.status(400)
return res.json({ error: 'NFT group does not exists' })
}
res.status(200)
return { nftGroup: parentToken }
} catch (err) {
// console.log(err)
wlogger.error('Error in slp.js/getNftGroup().', err)
return _this.errorHandler(err, res)
}
}
}
module.exports = Slp
+9 -2
View File
@@ -154,16 +154,23 @@ class RouteUtils {
}
}
// Handle 429 errors thrown by nginx
// Handle 429 errors
if (err.error) {
// console.log('decodeError: err: ', err)
console.log('decodeError: err: ', err)
// Error thrown by nginx (usually the SLPDB load balancer.)
if (err.error.includes('429 Too Many Requests')) {
const internalMsg =
'429 error thrown by nginx caught by route-utils.js/decodeError()'
console.error(internalMsg)
wlogger.error(internalMsg)
return {
msg: '429 Too Many Requests',
status: 429
}
} else if (err.error.includes('Too many requests')) {
// Error is being thrown by bch-api rate limit middleware.
return {
msg: '429 Too Many Requests',
status: 429
+5 -1
View File
@@ -15,7 +15,11 @@ var NETWORK = process.env.NETWORK
var LOG_MAX_SIZE = process.env.LOG_MAX_SIZE ? process.env.LOG_MAX_SIZE : '1m'
// Default 5 days.
var LOG_MAX_FILES = process.env.LOG_MAX_FILES ? process.env.LOG_MAX_FILES : '5d'
// This was causing a problem with popularity. Creating over a gigabyte of files.
// var LOG_MAX_FILES = process.env.LOG_MAX_FILES ? process.env.LOG_MAX_FILES : '5d'
// 250 files @ 1Meg each = 250 megs
var LOG_MAX_FILES = process.env.LOG_MAX_FILES ? process.env.LOG_MAX_FILES : '250'
// Configure daily-rotation transport.
var transport = new winston.transports.DailyRotateFile({
+9 -4
View File
@@ -15,6 +15,11 @@ export RPC_BASEURL=http://$RPC_IP/
export RPC_USERNAME=bitcoin
export RPC_PASSWORD=password
# (optional) If load-balancing multiple full nodes, it's best to pick a single
# one for broadcasting transactions to the network. Prevents accidental
# double spends.
#export RPC_SENDURL=http://$RPC_IP/
# SLPDB
export SLPDB_PASS_GP=somelongpassword
export SLPDB_URL=http://<SLPDB IP>:12300/
@@ -48,12 +53,12 @@ export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
# that originate froma domain on the whitelist.
export WHITELIST_DOMAINS=fullstack.cash,psfoundation.cash,torlist.cash
# Rate Limits. Numbers are divided into 1000. e.g. 1000 / 50 = 20 RPM for ANON.
# Rate Limits. Numbers are divided into 1000. e.g. 10000 / 500 = 20 RPM for ANON.
# Requests use the ANON rate limit if they fail to pass in a JWT token.
# ANON = 20 requests per minute (RPM)
export ANON_RATE_LIMIT=50
# 10 = 100 RPM
export WHITELIST_RATE_LIMIT=10
export ANON_RATE_LIMIT=500
# 10 = 1000 RPM
export WHITELIST_RATE_LIMIT=100
# Set logging parameters
#1m means no more than 1 megabyte
+200
View File
@@ -1823,4 +1823,204 @@ describe('#BlockchainRouter', () => {
assert.equal(result.length, 2)
})
})
describe('#getBlock()', () => {
it('returns proper error when downstream service stalls', async () => {
// Mock the timeout error.
sandbox.stub(uut.axios, 'request').throws({ code: 'ECONNABORTED' })
req.body.blockhash =
'000000202ed2723e7590e2b937f6821a99d6764cb8799bf30f8e300000000000000000001d311c02df9a1e3f57b8dbdcf97ec8dbc3109a26779724c63e560b29ad9ea501e2af955d286403183049e39c1e000000067139f230701a2819a76795564bd2f67ded7eeae68596f368eddb3dd5bc54e59320e896f71d61cfc3ae3d4a90fca08b1aa35ba91256d8939d2cad11e638c0081f66724abdef55cf7b8b9fed064bce0369171434f8b289c1330ccef765f8e97a2c0d794d81aafb535855f7daa6bb51e40f77c6b59d7af7f62d0eb726a4fc4df82353d56fcbda7c7ea6bd935d61af8fb3b295637e6f323b10231135b3f10a034cfb238f635830c0595e52c6c31247cf677b555f7a287076e20cd0e1d3cc9af7260f02b700'
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('returns proper error when downstream service is down', async () => {
// Mock the timeout error.
sandbox.stub(uut.axios, 'request').throws({ code: 'ECONNREFUSED' })
req.body.blockhash =
'000000202ed2723e7590e2b937f6821a99d6764cb8799bf30f8e300000000000000000001d311c02df9a1e3f57b8dbdcf97ec8dbc3109a26779724c63e560b29ad9ea501e2af955d286403183049e39c1e000000067139f230701a2819a76795564bd2f67ded7eeae68596f368eddb3dd5bc54e59320e896f71d61cfc3ae3d4a90fca08b1aa35ba91256d8939d2cad11e638c0081f66724abdef55cf7b8b9fed064bce0369171434f8b289c1330ccef765f8e97a2c0d794d81aafb535855f7daa6bb51e40f77c6b59d7af7f62d0eb726a4fc4df82353d56fcbda7c7ea6bd935d61af8fb3b295637e6f323b10231135b3f10a034cfb238f635830c0595e52c6c31247cf677b555f7a287076e20cd0e1d3cc9af7260f02b700'
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('should throw 400 if blockhash is empty', async () => {
const result = await uut.getBlock(req, res)
// console.log(`result: ${util.inspect(result)}`)
assert.hasAllKeys(result, ['error'])
assert.include(result.error, 'blockhash can not be empty')
})
it('should return block info with verbosity 0', async () => {
// Mock the RPC call for unit tests.
if (process.env.TEST === 'unit') {
sandbox
.stub(uut.axios, 'request')
.resolves({ data: { result: mockData.mockBlockInfo.verbosity0 } })
}
req.body.blockhash =
'0000000000000000008e8d83cba6d45a9314bc2ef4538d4e0577c6bed8593536'
req.body.verbosity = 0
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isString(result)
})
it('should return block info with verbosity 1', async () => {
// Mock the RPC call for unit tests.
if (process.env.TEST === 'unit') {
sandbox
.stub(uut.axios, 'request')
.resolves({ data: { result: mockData.mockBlockInfo.verbosity1 } })
}
req.body.blockhash =
'0000000000000000008e8d83cba6d45a9314bc2ef4538d4e0577c6bed8593536'
req.body.verbosity = 1
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.property(result, 'hash', 'hash property expected')
assert.property(
result,
'confirmations',
'confirmations property expected'
)
assert.property(result, 'size', 'size property expected')
assert.property(result, 'height', 'height property expected')
assert.property(result, 'version', 'version property expected')
assert.property(result, 'versionHex', 'versionHex property expected')
assert.property(result, 'merkleroot', 'merkleroot property expected')
assert.property(result, 'tx', 'tx property expected')
assert.property(result, 'time', 'time property expected')
assert.property(result, 'mediantime', 'mediantime property expected')
assert.property(result, 'nonce', 'nonce property expected')
assert.property(result, 'bits', 'bits property expected')
assert.property(result, 'difficulty', 'difficulty property expected')
assert.property(result, 'chainwork', 'chainwork property expected')
assert.property(result, 'nTx', 'nTx property expected')
assert.property(
result,
'previousblockhash',
'previousblockhash property expected'
)
assert.property(
result,
'nextblockhash',
'nextblockhash property expected'
)
})
it('should return block info with verbosity 2', async () => {
// Mock the RPC call for unit tests.
if (process.env.TEST === 'unit') {
sandbox
.stub(uut.axios, 'request')
.resolves({ data: { result: mockData.mockBlockInfo.verbosity1 } })
}
req.body.blockhash =
'0000000000000000008e8d83cba6d45a9314bc2ef4538d4e0577c6bed8593536'
req.body.verbosity = 2
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.property(result, 'hash', 'hash property expected')
assert.property(
result,
'confirmations',
'confirmations property expected'
)
assert.property(result, 'size', 'size property expected')
assert.property(result, 'height', 'height property expected')
assert.property(result, 'version', 'version property expected')
assert.property(result, 'versionHex', 'versionHex property expected')
assert.property(result, 'merkleroot', 'merkleroot property expected')
assert.property(result, 'tx', 'tx property expected')
assert.property(result, 'time', 'time property expected')
assert.property(result, 'mediantime', 'mediantime property expected')
assert.property(result, 'nonce', 'nonce property expected')
assert.property(result, 'bits', 'bits property expected')
assert.property(result, 'difficulty', 'difficulty property expected')
assert.property(result, 'chainwork', 'chainwork property expected')
assert.property(result, 'nTx', 'nTx property expected')
assert.property(
result,
'previousblockhash',
'previousblockhash property expected'
)
assert.property(
result,
'nextblockhash',
'nextblockhash property expected'
)
})
it('should return block info without verbosity especified', async () => {
// Mock the RPC call for unit tests.
if (process.env.TEST === 'unit') {
sandbox
.stub(uut.axios, 'request')
.resolves({ data: { result: mockData.mockBlockInfo.verbosity1 } })
}
req.body.blockhash =
'0000000000000000008e8d83cba6d45a9314bc2ef4538d4e0577c6bed8593536'
const result = await uut.getBlock(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.property(result, 'hash', 'hash property expected')
assert.property(
result,
'confirmations',
'confirmations property expected'
)
assert.property(result, 'size', 'size property expected')
assert.property(result, 'height', 'height property expected')
assert.property(result, 'version', 'version property expected')
assert.property(result, 'versionHex', 'versionHex property expected')
assert.property(result, 'merkleroot', 'merkleroot property expected')
assert.property(result, 'tx', 'tx property expected')
assert.property(result, 'time', 'time property expected')
assert.property(result, 'mediantime', 'mediantime property expected')
assert.property(result, 'nonce', 'nonce property expected')
assert.property(result, 'bits', 'bits property expected')
assert.property(result, 'difficulty', 'difficulty property expected')
assert.property(result, 'chainwork', 'chainwork property expected')
assert.property(result, 'nTx', 'nTx property expected')
assert.property(
result,
'previousblockhash',
'previousblockhash property expected'
)
assert.property(
result,
'nextblockhash',
'nextblockhash property expected'
)
})
})
})
+77
View File
@@ -0,0 +1,77 @@
/*
These integration tests need to be run against a live SLPDB. They query
against a live SLPDB and test the results against known token stats.
*/
'use strict'
const chai = require('chai')
const assert = chai.assert
// const axios = require('axios')
// Used for debugging.
const util = require('util')
util.inspect.defaultOptions = { depth: 1 }
// Exit if SLPDB URL is not defined.
if (!process.env.SLPDB_URL) {
throw new Error(
'SLPDB_URL and SLPDB_PASS must be defined in order to run these tests.'
)
}
const SLP = require('../../../src/routes/v4/slp')
const slp = new SLP()
const { mockReq, mockRes } = require('../mocks/express-mocks')
describe('#nft', () => {
let req, res
beforeEach(() => {
// Mock the req and res objects used by Express routes.
req = mockReq
res = mockRes
})
describe('#getNftChildren', () => {
it('should get NFT children list', async () => {
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
const result = await slp.getNftChildren(req, res)
// console.log(`result: ${util.inspect(result)}`)
assert.isArray(result.nftChildren)
assert.equal(result.nftChildren.length, 2)
assert.equal(
result.nftChildren[0],
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
)
assert.equal(
result.nftChildren[1],
'928ce61fe1006b1325a0ba0dce700bf83986a6f0691ba26e121c9ac035d12a55'
)
})
})
describe('#getNftGroup', () => {
it('should get NFT group token info', async () => {
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
// req.params.tokenId = '928ce61fe1006b1325a0ba0dce700bf83986a6f0691ba26e121c9ac035d12a55'
const result = await slp.getNftGroup(req, res)
// console.log(`result: ${util.inspect(result)}`)
assert.property(result, 'nftGroup')
assert.property(result.nftGroup, 'id')
assert.property(result.nftGroup, 'versionType')
assert.property(result.nftGroup, 'symbol')
assert.equal(
result.nftGroup.id,
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
)
assert.equal(result.nftGroup.versionType, 129)
assert.equal(result.nftGroup.symbol, 'PSF.TEST.GROUP')
})
})
})
+82 -2
View File
@@ -285,7 +285,86 @@ const mockAncestors = [
'e68dad4a7292105cfa84fcaef7f99e5d4f2ece9613ca625d4d2ebf61efa84118',
'fe94caf5da672be3772d2304a6272eb8bc3d3f5cb4a886f39b7981e1485cf74b'
]
const mockBlockInfo = {
verbosity0: '20000000',
verbosity1: {
hash: '00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09',
confirmations: 1,
size: 3725,
strippedsize: 3725,
weight: 3725,
height: 6725,
version: 1,
versionHex: '00000000',
merkleroot: 'xxxx',
tx: [
'2afb8264508e2bf3e5288ccad01ed2ab766745b6b9747666b519d59212012c01',
'18f40b1ae56bba3fa1934b737fbe46ed8d5ca40fa9aed95073eeb5a119530cd3',
'349720d878547752607a69eb19e330592fee271fb5376cdfd811bee423558ed8',
'35571c80e7d0e9247b467454ef147d1d5833c775bc2d4164b1bebd4c1f69164f',
'480937e8efacdafeeb97d401ff0dd9ea8e8ddb27244cefa67a03621315bdb0e6',
'523327469d0b90c0de9a905c2fe6e227278fc5b55b9d9911ca151e1c26647065',
'61de4af971d94dbc741762f21dcef08b74b62863a56a1cb3496becdd8d47a858',
'69f70a288403b5bba23030ccd05d2e5cb00394620fdae3b050cff9432cc590ce',
'94472a90fbdba2eb2cba68308415181faedf3585c66b89efcbdb927a0c10ba23',
'bc6f781f9e2f2df460f89995c5e1c7224e48ccbe1aa2a575961f3f5330259864',
'f2d945a79bec5454a9ab4d570a150d81124daa308f1c81106a977d6413476944'
],
time: 111,
mediantime: 111,
nonce: 111,
bits: '1d00ffff',
difficulty: 99.999,
chainwork: 'xxxx',
nTx: 1,
previousblockhash:
'00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09',
nextblockhash:
'00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09'
},
verbosity2: {
hash: '00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09',
confirmations: 1,
size: 3725,
strippedsize: 3725,
weight: 3725,
height: 6725,
version: 1,
versionHex: '00000000',
merkleroot: 'xxxx',
tx: [
{
hex:
'01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000',
txid:
'0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098',
hash:
'0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098',
size: 134,
version: 1,
locktime: 0,
vin: [],
vout: [],
blockhash:
'00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048',
confirmations: 581882,
time: 1231469665,
blocktime: 1231469665
}
],
time: 111,
mediantime: 111,
nonce: 111,
bits: '1d00ffff',
difficulty: 99.999,
chainwork: 'xxxx',
nTx: 1,
previousblockhash:
'00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09',
nextblockhash:
'00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09'
}
}
module.exports = {
mockBlockHash,
mockBlockchainInfo,
@@ -296,5 +375,6 @@ module.exports = {
mockBlockHeader,
mockTxOut,
mockTxOutProof,
mockAncestors
mockAncestors,
mockBlockInfo
}
+66 -1
View File
@@ -66,6 +66,69 @@ const mockSingleToken = {
]
}
const mockNftGroup = {
decimals: 0,
timestamp: '2021-05-03 10:36:01',
timestamp_unix: 1620038161,
versionType: 129,
documentUri: 'psfoundation.cash',
symbol: 'PSF.TEST.GROUP',
name: 'PSF Test NFT Group',
containsBaton: true,
id: '68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a',
documentHash: null,
initialTokenQty: 1000000,
blockCreated: 686117,
totalMinted: null,
totalBurned: null,
circulatingSupply: null
}
const mockNftChildren = [
{
decimals: 0,
timestamp: '2021-05-03 11:59:30',
timestamp_unix: 1620043170,
versionType: 65,
documentUri: 'psfoundation.cash',
symbol: 'PSF.TEST.CHILD.1',
name: 'PSF Test NFT Child #1',
containsBaton: false,
id: '45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9',
documentHash: null,
initialTokenQty: 1,
nftParentId: '68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a',
blockCreated: 686130,
totalMinted: null,
totalBurned: null,
circulatingSupply: null,
// only in axios.data.t
transactionType: 'GENESIS',
tokenIdHex: '45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
},
{
decimals: 0,
timestamp: '2021-05-03 11:59:30',
timestamp_unix: 1620043170,
versionType: 65,
documentUri: 'psfoundation.cash',
symbol: 'PSF.TEST.CHILD.2',
name: 'PSF Test NFT Child #2',
containsBaton: false,
id: '928ce61fe1006b1325a0ba0dce700bf83986a6f0691ba26e121c9ac035d12a55',
documentHash: null,
initialTokenQty: 1,
nftParentId: '68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a',
blockCreated: 686130,
totalMinted: null,
totalBurned: null,
circulatingSupply: null,
// only in axios.data.t
transactionType: 'GENESIS',
tokenIdHex: '928ce61fe1006b1325a0ba0dce700bf83986a6f0691ba26e121c9ac035d12a55'
}
]
const mockSingleTokenError = {
t: []
}
@@ -1038,5 +1101,7 @@ module.exports = {
mockPsfToken,
mockValidateBulk,
mockValidate3Bulk,
mockStatus
mockStatus,
mockNftGroup,
mockNftChildren
}
+8 -7
View File
@@ -135,9 +135,9 @@ describe('#rate-routelimit', () => {
// assert.equal(result.id, '123.456.789.10')
assert.property(result, 'email')
// assert.equal(result.email, 'test@bchtest.net')
assert.property(result, 'pointsToConsume')
// assert.property(result, 'pointsToConsume')
// assert.equal(result.pointsToConsume, config.anonRateLimit)
assert.property(result, 'duration')
// assert.property(result, 'duration')
// assert.equal(result.duration, 30)
assert.property(result, 'exp')
})
@@ -309,10 +309,10 @@ describe('#rate-routelimit', () => {
let val
for (let i = 0; i < 25; i++) {
console.log('req.locals: ', req.locals)
// console.log('req.locals: ', req.locals)
val = await uut.applyRateLimits(req, res, next)
}
console.log('val: ', val)
// console.log('val: ', val)
assert.property(val, 'error')
assert.include(
@@ -446,7 +446,7 @@ describe('#rate-routelimit', () => {
// Generate a new JWT token for the test.
const jwtPayload = {
id: '5dade3f5739e6c0ff034b9a1',
pointsToConsume: 10
pointsToConsume: 100
}
const jwtToken = uut.generateJwtToken(jwtPayload)
@@ -460,7 +460,7 @@ describe('#rate-routelimit', () => {
for (let i = 0; i < 120; i++) {
val = await uut.applyRateLimits(req, res, next)
}
console.log('val: ', val)
// console.log('val: ', val)
assert.property(val, 'error')
assert.include(
@@ -470,11 +470,12 @@ describe('#rate-routelimit', () => {
assert.equal(
res.locals.pointsToConsume,
10,
100,
'User JWT rate limits applied'
)
} catch (err) {
console.log('err: ', err)
assert.fail('Unexpected result')
}
})
+4
View File
@@ -250,6 +250,7 @@ describe('#Raw-Transactions', () => {
'Proper error message'
)
})
it('returns proper error when downstream service stalls', async () => {
req.body.hexes = [
'0200000001b9b598d7d6d72fc486b2b3a3c03c79b5bade6ec9a77ced850515ab5e64edcc21010000006b483045022100a7b1b08956abb8d6f322aa709d8583c8ea492ba0585f1a6f4f9983520af74a5a0220411aee4a9a54effab617b0508c504c31681b15f9b187179b4874257badd4139041210360cfc66fdacb650bc4c83b4e351805181ee696b7d5ab4667c57b2786f51c413dffffffff0210270000000000001976a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac786e9800000000001976a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac00000000'
@@ -1046,10 +1047,12 @@ describe('#Raw-Transactions', () => {
// Save the existing RPC URL.
const savedUrl = process.env.BITCOINCOM_BASEURL
const savedUrl2 = process.env.RPC_BASEURL
const savedUrl3 = process.env.RPC_SENDURL
// Manipulate the URL to cause a 500 network error.
process.env.BITCOINCOM_BASEURL = 'http://fakeurl/api/'
process.env.RPC_BASEURL = 'http://fakeurl/api/'
process.env.RPC_SENDURL = 'http://fakeurl/api/'
req.params.hex =
'020000000136697692fed77bc4f5b6885295d0c56d1d0280fb578f445ce42be4eb6db381f2010000006a4730440220473adba0e7da14f0abf4817bbd591741ecb8da6544b998f10341f6704f5f05280220405221c626cb7edcf333367ebd469aff3f5a2169e37ee58eebb811ffc2fbc9e0412102202ff86325c5d903171fa5a2895c4efb3765105115460dc96f113048ddb69b47feffffff027a621b00000000001976a914e0a8ffc3b91e35f46618d6db90f66397989abf0588ac38041300000000001976a914a741f282af390bc7ea8c4375a3a56401d668564288ac2c330900'
@@ -1059,6 +1062,7 @@ describe('#Raw-Transactions', () => {
// Restore the saved URL.
process.env.BITCOINCOM_BASEURL = savedUrl
process.env.RPC_BASEURL = savedUrl2
process.env.RPC_SENDURL = savedUrl3
assert.isAbove(
res.statusCode,
+34
View File
@@ -0,0 +1,34 @@
/*
Unit tests for the route-utils.js library.
*/
const assert = require('chai').assert
const RouteUtils = require('../../src/util/route-utils.js')
describe('#route-utils', () => {
let uut
beforeEach(() => {
uut = new RouteUtils()
})
describe('#decodeError', () => {
it('should decode a 429 error from nginx', () => {
const err = {
error: '<html>\r\n<head><title>429 Too Many Requests</title></head>\r\n<body>\r\n<center><h1>429 Too Many Requests</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n',
level: 'error',
message: 'Error in slp.js/hydrateUtxos().',
timestamp: '2021-03-31T04:13:36.662Z'
}
const result = uut.decodeError(err)
// console.log('result: ', result)
assert.property(result, 'msg')
assert.equal(result.msg, '429 Too Many Requests')
assert.property(result, 'status')
assert.equal(result.status, 429)
})
})
})
+271
View File
@@ -1760,6 +1760,277 @@ describe('#SLP', () => {
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
})
})
describe('#getNftChildren', () => {
it('should throw 400 if tokenID is empty', async () => {
req.params.tokenId = ''
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${util.inspect(result)}`)
assert.hasAllKeys(result, ['error'])
assert.include(result.error, 'tokenId can not be empty')
})
it('returns proper error when downstream service stalls', async () => {
// Mock the timeout error.
sandbox.stub(slpRoute.axios, 'request').throws({ code: 'ECONNABORTED' })
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('returns proper error when downstream service is down', async () => {
// Mock the timeout error.
sandbox.stub(slpRoute.axios, 'request').throws({ code: 'ECONNREFUSED' })
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('should return error on non-existing NFT group token', async () => {
if (process.env.TEST === 'unit') {
sandbox.stub(slpRoute, 'lookupToken').resolves({ id: 'not found' })
}
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0b'
const result = await slpRoute.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 return error on non-group NFT token', async () => {
if (process.env.TEST === 'unit') {
sandbox
.stub(slpRoute, 'lookupToken')
.resolves(mockData.mockNftChildren[0])
}
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0b'
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.include(
result.error,
'NFT group does not exists',
'Error message expected'
)
})
if (process.env.TEST === 'unit') {
it('should return error on invalid NFT group data', async () => {
sandbox.stub(slpRoute, 'lookupToken').resolves(mockData.mockNftGroup)
sandbox.stub(slpRoute.axios, 'request').resolves({
data: { u: 'invalid' }
})
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.include(
result.error,
'No children data in the group',
'Error message expected'
)
})
}
if (process.env.ISBCHN) {
it('should get NFT children IDs in given NFT group', async () => {
if (process.env.TEST === 'unit') {
sandbox.stub(slpRoute, 'lookupToken').resolves(mockData.mockNftGroup)
sandbox.stub(slpRoute.axios, 'request').resolves({
data: {
t: [
{
tokenDetails: mockData.mockNftChildren[0],
nftParentId: mockData.mockNftGroup.id
},
{
tokenDetails: mockData.mockNftChildren[1],
nftParentId: mockData.mockNftGroup.id
}
]
}
})
}
req.params.tokenId =
'68cd33ecd909068fbea318ae5ff1d6207cf754e53b191327d6d73b6916424c0a'
const result = await slpRoute.getNftChildren(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isArray(result.nftChildren)
assert.equal(result.nftChildren.length, 2)
assert.equal(
result.nftChildren[0],
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
)
assert.equal(
result.nftChildren[1],
'928ce61fe1006b1325a0ba0dce700bf83986a6f0691ba26e121c9ac035d12a55'
)
})
}
})
describe('#getNftGroup', () => {
it('should throw 400 if tokenID is empty', async () => {
req.params.tokenId = ''
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${util.inspect(result)}`)
assert.hasAllKeys(result, ['error'])
assert.include(result.error, 'tokenId can not be empty')
})
it('returns proper error when downstream service stalls', async () => {
// Mock the timeout error.
sandbox.stub(slpRoute.axios, 'request').throws({ code: 'ECONNABORTED' })
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('returns proper error when downstream service is down', async () => {
// Mock the timeout error.
sandbox.stub(slpRoute.axios, 'request').throws({ code: 'ECONNREFUSED' })
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(res.statusCode, 499, 'HTTP status code 503 expected.')
assert.include(
result.error,
'Could not communicate with full node',
'Error message expected'
)
})
it('should return error on non-existing NFT child token', async () => {
if (process.env.TEST === 'unit') {
sandbox.stub(slpRoute, 'lookupToken').resolves({ id: 'not found' })
}
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a8'
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.include(
result.error,
'NFT child does not exists',
'Error message expected'
)
})
it('should return error on invalid NFT child token', async () => {
if (process.env.TEST === 'unit') {
sandbox.stub(slpRoute, 'lookupToken').resolves(mockData.mockNftGroup)
}
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a8'
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.include(
result.error,
'NFT child does not exists',
'Error message expected'
)
})
if (process.env.TEST === 'unit') {
it('should return error on invalid parent', async () => {
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
const callback = sandbox.stub(slpRoute, 'lookupToken')
callback
.withArgs(req.params.tokenId)
.resolves(mockData.mockNftChildren[0])
// parent is non-valid NFT group (type != 129)
callback
.withArgs(mockData.mockNftGroup.id)
.resolves(mockData.mockNftChildren[0])
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.include(
result.error,
'NFT group does not exists',
'Error message expected'
)
})
}
if (process.env.ISBCHN) {
it('should get NFT group information for tokenId', async () => {
req.params.tokenId =
'45a30085691d6ea586e3ec2aa9122e9b0e0d6c3c1fd357decccc15d8efde48a9'
if (process.env.TEST === 'unit') {
const callback = sandbox.stub(slpRoute, 'lookupToken')
callback
.withArgs(req.params.tokenId)
.resolves(mockData.mockNftChildren[0])
callback
.withArgs(mockData.mockNftGroup.id)
.resolves(mockData.mockNftGroup)
}
const result = await slpRoute.getNftGroup(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.property(result, 'nftGroup')
assert.property(result.nftGroup, 'id')
assert.equal(result.nftGroup.id, mockData.mockNftGroup.id)
assert.property(result.nftGroup, 'versionType')
assert.equal(result.nftGroup.versionType, 129)
assert.property(result.nftGroup, 'symbol')
assert.property(result.nftGroup, 'initialTokenQty')
})
}
})
})
/*