mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 17:22:04 -07:00
fix(error handling): Replacing improper 429 with 400
This commit is contained in:
@@ -169,7 +169,7 @@ class Blockbook {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -333,7 +333,7 @@ class Blockbook {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -472,7 +472,7 @@ class Blockbook {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -470,7 +470,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
success: false,
|
success: false,
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
@@ -726,7 +726,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, heights)) {
|
if (!_this.routeUtils.validateArraySize(req, heights)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
success: false,
|
success: false,
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
@@ -895,7 +895,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -1088,7 +1088,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -1281,7 +1281,7 @@ class Electrum {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class Slp {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, tokenIds)) {
|
if (!_this.routeUtils.validateArraySize(req, tokenIds)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -545,7 +545,7 @@ class Slp {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -914,7 +914,7 @@ class Slp {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
if (!_this.routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -975,7 +975,7 @@ class Slp {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
@@ -1403,7 +1403,7 @@ class Slp {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
if (!_this.routeUtils.validateArraySize(req, txids)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class UtilRoute {
|
|||||||
|
|
||||||
// Enforce array size rate limits
|
// Enforce array size rate limits
|
||||||
if (!routeUtils.validateArraySize(req, addresses)) {
|
if (!routeUtils.validateArraySize(req, addresses)) {
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(400) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
return res.json({
|
return res.json({
|
||||||
error: 'Array too large.'
|
error: 'Array too large.'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ describe('#Electrumx', () => {
|
|||||||
assert.isArray(result.transactions)
|
assert.isArray(result.transactions)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw 429 error if txid array is too large', async () => {
|
it('should throw 400 error if txid array is too large', async () => {
|
||||||
const testArray = []
|
const testArray = []
|
||||||
for (var i = 0; i < 25; i++) testArray.push('')
|
for (var i = 0; i < 25; i++) testArray.push('')
|
||||||
|
|
||||||
@@ -603,7 +603,7 @@ describe('#Electrumx', () => {
|
|||||||
const result = await electrumxRoute.transactionDetailsBulk(req, res)
|
const result = await electrumxRoute.transactionDetailsBulk(req, res)
|
||||||
// console.log(`result: ${util.inspect(result)}`)
|
// console.log(`result: ${util.inspect(result)}`)
|
||||||
|
|
||||||
expectRouteError(res, result, 'Array too large', 429)
|
expectRouteError(res, result, 'Array too large', 400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should get details for a single txid', async () => {
|
it('should get details for a single txid', async () => {
|
||||||
@@ -841,7 +841,7 @@ describe('#Electrumx', () => {
|
|||||||
assert.isArray(result.headers)
|
assert.isArray(result.headers)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw 429 error if heights array is too large', async () => {
|
it('should throw 400 error if heights array is too large', async () => {
|
||||||
const testArray = []
|
const testArray = []
|
||||||
for (var i = 0; i < 25; i++) testArray.push('')
|
for (var i = 0; i < 25; i++) testArray.push('')
|
||||||
|
|
||||||
@@ -849,7 +849,7 @@ describe('#Electrumx', () => {
|
|||||||
|
|
||||||
const result = await electrumxRoute.blockHeadersBulk(req, res)
|
const result = await electrumxRoute.blockHeadersBulk(req, res)
|
||||||
|
|
||||||
expectRouteError(res, result, 'Array too large', 429)
|
expectRouteError(res, result, 'Array too large', 400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should get details for a single height', async () => {
|
it('should get details for a single height', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user