Skip to content

Commit

Permalink
fix: trying to add healthchecks instead of waiting for gh actions 🕓
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Feb 15, 2022
1 parent a43963a commit 6ca1b30
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 58 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/check-PRs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ jobs:
docker-compose build
./start-nightfall -g &> ganache-test.log &disown
- name: wait 2000s for Containers startup and setup completion
run: sleep 2000

- name: debug logs - after container startup
if: always()
run: cat ganache-test.log

- name: Run integration test
run: |
npm ci
docker wait nightfall_3_deployer_1
VERBOSE=true npm run test-e2e-protocol
VERBOSE=true npm run test-e2e-tokens
Expand Down
1 change: 0 additions & 1 deletion nightfall-client/src/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ app.use(cors());
app.use(bodyParser.json({ limit: '2mb' }));
app.use(bodyParser.urlencoded({ limit: '2mb', extended: true }));

app.get('/healthcheck', (req, res) => res.sendStatus(200));
app.use('/deposit', deposit);
app.use('/contract-address', getContractAddress);
app.use('/transfer', transfer);
Expand Down
8 changes: 5 additions & 3 deletions nightfall-client/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const main = async () => {
await rabbitmq.connect();
queues();
}
initialClientSync().then(async () => {
await startEventQueue(queueManager, eventHandlers);
});
await initialClientSync();
await startEventQueue(queueManager, eventHandlers);

app.get('/healthcheck', (req, res) => res.sendStatus(200));

await mongo.connection(config.MONGO_URL); // get a db connection
app.listen(80);
} catch (err) {
Expand Down
6 changes: 5 additions & 1 deletion nightfall-client/src/routes/contract-address.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ router.get('/:contract', async (req, res, next) => {
try {
const address = await getContractAddress(contract);
logger.debug(`returning address ${address}`);
res.json({ address });
if (address) {
res.json({ address });
} else {
res.sendStatus(404);
}
} catch (err) {
logger.error(err);
next(err);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"scripts": {
"neg-test": "mocha --timeout 0 --bail --exit test/neg-http.mjs",
"neg-test-ropsten": "mocha --timeout 0 --bail --exit test/neg-http.mjs",
"test-e2e-protocol": "mocha --timeout 0 --bail --exit test/e2e/protocol/index.test.mjs ",
"test-gas": "mocha --timeout 0 --bail --exit test/e2e/protocol/gas.test.mjs ",
"test-e2e-tokens": "mocha --timeout 0 --bail --exit test/e2e/tokens/index.test.mjs ",
"test-e2e-protocol": "mocha --timeout 0 --bail --parallel --exit test/e2e/protocol/*.test.mjs ",
"test-gas": "mocha --timeout 0 --bail --exit test/e2e/gas.test.mjs ",
"test-e2e-tokens": "mocha --timeout 0 --bail --parallel --exit test/e2e/tokens/*.test.mjs ",
"lint": "eslint . --ext js,mjs,jsx && find-unused-exports",
"prepare": "husky install",
"doc:build:sdk": "jsdoc -c jsdoc.json cli/lib/nf3.mjs"
Expand Down
24 changes: 10 additions & 14 deletions test/e2e/protocol/gas.test.mjs → test/e2e/gas.test.mjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
/* eslint-disable no-await-in-loop */
import chai from 'chai';
import chaiHttp from 'chai-http';
import config from 'config';
import chaiAsPromised from 'chai-as-promised';
import { createRequire } from 'module';
import Nf3 from '../../../cli/lib/nf3.mjs';
import { depositNTransactions, Web3Client } from '../../utils.mjs';
import Nf3 from '../../cli/lib/nf3.mjs';
import { depositNTransactions, Web3Client } from '../utils.mjs';

// so we can use require with mjs file
const require = createRequire(import.meta.url);
const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);
const { web3WsUrl, network } = process.env;

// we need require here to import jsons
const environments = require('../environments.json');
const mnemonics = require('../mnemonics.json');
const signingKeys = require('../signingKeys.json');
const { fee, transferValue } = require('../configs.json');
const { tokenType, tokenId } = require('../tokenConfigs.json');
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;
const mnemonics = require('./mnemonics.json');
const signingKeys = require('./signingKeys.json');
const { fee, transferValue } = require('./configs.json');
const { tokenType, tokenId } = require('./tokenConfigs.json');

const txPerBlock = 32;
const expectedGasCostPerTx = 10000 * txPerBlock;
const environment = environments[network];
const nf3Users = [
new Nf3(web3WsUrl, signingKeys.user1, environment),
new Nf3(web3WsUrl, signingKeys.user2, environment),
];
const nf3Proposer1 = new Nf3(web3WsUrl, signingKeys.proposer1, environment);
const nf3Users = [new Nf3(signingKeys.user1, environment), new Nf3(signingKeys.user2, environment)];
const nf3Proposer1 = new Nf3(signingKeys.proposer1, environment);

const web3Client = new Web3Client();

Expand Down
7 changes: 3 additions & 4 deletions test/e2e/protocol/challenger.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-await-in-loop */
import chai from 'chai';
import config from 'config';
import chaiHttp from 'chai-http';
import chaiAsPromised from 'chai-as-promised';
import { createRequire } from 'module';
Expand All @@ -10,15 +11,13 @@ const require = createRequire(import.meta.url);
const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);
const { web3WsUrl, network } = process.env;

// we need require here to import jsons
const environments = require('../environments.json');
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;
const signingKeys = require('../signingKeys.json');
const mnemonics = require('../mnemonics.json');

const environment = environments[network] || environments.localhost;
const nf3Challenger = new Nf3(web3WsUrl, signingKeys.challenger, environment);
const nf3Challenger = new Nf3(signingKeys.challenger, environment);

describe('Basic Challenger tests', () => {
before(async () => {
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/protocol/health-and-contracts.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-await-in-loop */
import chai from 'chai';
import config from 'config';
import chaiHttp from 'chai-http';
import chaiAsPromised from 'chai-as-promised';
import { createRequire } from 'module';
Expand All @@ -10,15 +11,13 @@ const require = createRequire(import.meta.url);
const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);
const { web3WsUrl, network } = process.env;

// we need require here to import jsons
const environments = require('../environments.json');
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;
const mnemonics = require('../mnemonics.json');
const signingKeys = require('../signingKeys.json');

const environment = environments[network];
const nf3User1 = new Nf3(web3WsUrl, signingKeys.user1, environment);
const nf3User1 = new Nf3(signingKeys.user1, environment);

before(async () => {
await nf3User1.init(mnemonics.user1);
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/protocol/index.test.mjs

This file was deleted.

12 changes: 6 additions & 6 deletions test/e2e/protocol/proposer.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import chai from 'chai';
import chaiHttp from 'chai-http';
import chaiAsPromised from 'chai-as-promised';
import config from 'config';
import { createRequire } from 'module';
import Nf3 from '../../../cli/lib/nf3.mjs';
import { Web3Client, expectTransaction } from '../../utils.mjs';
Expand All @@ -11,19 +12,18 @@ const require = createRequire(import.meta.url);
const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);
const { web3WsUrl, network } = process.env;

// we need require here to import jsons
const environments = require('../environments.json');
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;

const mnemonics = require('../mnemonics.json');
const signingKeys = require('../signingKeys.json');
const { bond, gasCosts, txPerBlock } = require('../configs.json');

const environment = environments[network] || environments.localhost;
const testProposers = [
new Nf3(web3WsUrl, signingKeys.proposer1, environment),
new Nf3(web3WsUrl, signingKeys.proposer2, environment),
new Nf3(web3WsUrl, signingKeys.proposer3, environment),
new Nf3(signingKeys.proposer1, environment),
new Nf3(signingKeys.proposer2, environment),
new Nf3(signingKeys.proposer3, environment),
];

const web3Client = new Web3Client();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tokens/erc1155.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);

const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT];
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;

// we need require here to import jsons
const mnemonics = require('../mnemonics.json');
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/tokens/erc20.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);

const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT];
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;

// we need require here to import jsons
const mnemonics = require('../mnemonics.json');
Expand All @@ -24,7 +24,7 @@ const { fee, transferValue, txPerBlock } = require('../configs.json');
const { tokenType, tokenId } = require('../tokenConfigs.json');

const nf3Users = [new Nf3(signingKeys.user1, environment), new Nf3(signingKeys.user2, environment)];
const nf3Proposer1 = new Nf3(signingKeys.proposer1, environment);
const nf3Proposer = new Nf3(signingKeys.proposer1, environment);

const web3Client = new Web3Client();

Expand Down Expand Up @@ -82,12 +82,12 @@ const emptyL2 = async nf3Instance => {

describe('ERC20 tests', () => {
before(async () => {
await nf3Proposer1.init(mnemonics.proposer);
await nf3Proposer1.registerProposer();
await nf3Proposer1.addPeer(environment.optimistApiUrl);
await nf3Proposer.init(mnemonics.proposer);
await nf3Proposer.registerProposer();
await nf3Proposer.addPeer(environment.optimistApiUrl);

// Proposer listening for incoming events
const newGasBlockEmitter = await nf3Proposer1.startProposer();
const newGasBlockEmitter = await nf3Proposer.startProposer();
newGasBlockEmitter.on('gascost', async gasUsed => {
if (process.env.VERBOSE)
console.log(
Expand Down Expand Up @@ -432,8 +432,8 @@ describe('ERC20 tests', () => {
});

after(async () => {
await nf3Proposer1.deregisterProposer();
await nf3Proposer1.close();
await nf3Proposer.deregisterProposer();
await nf3Proposer.close();
await nf3Users[0].close();
await nf3Users[1].close();
await web3Client.closeWeb3();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tokens/erc721.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const require = createRequire(import.meta.url);
const { expect } = chai;
chai.use(chaiHttp);
chai.use(chaiAsPromised);
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT];
const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;

// we need require here to import jsons
const mnemonics = require('../mnemonics.json');
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/tokens/index.test.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion test/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import rand from '../common-files/utils/crypto/crypto-random.mjs';

const { expect } = chai;
const { WEB3_PROVIDER_OPTIONS } = config;
const ENVIRONMENT = config.ENVIRONMENTS[process.env.ENVIRONMENT];
const ENVIRONMENT = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost;

const USE_INFURA = config.USE_INFURA === 'true';
const USE_ROPSTEN_NODE = config.USE_ROPSTEN_NODE === 'true';
Expand Down

0 comments on commit 6ca1b30

Please sign in to comment.