Zcash-ify daemon, config files etc.

This commit is contained in:
Jack Grigg 2016-08-28 14:27:01 +12:00
parent 10b44b6392
commit 112c6d896d
15 changed files with 42 additions and 42 deletions

View File

@ -28,7 +28,7 @@ var fixtureData = {
var bitcoind = require('../').services.Bitcoin({ var bitcoind = require('../').services.Bitcoin({
node: { node: {
datadir: process.env.HOME + '/.bitcoin', datadir: process.env.HOME + '/.zcash',
network: { network: {
name: 'testnet' name: 'testnet'
} }

View File

@ -49,7 +49,7 @@ var myNode = new bitcore.Node({
config: { config: {
spawn: { spawn: {
datadir: '/home/<username>/.bitcoin', datadir: '/home/<username>/.bitcoin',
exec: '/home/<username>/bitcore-node/bin/bitcoind' exec: '/home/<username>/bitcore-node/bin/zcashd'
} }
} }
}, },

View File

@ -48,7 +48,7 @@ To start reindexing add `reindex=1` during the **first startup only**.
"bitcoind": { "bitcoind": {
"spawn": { "spawn": {
"datadir": "/home/<username>/.bitcoin", "datadir": "/home/<username>/.bitcoin",
"exec": "/home/<username>/bitcore-node/bin/bitcoind" "exec": "/home/<username>/bitcore-node/bin/zcashd"
} }
} }
} }

View File

@ -22,8 +22,8 @@ function getDefaultBaseConfig(options) {
servicesConfig: { servicesConfig: {
bitcoind: { bitcoind: {
spawn: { spawn: {
datadir: options.datadir || path.resolve(process.env.HOME, '.bitcoin'), datadir: options.datadir || path.resolve(process.env.HOME, '.zcash'),
exec: path.resolve(__dirname, '../../bin/bitcoind') exec: path.resolve(__dirname, '../../bin/zcashd')
} }
} }
} }

View File

@ -38,7 +38,7 @@ function getDefaultConfig(options) {
bitcoind: { bitcoind: {
spawn: { spawn: {
datadir: path.resolve(defaultPath, './data'), datadir: path.resolve(defaultPath, './data'),
exec: path.resolve(__dirname, '../../bin/bitcoind') exec: path.resolve(__dirname, '../../bin/zcashd')
} }
} }
} }

View File

@ -34,7 +34,7 @@ function checkConfigVersion2(fullConfig) {
bitcoind: { bitcoind: {
spawn: { spawn: {
datadir: fullConfig.datadir, datadir: fullConfig.datadir,
exec: path.resolve(__dirname, '../../bin/bitcoind') exec: path.resolve(__dirname, '../../bin/zcashd')
} }
} }
} }

View File

@ -338,7 +338,7 @@ Bitcoin.prototype._loadSpawnConfiguration = function(node) {
this._expandRelativeDatadir(); this._expandRelativeDatadir();
var spawnOptions = this.options.spawn; var spawnOptions = this.options.spawn;
var configPath = path.resolve(spawnOptions.datadir, './bitcoin.conf'); var configPath = path.resolve(spawnOptions.datadir, './zcash.conf');
log.info('Using bitcoin config file:', configPath); log.info('Using bitcoin config file:', configPath);
@ -488,10 +488,10 @@ Bitcoin.prototype._initChain = function(callback) {
Bitcoin.prototype._getDefaultConf = function() { Bitcoin.prototype._getDefaultConf = function() {
var networkOptions = { var networkOptions = {
rpcport: 8332 rpcport: 8232
}; };
if (this.node.network === bitcore.Networks.testnet) { if (this.node.network === bitcore.Networks.testnet) {
networkOptions.rpcport = 18332; networkOptions.rpcport = 18232;
} }
return networkOptions; return networkOptions;
}; };
@ -499,9 +499,9 @@ Bitcoin.prototype._getDefaultConf = function() {
Bitcoin.prototype._getNetworkConfigPath = function() { Bitcoin.prototype._getNetworkConfigPath = function() {
var networkPath; var networkPath;
if (this.node.network === bitcore.Networks.testnet) { if (this.node.network === bitcore.Networks.testnet) {
networkPath = 'testnet3/bitcoin.conf'; networkPath = 'testnet3/zcash.conf';
if (this.node.network.regtestEnabled) { if (this.node.network.regtestEnabled) {
networkPath = 'regtest/bitcoin.conf'; networkPath = 'regtest/zcash.conf';
} }
} }
return networkPath; return networkPath;
@ -796,7 +796,7 @@ Bitcoin.prototype._loadTipFromNode = function(node, callback) {
Bitcoin.prototype._stopSpawnedBitcoin = function(callback) { Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
var self = this; var self = this;
var spawnOptions = this.options.spawn; var spawnOptions = this.options.spawn;
var pidPath = spawnOptions.datadir + '/bitcoind.pid'; var pidPath = spawnOptions.datadir + '/zcashd.pid';
function stopProcess() { function stopProcess() {
fs.readFile(pidPath, 'utf8', function(err, pid) { fs.readFile(pidPath, 'utf8', function(err, pid) {

View File

@ -46,7 +46,7 @@ describe('Bitcoind Functionality', function() {
bitcoind = require('../').services.Bitcoin({ bitcoind = require('../').services.Bitcoin({
spawn: { spawn: {
datadir: datadir, datadir: datadir,
exec: path.resolve(__dirname, '../bin/bitcoind') exec: path.resolve(__dirname, '../bin/zcashd')
}, },
node: { node: {
network: regtestNetwork, network: regtestNetwork,

View File

@ -19,11 +19,11 @@ var BitcoinService = index.services.Bitcoin;
describe('Bitcoin Cluster', function() { describe('Bitcoin Cluster', function() {
var node; var node;
var daemons = []; var daemons = [];
var execPath = path.resolve(__dirname, '../bin/bitcoind'); var execPath = path.resolve(__dirname, '../bin/zcashd');
var nodesConf = [ var nodesConf = [
{ {
datadir: path.resolve(__dirname, './data/node1'), datadir: path.resolve(__dirname, './data/node1'),
conf: path.resolve(__dirname, './data/node1/bitcoin.conf'), conf: path.resolve(__dirname, './data/node1/zcash.conf'),
rpcuser: 'bitcoin', rpcuser: 'bitcoin',
rpcpassword: 'local321', rpcpassword: 'local321',
rpcport: 30521, rpcport: 30521,
@ -32,7 +32,7 @@ describe('Bitcoin Cluster', function() {
}, },
{ {
datadir: path.resolve(__dirname, './data/node2'), datadir: path.resolve(__dirname, './data/node2'),
conf: path.resolve(__dirname, './data/node2/bitcoin.conf'), conf: path.resolve(__dirname, './data/node2/zcash.conf'),
rpcuser: 'bitcoin', rpcuser: 'bitcoin',
rpcpassword: 'local321', rpcpassword: 'local321',
rpcport: 30522, rpcport: 30522,
@ -41,7 +41,7 @@ describe('Bitcoin Cluster', function() {
}, },
{ {
datadir: path.resolve(__dirname, './data/node3'), datadir: path.resolve(__dirname, './data/node3'),
conf: path.resolve(__dirname, './data/node3/bitcoin.conf'), conf: path.resolve(__dirname, './data/node3/zcash.conf'),
rpcuser: 'bitcoin', rpcuser: 'bitcoin',
rpcpassword: 'local321', rpcpassword: 'local321',
rpcport: 30523, rpcport: 30523,

View File

@ -53,7 +53,7 @@ describe('Node Functionality', function() {
config: { config: {
spawn: { spawn: {
datadir: datadir, datadir: datadir,
exec: path.resolve(__dirname, '../bin/bitcoind') exec: path.resolve(__dirname, '../bin/zcashd')
} }
} }
} }

View File

@ -52,7 +52,7 @@ describe('P2P Functionality', function() {
bitcoind = require('../').services.Bitcoin({ bitcoind = require('../').services.Bitcoin({
spawn: { spawn: {
datadir: datadir, datadir: datadir,
exec: path.resolve(__dirname, '../bin/bitcoind') exec: path.resolve(__dirname, '../bin/zcashd')
}, },
node: { node: {
network: bitcore.Networks.testnet network: bitcore.Networks.testnet

View File

@ -33,7 +33,7 @@ describe('#create', function() {
if (err) { if (err) {
throw err; throw err;
} }
mkdirp(testDir + '/.bitcoin', function(err) { mkdirp(testDir + '/.zcash', function(err) {
if (err) { if (err) {
throw err; throw err;
} }
@ -104,7 +104,7 @@ describe('#create', function() {
dirname: 'mynode3', dirname: 'mynode3',
name: 'My Node 3', name: 'My Node 3',
isGlobal: true, isGlobal: true,
datadir: '../.bitcoin' datadir: '../.zcash'
}, function(err) { }, function(err) {
if (err) { if (err) {
throw err; throw err;
@ -139,7 +139,7 @@ describe('#create', function() {
dirname: 'mynode4', dirname: 'mynode4',
name: 'My Node 4', name: 'My Node 4',
isGlobal: false, isGlobal: false,
datadir: '../.bitcoin' datadir: '../.zcash'
}, function(err) { }, function(err) {
should.exist(err); should.exist(err);
err.message.should.equal('There was an error installing dependencies.'); err.message.should.equal('There was an error installing dependencies.');

View File

@ -14,8 +14,8 @@ describe('#defaultBaseConfig', function() {
info.config.port.should.equal(3001); info.config.port.should.equal(3001);
info.config.services.should.deep.equal(['bitcoind', 'web']); info.config.services.should.deep.equal(['bitcoind', 'web']);
var bitcoind = info.config.servicesConfig.bitcoind; var bitcoind = info.config.servicesConfig.bitcoind;
bitcoind.spawn.datadir.should.equal(home + '/.bitcoin'); bitcoind.spawn.datadir.should.equal(home + '/.zcash');
bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/bitcoind')); bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/zcashd'));
}); });
it('be able to specify a network', function() { it('be able to specify a network', function() {
var info = defaultBaseConfig({network: 'testnet'}); var info = defaultBaseConfig({network: 'testnet'});

View File

@ -6,7 +6,7 @@ var sinon = require('sinon');
var proxyquire = require('proxyquire'); var proxyquire = require('proxyquire');
describe('#defaultConfig', function() { describe('#defaultConfig', function() {
var expectedExecPath = path.resolve(__dirname, '../../bin/bitcoind'); var expectedExecPath = path.resolve(__dirname, '../../bin/zcashd');
it('will return expected configuration', function() { it('will return expected configuration', function() {
var config = JSON.stringify({ var config = JSON.stringify({

View File

@ -18,13 +18,13 @@ var log = index.log;
var errors = index.errors; var errors = index.errors;
var Transaction = bitcore.Transaction; var Transaction = bitcore.Transaction;
var readFileSync = sinon.stub().returns(fs.readFileSync(path.resolve(__dirname, '../data/bitcoin.conf'))); var readFileSync = sinon.stub().returns(fs.readFileSync(path.resolve(__dirname, '../data/zcash.conf')));
var BitcoinService = proxyquire('../../lib/services/bitcoind', { var BitcoinService = proxyquire('../../lib/services/bitcoind', {
fs: { fs: {
readFileSync: readFileSync readFileSync: readFileSync
} }
}); });
var defaultBitcoinConf = fs.readFileSync(path.resolve(__dirname, '../data/default.bitcoin.conf'), 'utf8'); var defaultBitcoinConf = fs.readFileSync(path.resolve(__dirname, '../data/default.zcash.conf'), 'utf8');
describe('Bitcoin Service', function() { describe('Bitcoin Service', function() {
var txhex = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000'; var txhex = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000';
@ -357,7 +357,7 @@ describe('Bitcoin Service', function() {
afterEach(function() { afterEach(function() {
sandbox.restore(); sandbox.restore();
}); });
it('will parse a bitcoin.conf file', function() { it('will parse a zcash.conf file', function() {
var TestBitcoin = proxyquire('../../lib/services/bitcoind', { var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
fs: { fs: {
readFileSync: readFileSync, readFileSync: readFileSync,
@ -369,7 +369,7 @@ describe('Bitcoin Service', function() {
} }
}); });
var bitcoind = new TestBitcoin(baseConfig); var bitcoind = new TestBitcoin(baseConfig);
bitcoind.options.spawn.datadir = '/tmp/.bitcoin'; bitcoind.options.spawn.datadir = '/tmp/.zcash';
var node = {}; var node = {};
bitcoind._loadSpawnConfiguration(node); bitcoind._loadSpawnConfiguration(node);
should.exist(bitcoind.spawn.config); should.exist(bitcoind.spawn.config);
@ -423,7 +423,7 @@ describe('Bitcoin Service', function() {
it('should throw an exception if txindex isn\'t enabled in the configuration', function() { it('should throw an exception if txindex isn\'t enabled in the configuration', function() {
var TestBitcoin = proxyquire('../../lib/services/bitcoind', { var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
fs: { fs: {
readFileSync: sinon.stub().returns(fs.readFileSync(__dirname + '/../data/badbitcoin.conf')), readFileSync: sinon.stub().returns(fs.readFileSync(__dirname + '/../data/badzcash.conf')),
existsSync: sinon.stub().returns(true), existsSync: sinon.stub().returns(true),
}, },
mkdirp: { mkdirp: {
@ -466,7 +466,7 @@ describe('Bitcoin Service', function() {
} }
}; };
var bitcoind = new TestBitcoin(config); var bitcoind = new TestBitcoin(config);
bitcoind.options.spawn.datadir = '/tmp/.bitcoin'; bitcoind.options.spawn.datadir = '/tmp/.zcash';
var node = {}; var node = {};
bitcoind._loadSpawnConfiguration(node); bitcoind._loadSpawnConfiguration(node);
}); });
@ -480,7 +480,7 @@ describe('Bitcoin Service', function() {
afterEach(function() { afterEach(function() {
sandbox.restore(); sandbox.restore();
}); });
it('should warn the user if reindex is set to 1 in the bitcoin.conf file', function() { it('should warn the user if reindex is set to 1 in the zcash.conf file', function() {
var bitcoind = new BitcoinService(baseConfig); var bitcoind = new BitcoinService(baseConfig);
var config = { var config = {
txindex: 1, txindex: 1,
@ -829,7 +829,7 @@ describe('Bitcoin Service', function() {
} }
}; };
var bitcoind = new BitcoinService(config); var bitcoind = new BitcoinService(config);
bitcoind._getNetworkConfigPath().should.equal('testnet3/bitcoin.conf'); bitcoind._getNetworkConfigPath().should.equal('testnet3/zcash.conf');
}); });
it('will get default rpc port for regtest', function() { it('will get default rpc port for regtest', function() {
bitcore.Networks.enableRegtest(); bitcore.Networks.enableRegtest();
@ -843,7 +843,7 @@ describe('Bitcoin Service', function() {
} }
}; };
var bitcoind = new BitcoinService(config); var bitcoind = new BitcoinService(config);
bitcoind._getNetworkConfigPath().should.equal('regtest/bitcoin.conf'); bitcoind._getNetworkConfigPath().should.equal('regtest/zcash.conf');
}); });
}); });
@ -1749,7 +1749,7 @@ describe('Bitcoin Service', function() {
bitcoind._loadSpawnConfiguration = sinon.stub(); bitcoind._loadSpawnConfiguration = sinon.stub();
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'testexec'; bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf'; bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir'; bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001; bitcoind.spawn.config.rpcport = 20001;
@ -1766,7 +1766,7 @@ describe('Bitcoin Service', function() {
spawn.callCount.should.equal(1); spawn.callCount.should.equal(1);
spawn.args[0][0].should.equal('testexec'); spawn.args[0][0].should.equal('testexec');
spawn.args[0][1].should.deep.equal([ spawn.args[0][1].should.deep.equal([
'--conf=testdir/bitcoin.conf', '--conf=testdir/zcash.conf',
'--datadir=testdir', '--datadir=testdir',
'--testnet' '--testnet'
]); ]);
@ -1800,7 +1800,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind'; bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin'; bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf'; bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1; bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1); bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1838,7 +1838,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind'; bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin'; bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf'; bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1; bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1); bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1885,7 +1885,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind'; bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin'; bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf'; bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1; bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1); bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1924,7 +1924,7 @@ describe('Bitcoin Service', function() {
bitcoind._loadSpawnConfiguration = sinon.stub(); bitcoind._loadSpawnConfiguration = sinon.stub();
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'testexec'; bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf'; bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir'; bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001; bitcoind.spawn.config.rpcport = 20001;
@ -1954,7 +1954,7 @@ describe('Bitcoin Service', function() {
bitcoind._loadSpawnConfiguration = sinon.stub(); bitcoind._loadSpawnConfiguration = sinon.stub();
bitcoind.spawn = {}; bitcoind.spawn = {};
bitcoind.spawn.exec = 'testexec'; bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf'; bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir'; bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {}; bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001; bitcoind.spawn.config.rpcport = 20001;