docs: update development guide
This commit is contained in:
parent
c8ba4eaa8f
commit
3fed348cf7
|
@ -44,7 +44,7 @@ There are several add-on services available to extend the functionality of Bitco
|
||||||
- [Services](docs/services.md)
|
- [Services](docs/services.md)
|
||||||
- [Bitcoind](docs/services/bitcoind.md) - Interface to Bitcoin Core
|
- [Bitcoind](docs/services/bitcoind.md) - Interface to Bitcoin Core
|
||||||
- [Web](docs/services/web.md) - Creates an express application over which services can expose their web/API content
|
- [Web](docs/services/web.md) - Creates an express application over which services can expose their web/API content
|
||||||
- [Testing & Development](docs/testing.md) - Developer guide for testing
|
- [Development Environment](docs/development.md) - Guide for setting up a development environment
|
||||||
- [Node](docs/node.md) - Details on the node constructor
|
- [Node](docs/node.md) - Details on the node constructor
|
||||||
- [Bus](docs/bus.md) - Overview of the event bus constructor
|
- [Bus](docs/bus.md) - Overview of the event bus constructor
|
||||||
- [Release Process](docs/release.md) - Information about verifying a release and the release process.
|
- [Release Process](docs/release.md) - Information about verifying a release and the release process.
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
# Setting up Development Environment
|
||||||
|
|
||||||
|
## Install Node.js
|
||||||
|
|
||||||
|
Install Node.js by your favorite method, or use Node Version Manager by following directions at https://github.com/creationix/nvm
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nvm install v4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Fork and Download Repositories
|
||||||
|
|
||||||
|
To develop bitcore-node:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~
|
||||||
|
git clone git@github.com:<yourusername>/bitcore-node.git
|
||||||
|
git clone git@github.com:<yourusername>/bitcore-lib.git
|
||||||
|
```
|
||||||
|
|
||||||
|
To develop bitcoin or to compile from source:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:<yourusername>/bitcoin.git
|
||||||
|
git fetch origin <branchname>:<branchname>
|
||||||
|
git checkout <branchname>
|
||||||
|
```
|
||||||
|
**Note**: See bitcoin documentation for building bitcoin on your platform.
|
||||||
|
|
||||||
|
|
||||||
|
## Install ZeroMQ Development Dependency
|
||||||
|
|
||||||
|
For Ubuntu:
|
||||||
|
```bash
|
||||||
|
sudo apt-get install libzmq-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
For Mac OS X:
|
||||||
|
```bash
|
||||||
|
brew install zeromq
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install and Symlink
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd bitcore-lib
|
||||||
|
npm install
|
||||||
|
cd ../bitcore-node
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
**Note**: If you get a message about not being able to download bitcoin distribution, you'll need to compile bitcoind from source, and setup your configuration to use that version.
|
||||||
|
|
||||||
|
|
||||||
|
We now will setup symlinks in `bitcore-node` *(repeat this for any other modules you're planning on developing)*:
|
||||||
|
```bash
|
||||||
|
cd node_modules
|
||||||
|
rm -rf bitcore-lib
|
||||||
|
ln -s ~/bitcore-lib
|
||||||
|
rm -rf bitcoind-rpc
|
||||||
|
ln -s ~/bitcoind-rpc
|
||||||
|
```
|
||||||
|
|
||||||
|
And if you're compiling or developing bitcoin:
|
||||||
|
```bash
|
||||||
|
cd ../bin
|
||||||
|
ln -sf ~/bitcoin/src/bitcoind
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run Tests
|
||||||
|
|
||||||
|
If you do not already have mocha installed:
|
||||||
|
```bash
|
||||||
|
npm install mocha -g
|
||||||
|
```
|
||||||
|
|
||||||
|
To run all test suites:
|
||||||
|
```bash
|
||||||
|
cd bitcore-node
|
||||||
|
npm run regtest
|
||||||
|
npm run test
|
||||||
|
```
|
||||||
|
|
||||||
|
To run a specific unit test in watch mode:
|
||||||
|
```bash
|
||||||
|
mocha -w -R spec test/services/bitcoind.unit.js
|
||||||
|
```
|
||||||
|
|
||||||
|
To run a specific regtest:
|
||||||
|
```bash
|
||||||
|
mocha -R spec regtest/bitcoind.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running a Development Node
|
||||||
|
|
||||||
|
To test running the node, you can setup a configuration that will specify development versions of all of the services:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~
|
||||||
|
mkdir devnode
|
||||||
|
cd devnode
|
||||||
|
mkdir node_modules
|
||||||
|
touch bitcore-node.json
|
||||||
|
touch package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `bitcore-node.json` with something similar to:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"network": "livenet",
|
||||||
|
"port": 3001,
|
||||||
|
"services": [
|
||||||
|
"bitcoind",
|
||||||
|
"web",
|
||||||
|
"insight-api",
|
||||||
|
"insight-ui"
|
||||||
|
],
|
||||||
|
"servicesConfig": {
|
||||||
|
"bitcoind": {
|
||||||
|
"spawn": {
|
||||||
|
"datadir": "/home/<youruser>/.bitcoin",
|
||||||
|
"exec": "/home/<youruser>/bitcoin/src/bitcoind"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Setup symlinks for all of the services and dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd node_modules
|
||||||
|
ln -s ~/bitcore-lib
|
||||||
|
ln -s ~/bitcore-node
|
||||||
|
ln -s ~/insight-api
|
||||||
|
ln -s ~/insight-ui
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure that the `<datadir>/bitcoin.conf` has the necessary settings, for example:
|
||||||
|
```
|
||||||
|
server=1
|
||||||
|
whitelist=127.0.0.1
|
||||||
|
txindex=1
|
||||||
|
addressindex=1
|
||||||
|
timestampindex=1
|
||||||
|
spentindex=1
|
||||||
|
zmqpubrawtx=tcp://127.0.0.1:28332
|
||||||
|
zmqpubhashblock=tcp://127.0.0.1:28332
|
||||||
|
rpcallowip=127.0.0.1
|
||||||
|
rpcuser=bitcoin
|
||||||
|
rpcpassword=local321
|
||||||
|
```
|
||||||
|
|
||||||
|
From within the `devnode` directory with the configuration file, start the node:
|
||||||
|
```bash
|
||||||
|
../bitcore-node/bin/bitcore-node start
|
||||||
|
```
|
|
@ -1,37 +0,0 @@
|
||||||
# Development & Testing
|
|
||||||
To run all of the JavaScript tests:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run test
|
|
||||||
```
|
|
||||||
|
|
||||||
If you do not already have mocha installed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install mocha -g
|
|
||||||
```
|
|
||||||
|
|
||||||
To run the regression tests:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mocha -R spec regtest/bitcoind.js
|
|
||||||
```
|
|
||||||
|
|
||||||
To be able to debug bitcoind you'll need to have `gdb` and `node` compiled for debugging with gdb using `--gdb` (sometimes called node_g), and you can then run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ gdb --args node examples/node.js
|
|
||||||
```
|
|
||||||
|
|
||||||
To run mocha from within gdb (notice `_mocha` and not `mocha` so that the tests run in the same process):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ gdb --args node /path/to/_mocha -R spec integration/regtest.js
|
|
||||||
```
|
|
||||||
|
|
||||||
To run the benchmarks:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ cd benchmarks
|
|
||||||
$ node index.js
|
|
||||||
```
|
|
Loading…
Reference in New Issue