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/1517 fix self bond querying #1521

Merged
merged 6 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1480](https://github.com/cosmos/voyager/issues/1480) Fixed false detection of node crash in e2e test start. @faboweb
* [\#1451](https://github.com/cosmos/voyager/issues/1451) Provide better sourcemaps to make debugging easier. @faboweb
* [\#1409](https://github.com/cosmos/voyager/issues/1409) Fixed disabled unbond and redelegation button when delegation amount was less than 1 @fedekunze
* [\#1517](https://github.com/cosmos/voyager/issues/1517) Fixed wrong account format used for querying selfBond @faboweb

## [0.10.7] - 2018-10-10

Expand Down
8 changes: 6 additions & 2 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ export default {
}
},
watch: {
validator(validator) {
this.$store.dispatch(`getSelfBond`, validator)
validator: {
immediate: true,
handler(validator) {
if (!validator) return
this.$store.dispatch(`getSelfBond`, validator)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/renderer/vuex/modules/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BN from "bignumber.js"
import { ratToBigNumber } from "scripts/common"
import num from "scripts/num"
import { isEmpty } from "lodash"
import b32 from "scripts/b32"
export default ({ node }) => {
const emptyState = {
delegates: [],
Expand Down Expand Up @@ -96,8 +97,10 @@ export default ({ node }) => {
async getSelfBond({ commit }, validator) {
if (validator.selfBond) return validator.selfBond
else {
let hexAddr = b32.decode(validator.operator_address)
let operatorCosmosAddr = b32.encode(hexAddr, `cosmos`)
let delegation = await node.queryDelegation(
validator.operator_address,
operatorCosmosAddr,
validator.operator_address
)
let ratio = new BN(delegation.shares).div(
Expand Down
66 changes: 48 additions & 18 deletions test/unit/specs/components/staking/PageValidator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ describe(`onDelegation`, () => {
{ atoms: 10, validator: validator }
]

$store.dispatch.mockClear()

await submitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
Expand All @@ -495,9 +497,7 @@ describe(`onDelegation`, () => {
it(`error`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`message`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -520,6 +520,11 @@ describe(`onDelegation`, () => {
{ atoms: 10, validator: validator }
]

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`message`)
})

await submitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
Expand All @@ -543,9 +548,7 @@ describe(`onDelegation`, () => {
it(`error with data`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -568,6 +571,11 @@ describe(`onDelegation`, () => {
{ atoms: 10, validator: validator }
]

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
})

await submitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
Expand Down Expand Up @@ -619,6 +627,8 @@ describe(`onDelegation`, () => {
}
})

$store.dispatch.mockClear()

await submitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
Expand Down Expand Up @@ -728,6 +738,8 @@ describe(`onDelegation`, () => {
{ atoms: 5, validatorSrc: validator, validatorDst: validatorTo }
]

$store.dispatch.mockClear()

await submitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
Expand All @@ -753,9 +765,7 @@ describe(`onDelegation`, () => {
it(`error`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`message`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -778,6 +788,11 @@ describe(`onDelegation`, () => {
{ atoms: 5, validatorSrc: validator, validatorDst: validatorTo }
]

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`message`)
})

await submitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
Expand All @@ -801,9 +816,7 @@ describe(`onDelegation`, () => {
it(`error with data`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -826,6 +839,11 @@ describe(`onDelegation`, () => {
{ atoms: 5, validatorSrc: validator, validatorDst: validatorTo }
]

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
})

await submitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
Expand Down Expand Up @@ -881,6 +899,8 @@ describe(`onDelegation`, () => {
}
})

$store.dispatch.mockClear()

await submitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
Expand Down Expand Up @@ -1012,6 +1032,8 @@ describe(`onUnstake`, () => {
}
})

$store.dispatch.mockClear()

await submitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
Expand All @@ -1035,9 +1057,7 @@ describe(`onUnstake`, () => {
it(`error`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`message`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -1050,6 +1070,11 @@ describe(`onUnstake`, () => {
}
})

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`message`)
})

await submitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
Expand All @@ -1073,9 +1098,7 @@ describe(`onUnstake`, () => {
it(`error with data`, async () => {
const $store = {
commit: jest.fn(),
dispatch: jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix"seven`)
}),
dispatch: jest.fn(),
getters: getterValues
}

Expand All @@ -1088,6 +1111,11 @@ describe(`onUnstake`, () => {
}
})

$store.dispatch.mockClear()
$store.dispatch = jest.fn(() => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix"seven`)
})

await submitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
Expand Down Expand Up @@ -1141,6 +1169,8 @@ describe(`onUnstake`, () => {
}
})

$store.dispatch.mockClear()

await submitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ exports[`PageValidator has the expected html structure 1`] = `
<dd
id="validator-profile__self-bond"
>
0 %
0.00 %
</dd>
</dl>
<dl
Expand Down