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({
node: {
datadir: process.env.HOME + '/.bitcoin',
datadir: process.env.HOME + '/.zcash',
network: {
name: 'testnet'
}

View File

@ -49,7 +49,7 @@ var myNode = new bitcore.Node({
config: {
spawn: {
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": {
"spawn": {
"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: {
bitcoind: {
spawn: {
datadir: options.datadir || path.resolve(process.env.HOME, '.bitcoin'),
exec: path.resolve(__dirname, '../../bin/bitcoind')
datadir: options.datadir || path.resolve(process.env.HOME, '.zcash'),
exec: path.resolve(__dirname, '../../bin/zcashd')
}
}
}

View File

@ -38,7 +38,7 @@ function getDefaultConfig(options) {
bitcoind: {
spawn: {
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: {
spawn: {
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();
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);
@ -488,10 +488,10 @@ Bitcoin.prototype._initChain = function(callback) {
Bitcoin.prototype._getDefaultConf = function() {
var networkOptions = {
rpcport: 8332
rpcport: 8232
};
if (this.node.network === bitcore.Networks.testnet) {
networkOptions.rpcport = 18332;
networkOptions.rpcport = 18232;
}
return networkOptions;
};
@ -499,9 +499,9 @@ Bitcoin.prototype._getDefaultConf = function() {
Bitcoin.prototype._getNetworkConfigPath = function() {
var networkPath;
if (this.node.network === bitcore.Networks.testnet) {
networkPath = 'testnet3/bitcoin.conf';
networkPath = 'testnet3/zcash.conf';
if (this.node.network.regtestEnabled) {
networkPath = 'regtest/bitcoin.conf';
networkPath = 'regtest/zcash.conf';
}
}
return networkPath;
@ -796,7 +796,7 @@ Bitcoin.prototype._loadTipFromNode = function(node, callback) {
Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
var self = this;
var spawnOptions = this.options.spawn;
var pidPath = spawnOptions.datadir + '/bitcoind.pid';
var pidPath = spawnOptions.datadir + '/zcashd.pid';
function stopProcess() {
fs.readFile(pidPath, 'utf8', function(err, pid) {

View File

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

View File

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

View File

@ -53,7 +53,7 @@ describe('Node Functionality', function() {
config: {
spawn: {
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({
spawn: {
datadir: datadir,
exec: path.resolve(__dirname, '../bin/bitcoind')
exec: path.resolve(__dirname, '../bin/zcashd')
},
node: {
network: bitcore.Networks.testnet

View File

@ -33,7 +33,7 @@ describe('#create', function() {
if (err) {
throw err;
}
mkdirp(testDir + '/.bitcoin', function(err) {
mkdirp(testDir + '/.zcash', function(err) {
if (err) {
throw err;
}
@ -104,7 +104,7 @@ describe('#create', function() {
dirname: 'mynode3',
name: 'My Node 3',
isGlobal: true,
datadir: '../.bitcoin'
datadir: '../.zcash'
}, function(err) {
if (err) {
throw err;
@ -139,7 +139,7 @@ describe('#create', function() {
dirname: 'mynode4',
name: 'My Node 4',
isGlobal: false,
datadir: '../.bitcoin'
datadir: '../.zcash'
}, function(err) {
should.exist(err);
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.services.should.deep.equal(['bitcoind', 'web']);
var bitcoind = info.config.servicesConfig.bitcoind;
bitcoind.spawn.datadir.should.equal(home + '/.bitcoin');
bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/bitcoind'));
bitcoind.spawn.datadir.should.equal(home + '/.zcash');
bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/zcashd'));
});
it('be able to specify a network', function() {
var info = defaultBaseConfig({network: 'testnet'});

View File

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

View File

@ -18,13 +18,13 @@ var log = index.log;
var errors = index.errors;
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', {
fs: {
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() {
var txhex = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000';
@ -357,7 +357,7 @@ describe('Bitcoin Service', function() {
afterEach(function() {
sandbox.restore();
});
it('will parse a bitcoin.conf file', function() {
it('will parse a zcash.conf file', function() {
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
fs: {
readFileSync: readFileSync,
@ -369,7 +369,7 @@ describe('Bitcoin Service', function() {
}
});
var bitcoind = new TestBitcoin(baseConfig);
bitcoind.options.spawn.datadir = '/tmp/.bitcoin';
bitcoind.options.spawn.datadir = '/tmp/.zcash';
var node = {};
bitcoind._loadSpawnConfiguration(node);
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() {
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
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),
},
mkdirp: {
@ -466,7 +466,7 @@ describe('Bitcoin Service', function() {
}
};
var bitcoind = new TestBitcoin(config);
bitcoind.options.spawn.datadir = '/tmp/.bitcoin';
bitcoind.options.spawn.datadir = '/tmp/.zcash';
var node = {};
bitcoind._loadSpawnConfiguration(node);
});
@ -480,7 +480,7 @@ describe('Bitcoin Service', function() {
afterEach(function() {
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 config = {
txindex: 1,
@ -829,7 +829,7 @@ describe('Bitcoin Service', function() {
}
};
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() {
bitcore.Networks.enableRegtest();
@ -843,7 +843,7 @@ describe('Bitcoin Service', function() {
}
};
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.spawn = {};
bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001;
@ -1766,7 +1766,7 @@ describe('Bitcoin Service', function() {
spawn.callCount.should.equal(1);
spawn.args[0][0].should.equal('testexec');
spawn.args[0][1].should.deep.equal([
'--conf=testdir/bitcoin.conf',
'--conf=testdir/zcash.conf',
'--datadir=testdir',
'--testnet'
]);
@ -1800,7 +1800,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1838,7 +1838,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1885,7 +1885,7 @@ describe('Bitcoin Service', function() {
bitcoind.spawn = {};
bitcoind.spawn.exec = 'bitcoind';
bitcoind.spawn.datadir = '/tmp/bitcoin';
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
bitcoind.spawn.config = {};
bitcoind.spawnRestartTime = 1;
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
@ -1924,7 +1924,7 @@ describe('Bitcoin Service', function() {
bitcoind._loadSpawnConfiguration = sinon.stub();
bitcoind.spawn = {};
bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001;
@ -1954,7 +1954,7 @@ describe('Bitcoin Service', function() {
bitcoind._loadSpawnConfiguration = sinon.stub();
bitcoind.spawn = {};
bitcoind.spawn.exec = 'testexec';
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
bitcoind.spawn.configPath = 'testdir/zcash.conf';
bitcoind.spawn.datadir = 'testdir';
bitcoind.spawn.config = {};
bitcoind.spawn.config.rpcport = 20001;