Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Deploy indra-4.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Sethuram committed Feb 6, 2020
2 parents 480375e + 5e19ab1 commit 1b7f5db
Show file tree
Hide file tree
Showing 111 changed files with 3,581 additions and 1,914 deletions.
9 changes: 4 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module.exports = {
rules: {
"@typescript-eslint/no-unused-expressions": "off",
"comma-dangle": ["error", "only-multiline"],
indent: ["error", 2],
"comma-dangle": ["error", "always-multiline"],
"max-len": ["warn", { code: 120, ignoreTemplateLiterals: true }],
"no-async-promise-executor": "off",
"no-undef": ["error"],
"no-unused-vars": ["error"],
"no-var": ["error"],
"object-curly-spacing": ["error", "always"],
quotes: ["error", "double", { allowTemplateLiterals: true }],
semi: ["error", "always"],
"quotes": ["error", "double", { allowTemplateLiterals: true }],
"semi": ["error", "always"],
"spaced-comment": "off",
"no-prototype-builtins": "off",
"sort-keys": ["error"],
},
settings: {
react: {
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/cd-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
- run: make start-test-release
- run: sleep 15 && make dls
- run: TEST_MODE=release make test-integration
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-backwards-compatibility:
runs-on: ubuntu-latest
Expand All @@ -104,6 +107,9 @@ jobs:
- run: make start-test-release
- run: sleep 15 && make dls
- run: make test-backwards-compatibility
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-daicard:
runs-on: ubuntu-16.04
Expand All @@ -113,6 +119,9 @@ jobs:
- run: make pull-release
- run: make start-test-release
- run: make test-daicard
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

deploy-rinkeby:
env:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/cd-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ jobs:
- run: make start-test-staging
- run: sleep 15 && make dls
- run: TEST_MODE=staging make test-integration
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-backwards-compatibility:
runs-on: ubuntu-latest
Expand All @@ -97,6 +100,9 @@ jobs:
- run: make start-test-staging
- run: sleep 15 && make dls
- run: make test-backwards-compatibility
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-daicard:
runs-on: ubuntu-16.04
Expand All @@ -106,6 +112,9 @@ jobs:
- run: make pull-commit
- run: make start-test-staging
- run: make test-daicard
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

deploy-staging:
env:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/cd-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
- run: make start-test-staging
- run: sleep 15 && make dls
- run: TEST_MODE=staging make test-integration
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-backwards-compatibility:
runs-on: ubuntu-latest
Expand All @@ -85,6 +88,9 @@ jobs:
- run: make start-test-staging
- run: sleep 15 && make dls
- run: make test-backwards-compatibility
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node

test-daicard:
runs-on: ubuntu-16.04
Expand All @@ -94,3 +100,6 @@ jobs:
- run: make pull-commit
- run: make start-test-staging
- run: make test-daicard
- name: Print node logs
if: failure()
run: docker service logs --tail 200 indra_node
6 changes: 4 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"printWidth": 100,
"trailingComma": "all"
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"printWidth": 120
}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ release=$(shell cat package.json | grep '"version"' | awk -F '"' '{print $$4}')
solc_version=$(shell cat package.json | grep '"solc"' | awk -F '"' '{print $$4}')

# version that will be tested against for backwards compatibility checks
backwards_compatible_version=$(shell echo $(release) | cut -d '.' -f 1).0.1
backwards_compatible_version=$(shell echo $(release) | cut -d '.' -f 1).0.7

# Pool of images to pull cached layers from during docker build steps
cache_from=$(shell if [[ -n "${GITHUB_WORKFLOW}" ]]; then echo "--cache-from=$(project)_database:$(commit),$(project)_database,$(project)_ethprovider:$(commit),$(project)_ethprovider,$(project)_node:$(commit),$(project)_node,$(project)_proxy:$(commit),$(project)_proxy,$(project)_relay:$(commit),$(project)_relay,$(project)_bot:$(commit),$(project)_bot,$(project)_builder"; else echo ""; fi)
Expand Down Expand Up @@ -59,9 +59,9 @@ $(shell mkdir -p .makeflags $(node)/dist)

default: dev
all: dev staging release
dev: database node client payment-bot-js indra-proxy test-runner-js ws-tcp-relay
staging: daicard-proxy database ethprovider indra-proxy-prod node-staging payment-bot-staging test-runner-staging ws-tcp-relay
release: daicard-proxy database ethprovider indra-proxy-prod node-release payment-bot-release test-runner-release ws-tcp-relay
dev: database node client indra-proxy test-runner-js ws-tcp-relay
staging: daicard-proxy database ethprovider indra-proxy-prod node-staging test-runner-staging ws-tcp-relay
release: daicard-proxy database ethprovider indra-proxy-prod node-release test-runner-release ws-tcp-relay

start: start-daicard

Expand Down
18 changes: 17 additions & 1 deletion cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

////////////////////////////////////////
// To exit tests after first failure, the following code was copy/pasted from:
// https://github.com/cypress-io/cypress/issues/518#issuecomment-552382781

let shouldSkip = false;
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// on('task', { failed: require('cypress-failed-log/src/failed')(), })
}
on("task", {
resetShouldSkipFlag() {
shouldSkip = false;
return null;
},
shouldSkip(value) {
if (value != null) shouldSkip = value;
return shouldSkip;
},
});
};
////////////////////////////////////////
73 changes: 50 additions & 23 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global afterEach, before, beforeEach, chai, Cypress, cy*/
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
Expand All @@ -12,38 +13,64 @@
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
import './commands'
chai.use(require('chai-bn')(require('bn.js')))
import "./commands";
chai.use(require("chai-bn")(require("bn.js")));

// store logs
let logs = '';
let logs = "";

Cypress.on('window:before:load', (window) => {
// Overwrite all of the console methods.
['log', 'info', 'error', 'warn', 'debug'].forEach((consoleProperty) => {
const oldConsole = window.console[consoleProperty]
window.console[consoleProperty] = function (...args) {
oldConsole(...args) // Still console log everything
logs += args.join(' ') + '\n'; // Also save copy of all logs to dump if tests fail
};
});
Cypress.on("window:before:load", window => {
// Overwrite all of the console methods.
["log", "info", "error", "warn", "debug"].forEach(consoleProperty => {
const oldConsole = window.console[consoleProperty];
window.console[consoleProperty] = function(...args) {
oldConsole(...args); // Still console log everything
logs += args.join(" ") + "\n"; // Also save copy of all logs to dump if tests fail
};
});
});

// Cypress doesn't have a each test event
// so I'm using mochas events to clear log state after every test.
Cypress.mocha.getRunner().on('test', () => {
// Every test reset your logs to be empty
// This will make sure only logs from that test suite will be logged if a error happens
logs = '';
Cypress.mocha.getRunner().on("test", () => {
// Every test reset your logs to be empty
// This will make sure only logs from that test suite will be logged if a error happens
logs = "";
});

// On a cypress fail. I add the console logs, from the start of test or after the last test fail to the
// current fail, to the end of the error.stack property.
Cypress.on('fail', (error) => {
error.stack += '\nConsole Logs:\n========================';
error.stack += logs;
// clear logs after fail so we dont see duplicate logs
logs = '';
// still need to throw the error so tests wont be marked as a pass
throw error;
Cypress.on("fail", error => {
error.stack += "\nConsole Logs:\n========================\n\n";
error.stack += logs;
// clear logs after fail so we dont see duplicate logs
logs = "";
// still need to throw the error so tests wont be marked as a pass
throw error;
});

////////////////////////////////////////
// To exit tests after first failure, the following code was copy/pasted from:
// https://github.com/cypress-io/cypress/issues/518#issuecomment-552382781

function abortEarly() {
if (this.currentTest.state === "failed") {
return cy.task("shouldSkip", true);
}
cy.task("shouldSkip").then(value => {
if (value) this.skip();
});
}

beforeEach(abortEarly);
afterEach(abortEarly);
before(() => {
if (Cypress.browser.isHeaded) {
// Reset the shouldSkip flag at the start of a run, so that it
// doesn't carry over into subsequent runs.
// Do this only for headed runs because in headless runs,
// the `before` hook is executed for each spec file.
cy.task("resetShouldSkipFlag");
}
});
////////////////////////////////////////
4 changes: 0 additions & 4 deletions modules/cf-core/.prettierrc

This file was deleted.

4 changes: 2 additions & 2 deletions modules/cf-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@connext/cf-core",
"version": "4.0.8",
"version": "4.0.10",
"main": "dist/src/index.js",
"iife": "dist/src/index.iife.js",
"types": "dist/src/index.d.ts",
Expand All @@ -20,7 +20,7 @@
},
"dependencies": {
"@connext/contracts": "1.0.4",
"@connext/types": "4.0.8",
"@connext/types": "4.0.10",
"ethers": "4.0.41",
"eventemitter3": "4.0.0",
"loglevel": "1.6.6",
Expand Down
54 changes: 26 additions & 28 deletions modules/cf-core/src/methods/app-instance/uninstall/controller.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
import { jsonRpcMethod } from "rpc-server";

import { RequestHandler } from "../../../request-handler";
import { CFCoreTypes, ProtocolTypes } from "../../../types";
import { getFirstElementInListNotEqualTo } from "../../../utils";
import { NodeController } from "../../controller";
import { uninstallAppInstanceFromChannel } from "./operation";

import {
APP_ALREADY_UNINSTALLED,
CANNOT_UNINSTALL_FREE_BALANCE,
NO_APP_INSTANCE_ID_TO_UNINSTALL,
USE_RESCIND_DEPOSIT_RIGHTS,
} from "../../errors";

import { uninstallAppInstanceFromChannel } from "./operation";
import { RequestHandler } from "../../../request-handler";
import { CFCoreTypes, ProtocolTypes } from "../../../types";
import { getFirstElementInListNotEqualTo } from "../../../utils";
import { NodeController } from "../../controller";

export default class UninstallController extends NodeController {
@jsonRpcMethod(ProtocolTypes.chan_uninstall)
public executeMethod = super.executeMethod;

protected async getRequiredLockNames(
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallVirtualParams
params: CFCoreTypes.UninstallVirtualParams,
): Promise<string[]> {
const { store } = requestHandler;
const { appInstanceId } = params;

const sc = await store.getChannelFromAppInstanceID(appInstanceId);

if (sc.freeBalance.identityHash === appInstanceId) {
throw Error(CANNOT_UNINSTALL_FREE_BALANCE(sc.multisigAddress));
}

return [sc.multisigAddress, appInstanceId];
}

protected async beforeExecution(
// @ts-ignore
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallParams
) {
protected async beforeExecution(requestHandler: RequestHandler, params: CFCoreTypes.UninstallParams) {
const { store, networkContext } = requestHandler;
const { appInstanceId } = params;

if (!appInstanceId) {
throw Error(NO_APP_INSTANCE_ID_TO_UNINSTALL);
}

const sc = await store.getChannelFromAppInstanceID(appInstanceId);

if (sc.freeBalance.identityHash === appInstanceId) {
throw Error(CANNOT_UNINSTALL_FREE_BALANCE(sc.multisigAddress));
}

// check if its the balance refund app
const app = await store.getAppInstance(appInstanceId);
if (app.appInterface.addr === networkContext.CoinBalanceRefundApp) {
throw Error(USE_RESCIND_DEPOSIT_RIGHTS);
}
}

protected async executeMethodImplementation(
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallParams
params: CFCoreTypes.UninstallParams,
): Promise<CFCoreTypes.UninstallResult> {
const { store, protocolRunner, publicIdentifier } = requestHandler;
const { appInstanceId } = params;
Expand All @@ -61,18 +68,9 @@ export default class UninstallController extends NodeController {
throw Error(APP_ALREADY_UNINSTALLED(appInstanceId));
}

const to = getFirstElementInListNotEqualTo(
publicIdentifier,
stateChannel.userNeuteredExtendedKeys
);

await uninstallAppInstanceFromChannel(
store,
protocolRunner,
publicIdentifier,
to,
appInstanceId
);
const to = getFirstElementInListNotEqualTo(publicIdentifier, stateChannel.userNeuteredExtendedKeys);

await uninstallAppInstanceFromChannel(store, protocolRunner, publicIdentifier, to, appInstanceId);

return { appInstanceId };
}
Expand Down
Loading

0 comments on commit 1b7f5db

Please sign in to comment.