mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fix(error handling): Improved error handling. Thowing errors, not objects
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
"test:integration:fullstack:free": "export RESTURL=https://bch.fullstack.cash/v6 && mocha --timeout 60000 test/integration/",
|
"test:integration:fullstack:free": "export RESTURL=https://bch.fullstack.cash/v6 && mocha --timeout 60000 test/integration/",
|
||||||
"test:integration:fullstack:x402": "export RESTURL=https://x402-bch.fullstack.cash/v6 && export BCHJSWIF=L1eYaneXDDXy8VDig4Arwe8wYHbhtsA5wuQvwsKwhaYeneoZuKG4 && mocha --timeout 120000 test/integration/",
|
"test:integration:fullstack:x402": "export RESTURL=https://x402-bch.fullstack.cash/v6 && export BCHJSWIF=L1eYaneXDDXy8VDig4Arwe8wYHbhtsA5wuQvwsKwhaYeneoZuKG4 && mocha --timeout 120000 test/integration/",
|
||||||
"test:integration:fullstack:auth": "export RESTURL=http://dev.fullstack.cash/v6 && export BCHJSBEARERTOKEN=test01 && mocha --timeout 30000 test/integration/",
|
"test:integration:fullstack:auth": "export RESTURL=http://dev.fullstack.cash/v6 && export BCHJSBEARERTOKEN=test01 && mocha --timeout 30000 test/integration/",
|
||||||
"test:integration:local:noauth": "export RESTURL=http://localhost:5942/v6 && mocha --timeout 30000 test/integration/",
|
"test:integration:local:noauth": "export RESTURL=http://192.168.1.65:5942/v6 && mocha --timeout 30000 test/integration/",
|
||||||
"test:integration:local:auth": "export RESTURL=http://192.168.1.115:5942/v6 && export BCHJSBEARERTOKEN=temp01 && mocha --timeout 30000 test/integration/",
|
"test:integration:local:auth": "export RESTURL=http://192.168.1.115:5942/v6 && export BCHJSBEARERTOKEN=temp01 && mocha --timeout 30000 test/integration/",
|
||||||
"test:integration:local:x402": "export RESTURL=http://localhost:5942/v6 && export BCHJSWIF=L1eYaneXDDXy8VDig4Arwe8wYHbhtsA5wuQvwsKwhaYeneoZuKG4 && mocha --timeout 1200000 test/integration/",
|
"test:integration:local:x402": "export RESTURL=http://localhost:5942/v6 && export BCHJSWIF=L1eYaneXDDXy8VDig4Arwe8wYHbhtsA5wuQvwsKwhaYeneoZuKG4 && mocha --timeout 1200000 test/integration/",
|
||||||
"test:integration:decatur": "export RESTURL=http://192.168.1.65:5942/v6 && mocha --timeout 30000 test/integration/",
|
"test:integration:decatur": "export RESTURL=http://192.168.1.65:5942/v6 && mocha --timeout 30000 test/integration/",
|
||||||
|
|||||||
+96
-39
@@ -47,8 +47,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,8 +108,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +161,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +198,11 @@ class Blockchain {
|
|||||||
console.log('Error in bch-js/blockchain.js/getBlockCount()')
|
console.log('Error in bch-js/blockchain.js/getBlockCount()')
|
||||||
console.log('blockchain.js restURL: ', this.restURL)
|
console.log('blockchain.js restURL: ', this.restURL)
|
||||||
|
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +234,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,10 +302,13 @@ class Blockchain {
|
|||||||
|
|
||||||
throw new Error('Input hash must be a string or array of strings.')
|
throw new Error('Input hash must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Error in bch-js/blockchain.js/getBlockHeader() error: ', error)
|
// console.log('Error in bch-js/blockchain.js/getBlockHeader() error: ', error)
|
||||||
|
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,8 +350,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,8 +385,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,8 +404,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,8 +422,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,8 +537,11 @@ class Blockchain {
|
|||||||
|
|
||||||
throw new Error('Input must be a string or array of strings.')
|
throw new Error('Input must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,8 +576,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,8 +626,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,8 +683,11 @@ class Blockchain {
|
|||||||
|
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,8 +753,11 @@ class Blockchain {
|
|||||||
|
|
||||||
throw new Error('Input must be a string or array of strings.')
|
throw new Error('Input must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,8 +769,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,8 +785,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,8 +801,11 @@ class Blockchain {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,8 +872,11 @@ class Blockchain {
|
|||||||
|
|
||||||
throw new Error('Input must be a string or array of strings.')
|
throw new Error('Input must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -62,8 +62,11 @@ class DSProof {
|
|||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-15
@@ -120,8 +120,11 @@ class ElectrumX {
|
|||||||
|
|
||||||
throw new Error('Input address must be a string or array of strings.')
|
throw new Error('Input address must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,8 +207,11 @@ class ElectrumX {
|
|||||||
|
|
||||||
throw new Error('Input address must be a string or array of strings.')
|
throw new Error('Input address must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,8 +311,11 @@ class ElectrumX {
|
|||||||
throw new Error('Input address must be a string or array of strings.')
|
throw new Error('Input address must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log('Error in transactions(): ', error)
|
// console.log('Error in transactions(): ', error)
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,8 +406,11 @@ class ElectrumX {
|
|||||||
|
|
||||||
throw new Error('Input address must be a string or array of strings.')
|
throw new Error('Input address must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,9 +465,13 @@ class ElectrumX {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log("error: ", error)
|
// console.log("error: ", error)
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
if (error.response && error.response.data) {
|
const errorData = error.response.data
|
||||||
throw new Error(error.response.data.error)
|
if (errorData.error) {
|
||||||
} else throw error.response.data
|
throw new Error(errorData.error)
|
||||||
|
} else {
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@@ -555,8 +571,11 @@ class ElectrumX {
|
|||||||
|
|
||||||
throw new Error('Input txId must be a string or array of strings.')
|
throw new Error('Input txId must be a string or array of strings.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,8 +614,11 @@ class ElectrumX {
|
|||||||
|
|
||||||
throw new Error('Input txHex must be a string.')
|
throw new Error('Input txHex must be a string.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) throw error.response.data
|
if (error.response && error.response.data) {
|
||||||
else throw error
|
const errorData = error.response.data
|
||||||
|
const errorMessage = typeof errorData === 'string' ? errorData : (errorData.error || errorData.message || JSON.stringify(errorData))
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
} else throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ describe('#blockchain', () => {
|
|||||||
console.log(`result: ${util.inspect(result)}`)
|
console.log(`result: ${util.inspect(result)}`)
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -171,8 +171,8 @@ describe('#blockchain', () => {
|
|||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// console.log(`err: ${util.inspect(err)}`)
|
// console.log(`err: ${util.inspect(err)}`)
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Transaction not in mempool')
|
assert.include(err.message, 'Transaction not in mempool')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -241,8 +241,8 @@ describe('#blockchain', () => {
|
|||||||
console.log(`result: ${util.inspect(result)}`)
|
console.log(`result: ${util.inspect(result)}`)
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ describe('#ElectrumX', () => {
|
|||||||
// console.log(`result: ${util.inspect(result)}`)
|
// console.log(`result: ${util.inspect(result)}`)
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -129,8 +129,8 @@ describe('#ElectrumX', () => {
|
|||||||
|
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -187,8 +187,8 @@ describe('#ElectrumX', () => {
|
|||||||
|
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -250,8 +250,8 @@ describe('#ElectrumX', () => {
|
|||||||
// console.log(`result: ${util.inspect(result)}`)
|
// console.log(`result: ${util.inspect(result)}`)
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -345,8 +345,8 @@ describe('#ElectrumX', () => {
|
|||||||
// console.log(`result: ${util.inspect(result)}`)
|
// console.log(`result: ${util.inspect(result)}`)
|
||||||
assert.equal(true, false, 'Unexpected result!')
|
assert.equal(true, false, 'Unexpected result!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.hasAnyKeys(err, ['error'])
|
assert.instanceOf(err, Error)
|
||||||
assert.include(err.error, 'Array too large')
|
assert.include(err.message, 'Array too large')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -359,8 +359,9 @@ describe('#ElectrumX', () => {
|
|||||||
try {
|
try {
|
||||||
await bchjs.Electrumx.broadcast(txHex)
|
await bchjs.Electrumx.broadcast(txHex)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// console.error('err: ', err)
|
||||||
assert.include(
|
assert.include(
|
||||||
err.error,
|
err.message,
|
||||||
'the transaction was rejected by network rules'
|
'the transaction was rejected by network rules'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ describe('#Blockchain', () => {
|
|||||||
await bchjs.Blockchain.getBlock(blockhash)
|
await bchjs.Blockchain.getBlock(blockhash)
|
||||||
assert2.fail('Unexpected result')
|
assert2.fail('Unexpected result')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert2.include(err, 'Test Error')
|
assert2.include(err.message, 'Test Error')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user