Got all tests passing again

This commit is contained in:
Chris Troutner
2021-07-17 08:15:02 -07:00
parent 6f619db666
commit e04cb1f05a
8 changed files with 76 additions and 3230 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ async function startServer () {
// Attach REST API and JSON RPC controllers to the app.
const controllers = require('../src/controllers')
controllers.attachControllers(app)
await controllers.attachControllers(app)
// Enable CORS for testing
// THIS IS A SECURITY RISK. COMMENT OUT FOR PRODUCTION
+55 -3224
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -8,7 +8,7 @@
"test": "npm run test:all",
"test:all": "export SVC_ENV=test && nyc --reporter=text mocha --exit --timeout 15000 --recursive test/unit test/e2e/automated/",
"test:unit": "export SVC_ENV=test && mocha --exit --timeout 15000 --recursive test/unit/",
"test:e2e:auto": "export SVC_ENV=test && mocha --exit --timeout 15000 test/e2e/automated/",
"test:e2e:auto": "export SVC_ENV=test && mocha --exit --timeout 30000 test/e2e/automated/",
"test:temp": "export SVC_ENV=test && mocha --exit --timeout 15000 -g '#rate-limit' test/unit/json-rpc/",
"lint": "standard --env mocha --fix",
"docs": "./node_modules/.bin/apidoc -i src/ -o docs",
@@ -28,7 +28,7 @@
"bcryptjs": "^2.4.3",
"glob": "^7.1.6",
"ipfs": "^0.54.4",
"ipfs-coord": "^3.2.0",
"ipfs-coord": "../ipfs-coord/",
"jsonrpc-lite": "^2.2.0",
"jsonwebtoken": "^8.5.1",
"jwt-bch-lib": "^1.3.0",
+5 -1
View File
@@ -42,7 +42,7 @@ class IpfsCoordAdapter {
_this = this
}
async start () {
async start (localConfig = {}) {
this.ipfsCoord = new this.IpfsCoord({
ipfs: this.ipfs,
type: 'node.js',
@@ -54,8 +54,12 @@ class IpfsCoordAdapter {
announceJsonLd: this.config.announceJsonLd
})
// Skip connecting ipfs-coord to the network if this is an E2E test.
if (!process.env.E2ETEST) {
// Wait for the ipfs-coord library to signal that it is ready.
await this.ipfsCoord.ipfs.start()
await this.ipfsCoord.isReady()
}
// Signal that this adapter is ready.
this.isReady = true
+1
View File
@@ -63,6 +63,7 @@ class IpfsAdapter {
// Stop the IPFS node if we're running tests.
if (this.config.env === 'test') {
console.log('Stopping IPFS for tests.')
await this.ipfs.stop()
}
+2
View File
@@ -23,6 +23,8 @@ const LOCALHOST = `http://localhost:${config.port}`
describe('Auth', () => {
before(async () => {
try {
process.env.E2ETEST = 'true'
// This should be the first instruction. It starts the REST API server.
await app.startServer()
@@ -23,6 +23,8 @@ describe('#Controllers', () => {
it('should attach the controllers', async () => {
// mock IPFS
sandbox.stub(adapters.ipfs, 'start').resolves({})
sandbox.stub(adapters.fullStackJwt, 'getJWT').resolves({})
sandbox.stub(adapters.fullStackJwt, 'instanceBchjs').resolves({})
adapters.ipfs.ipfsCoordAdapter = {
attachRPCRouter: () => {}
}
+6
View File
@@ -3,6 +3,12 @@
*/
class IPFSCoord {
constructor () {
this.ipfs = {
async start () {}
}
}
async isReady () {
return true
}