forked from bigearth/rest.bitbox.earth
-
Notifications
You must be signed in to change notification settings - Fork 26
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 #100 from Bitcoin-com/stage
v1.10.4
- Loading branch information
Showing
5 changed files
with
116 additions
and
9 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,75 @@ | ||
"use strict" | ||
|
||
//const chai = require("chai"); | ||
const assert = require("assert") | ||
const httpMocks = require("node-mocks-http") | ||
const panda = require("./helpers/panda"); | ||
process.env.RPC_BASEURL="http://localhost:48332/"; | ||
const blockchainRoute = require("../../dist/routes/v2/blockchain") | ||
|
||
describe("#BlockchainRouter", () => { | ||
// local node will be started in regtest mode on the port 48332 | ||
before(panda.runLocalNode); | ||
after(() => { | ||
// otherwise the panda will run forever | ||
process.exit(); | ||
}); | ||
|
||
describe("#root", () => { | ||
it("should return 'blockchain' for GET /", () => { | ||
const mockRequest = httpMocks.createRequest({ | ||
method: "GET", | ||
url: "/" | ||
}) | ||
|
||
const mockResponse = httpMocks.createResponse() | ||
|
||
blockchainRoute(mockRequest, mockResponse) | ||
|
||
const actualResponseBody = mockResponse._getData() | ||
const expectedResponseBody = { | ||
status: "blockchain" | ||
} | ||
|
||
assert.deepEqual(JSON.parse(actualResponseBody), expectedResponseBody) | ||
}) | ||
}) | ||
|
||
describe("#BlockchainGetBlockchainInfo", () => { | ||
it("should GET /getBlockchainInfo ", (done) => { | ||
const mockRequest = httpMocks.createRequest({ | ||
method: "GET", | ||
url: "/getBlockchainInfo" | ||
}) | ||
|
||
const mockResponse = httpMocks.createResponse({ | ||
eventEmitter: require("events").EventEmitter | ||
}) | ||
|
||
blockchainRoute(mockRequest, mockResponse) | ||
|
||
mockResponse.on("end", () => { | ||
const actualResponseBody = Object.keys( | ||
JSON.parse(mockResponse._getData()) | ||
) | ||
|
||
assert.deepEqual(actualResponseBody, [ | ||
"chain", | ||
"blocks", | ||
"headers", | ||
"bestblockhash", | ||
"difficulty", | ||
"mediantime", | ||
"verificationprogress", | ||
"chainwork", | ||
"pruned", | ||
"softforks", | ||
"bip9_softforks", | ||
"pruneheight" | ||
]); | ||
|
||
return done(); | ||
}); | ||
}) | ||
}) | ||
}) |
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,26 @@ | ||
"use strict" | ||
|
||
/** | ||
* Read more about panda here: https://panda-suite.github.io/ | ||
*/ | ||
const panda = require("pandacash-cli") | ||
|
||
const runLocalNode = done => { | ||
const server = panda.server({ | ||
// always the same mnemonic | ||
// mnemonic: "cigar magnet ocean purchase travel damp snack alone theme budget wagon wrong", | ||
seedAccounts: true, | ||
enableLogs: false, | ||
debug: false | ||
}) | ||
|
||
server.listen(48332, (err, pandaCashCore) => { | ||
if (err) return console.error(err) | ||
|
||
done() | ||
}) | ||
} | ||
|
||
module.exports = { | ||
runLocalNode | ||
} |