This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #858 from LiskHQ/830-nethash-from-api
Get Blockchain Nethash from API - Closes #830
- Loading branch information
Showing
6 changed files
with
118 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { requestToActivePeer } from './peers'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const getNethash = activePeer => (requestToActivePeer(activePeer, 'blocks/getNethash')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from 'chai'; | ||
import { mock } from 'sinon'; | ||
import * as peers from './peers'; | ||
import { getNethash } from './nethash'; | ||
|
||
|
||
describe('Utils: Nethash', () => { | ||
let peersMock; | ||
const activePeer = {}; | ||
|
||
beforeEach(() => { | ||
peersMock = mock(peers); | ||
}); | ||
|
||
afterEach(() => { | ||
peersMock.restore(); | ||
}); | ||
|
||
it('should return the result from requestToActivePeer call', () => { | ||
const mockedReturns = 'requestToActivePeer returns something'; | ||
|
||
peersMock.expects('requestToActivePeer') | ||
.withArgs(activePeer, 'blocks/getNethash') | ||
.returns(mockedReturns); | ||
|
||
const returnedPromise = getNethash(activePeer); | ||
expect(returnedPromise).to.equal(mockedReturns); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters