Skip to content

Commit

Permalink
Block height update (#1927)
Browse files Browse the repository at this point in the history
* fix block height reference

Signed-off-by: Karoly Albert Szabo <[email protected]>

* fix changelog

Signed-off-by: Karoly Albert Szabo <[email protected]>
  • Loading branch information
sabau authored and jbibla committed Feb 5, 2019
1 parent ebb897c commit 2d52190
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1338](https://github.com/cosmos/voyager/issues/1338) Add Ledger Nano S support for signing transactions @fedekunze
- [\#1869](https://github.com/cosmos/voyager/issues/1869) Added PageNetwork @jbibla
- [\#1894](https://github.com/cosmos/voyager/issues/1894) Added favicons for all the browsers and devices @jbibla
- [\#1865](https://github.com/cosmos/voyager/issues/1865) Added Vuex blocks module @sabau

### Changed

Expand Down
3 changes: 3 additions & 0 deletions app/src/renderer/vuex/modules/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export default ({ node }) => {
node.rpc.subscribe({ query: `tm.event = 'NewBlock'` }, event => {
if (state.subscription === false) commit(`setSubscription`, true)
commit(`addBlock`, event.block)
event.block &&
event.block.header &&
commit(`setBlockHeight`, event.block.header.height)
})

return true
Expand Down
10 changes: 6 additions & 4 deletions test/unit/specs/store/blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ describe(`Module: Blocks`, () => {
}
}),
subscribe: (query, cb) => {
cb({ block: `subscribe here` })
cb({ block: { header: { height: 1 } } })
expect(commit).toBeCalledWith(`setSubscription`, true)
module.state.subscription = true
cb({ block: `already subscribed` })
cb({ block: { header: { height: 2 } } })
}
}
}
Expand All @@ -167,8 +167,10 @@ describe(`Module: Blocks`, () => {
[`setSyncing`, false],
[`setBlocks`, []],
[`setSubscription`, true],
[`addBlock`, `subscribe here`],
[`addBlock`, `already subscribed`]
[`addBlock`, { header: { height: 1 } }],
[`setBlockHeight`, 1],
[`addBlock`, { header: { height: 2 } }],
[`setBlockHeight`, 2]
])
})

Expand Down

0 comments on commit 2d52190

Please sign in to comment.