Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabo/1509 crash tests on warnings #1542

Merged
merged 16 commits into from
Nov 14, 2018
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1436](https://github.com/cosmos/voyager/issues/1436) governance endpoints and vuex module @fedekunze
* [\#1482](https://github.com/cosmos/voyager/issues/1482) Added ESLint errors: no-var. @sgobotta
* [\#1449](https://github.com/cosmos/voyager/issues/1449) shortNumber to num scripts for more readable numbers. @jbibla
* [\#1509](https://github.com/cosmos/voyager/issues/1509) fail tests on console.error and console.warn and fix related bugs. Plus added a way to simply opt out of failing tests on console usage. @faboweb
* [\#1464](https://github.com/cosmos/voyager/issues/1464) Added governance transactions to tx history page @fedekunze
* [\1401](https://github.com/cosmos/voyager/issues/1401) Display governance proposals index. @fedekunze
* [\#1472](https://github.com/cosmos/voyager/issues/1472) Added mock functionality for redelegation @fedekunze + @faboweb
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -226,19 +226,20 @@ Import the account with the 12 word seed phrase you wrote down earlier.

A list of all environment variables and their purpose:

| Variable | Values | default | Purpose |
| ----------------------- | ---------------------------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- |
| NODE_ENV | 'production', 'development' | | |
| LOGGING | 'true', 'false' | 'true' | Disable logging |
| COSMOS_NETWORK | {path to network configuration folder} | '../networks/gaia-7001' | Network to connect to |
| COSMOS_HOME | {path to config persistence folder} | '$HOME/.cosmos-voyager[-dev]' | |
| LCD_URL | {URL of a Cosmos light client interface} | see 'app/config.toml' | Cosmos Light Client interface to connect to |
| RPC_URL | {URL of a Tendermint rpc interface} | see 'app/config.toml' | Tendermint node to connect to |
| COSMOS_DEVTOOLS | 'true', 'false' | 'false' | Open the debug panel in the electron view |
| ELECTRON_ENABLE_LOGGING | 'true', 'false' | 'false' | Redirect the browser view console output to the console |
| PREVIEW | 'true', 'false' | 'true' if NODE_ENV 'development' | Show/Hide features that are in development |
| COSMOS_E2E_KEEP_OPEN | 'true', 'false' | 'false' | Keep the Window open in local E2E test to see the state in which the application broke. |
| CI | 'true', 'false' | 'false' | Adds better structured output, makes a screenshot and adds logs to files (used on CircleCI). |
| Variable | Values | default | Purpose |
| ----------------------- | ---------------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| NODE_ENV | 'production', 'development' | | |
| LOGGING | 'true', 'false' | 'true' | Disable logging |
| COSMOS_NETWORK | {path to network configuration folder} | '../networks/gaia-7001' | Network to connect to |
| COSMOS_HOME | {path to config persistence folder} | '$HOME/.cosmos-voyager[-dev]' | |
| LCD_URL | {URL of a Cosmos light client interface} | see 'app/config.toml' | Cosmos Light Client interface to connect to |
| RPC_URL | {URL of a Tendermint rpc interface} | see 'app/config.toml' | Tendermint node to connect to |
| COSMOS_DEVTOOLS | 'true', 'false' | 'false' | Open the debug panel in the electron view |
| ELECTRON_ENABLE_LOGGING | 'true', 'false' | 'false' | Redirect the browser view console output to the console |
| PREVIEW | 'true', 'false' | 'true' if NODE_ENV 'development' | Show/Hide features that are in development |
| COSMOS_E2E_KEEP_OPEN | 'true', 'false' | 'false' | Keep the Window open in local E2E test to see the state in which the application broke. |
| CI | 'true', 'false' | 'false' | Adds better structured output, makes a screenshot and adds logs to files (used on CircleCI). |
| ALLOW_CONSOLE | 'true', 'false' | 'false' | Unit tests fail if they use console.error or console.warn. To see the initial use/occurences of those callings, you can escape this behavior using this flag. |

## FAQ

3 changes: 1 addition & 2 deletions app/src/renderer/components/staking/LiValidator.vue
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ tr.li-validator
img.li-validator__avatar.no-img(v-else src="~assets/images/validator-icon.svg" width="48" height="48")
.li-validator__name-container
span.validator-profile__status(v-bind:class="statusColor" v-tooltip.top="status")
router-link.li-validator__moniker(:to="{ name: 'validator', params: { validator: validator.id }}", :class='styles') {{ validator.description.moniker }}
router-link.li-validator__moniker(:to="{ name: 'validator', params: { validator: validator.operator_address }}", :class='styles') {{ validator.description.moniker }}
short-bech32.li-validator__address(:address="validator.operator_address")
td.li-validator__delegated-steak {{ yourVotes.isLessThan(0.01) && yourVotes.isGreaterThan(0) ? '< ' + num.shortNumber(0.01) : num.shortNumber(yourVotes) }}
td.li-validator__rewards n/a
@@ -142,5 +142,4 @@ export default {
.li-validator__address
.address
font-size sm
</style>
1 change: 0 additions & 1 deletion app/src/renderer/components/staking/TableValidators.vue
Original file line number Diff line number Diff line change
@@ -227,5 +227,4 @@ table tr td:nth-child(3):after
top 1.5rem
right 2rem
background var(--bc-dim)
</style>
19 changes: 19 additions & 0 deletions test/unit/helpers/console_error_throw.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
"use strict"

/* eslint-env jasmine */

if (!process.env.LISTENING_TO_UNHANDLED_REJECTION) {
process.on(`unhandledRejection`, reason => {
throw reason
})
// Avoid memory leak by adding too many listeners
process.env.LISTENING_TO_UNHANDLED_REJECTION = true
}

if (!process.env.ALLOW_CONSOLE) {
const originalError = global.console.error
const originalWarn = global.console.warn
global.console.error = (...args) => {
originalError(...args)
fail(
`console.error in tests are forbidden (run with ALLOW_CONSOLE=true to show the console.error without failing)\n${args}`
)
}
global.console.warn = (...args) => {
originalWarn(...args)
fail(
`console.warn in tests are forbidden (run with ALLOW_CONSOLE=true to show the console.warn without failing)\n${args}`
)
}
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ exports[`LiValidator has the expected html structure 1`] = `
/>
<a
class="li-validator__moniker"
href="#/staking/validators/abc"
href="#/staking/validators/cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctplpn3au"
>
herr_schmidt_revoked
</a>
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ exports[`TableValidators has the expected html structure 1`] = `
<td class=\\"li-validator__moniker-container\\">
<img src=\\"~assets/images/validator-icon.svg\\" width=\\"48\\" height=\\"48\\" class=\\"li-validator__avatar no-img\\">
<div class=\\"li-validator__name-container\\">
<span class=\\"validator-profile__status yellow\\"></span><a href=\\"#/\\" class=\\"li-validator__moniker router-link-exact-active router-link-active li-validator-validator \\">good_greg</a>
<span class=\\"validator-profile__status yellow\\"></span><a href=\\"#/staking/validators/cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctplpn3au\\" class=\\"li-validator__moniker li-validator-validator \\">good_greg</a>
<div class=\\"short-bech32 li-validator__address\\">
<div id=\\"address\\" class=\\"address\\">
cosmosvaladdr…n3au
@@ -67,7 +67,7 @@ exports[`TableValidators has the expected html structure 1`] = `
<td class=\\"li-validator__moniker-container\\">
<img src=\\"~assets/images/validator-icon.svg\\" width=\\"48\\" height=\\"48\\" class=\\"li-validator__avatar no-img\\">
<div class=\\"li-validator__name-container\\">
<span class=\\"validator-profile__status red\\"></span><a href=\\"#/\\" class=\\"li-validator__moniker router-link-exact-active router-link-active li-validator-validator \\">herr_schmidt_revoked</a>
<span class=\\"validator-profile__status red\\"></span><a href=\\"#/staking/validators/cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctgurrg7n\\" class=\\"li-validator__moniker li-validator-validator \\">herr_schmidt_revoked</a>
<div class=\\"short-bech32 li-validator__address\\">
<div id=\\"address\\" class=\\"address\\">
cosmosvaladdr…rg7n
@@ -101,7 +101,7 @@ exports[`TableValidators has the expected html structure 1`] = `
<td class=\\"li-validator__moniker-container\\">
<img src=\\"~assets/images/validator-icon.svg\\" width=\\"48\\" height=\\"48\\" class=\\"li-validator__avatar no-img\\">
<div class=\\"li-validator__name-container\\">
<span class=\\"validator-profile__status yellow\\"></span><a href=\\"#/\\" class=\\"li-validator__moniker router-link-exact-active router-link-active li-validator-validator \\">mr_mounty</a>
<span class=\\"validator-profile__status yellow\\"></span><a href=\\"#/staking/validators/cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw\\" class=\\"li-validator__moniker li-validator-validator \\">mr_mounty</a>
<div class=\\"short-bech32 li-validator__address\\">
<div id=\\"address\\" class=\\"address\\">
cosmosvaladdr…8yqw
@@ -228,8 +228,8 @@ exports[`TableValidators should filter the delegates 1`] = `
class="validator-profile__status yellow"
/>
<a
class="li-validator__moniker router-link-exact-active router-link-active li-validator-validator "
href="#/"
class="li-validator__moniker li-validator-validator "
href="#/staking/validators/cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw"
>
mr_mounty
</a>
3 changes: 3 additions & 0 deletions test/unit/specs/lcdClient.spec.js
Original file line number Diff line number Diff line change
@@ -207,6 +207,7 @@ describe(`LCD Client`, () => {

describe(`keys`, () => {
it(`add`, async () => {
jest.spyOn(console, `error`).mockImplementation(() => {})
expect(await client.keys.get(`foo`)).toEqual(undefined)

await client.keys.add({
@@ -222,6 +223,8 @@ describe(`LCD Client`, () => {
seed: `seed some thin`,
type: `local`
})

console.error.mockReset()
})

it(`delete`, async () => {
3 changes: 3 additions & 0 deletions test/unit/specs/store/store.spec.js
Original file line number Diff line number Diff line change
@@ -154,6 +154,8 @@ describe(`Store`, () => {
}
}))
let Raven = require(`raven-js`)
// the error will be logged, which is confusing in the test output
jest.spyOn(console, `error`).mockImplementation(() => {})

let spy = jest.spyOn(Raven, `captureException`)
let opts = { node: { keys: { get: () => ({}) } } }
@@ -168,5 +170,6 @@ describe(`Store`, () => {
jest.runAllTimers()

expect(spy).toHaveBeenCalled()
console.error.mockReset()
})
})