node: add getNetworkName method

This commit is contained in:
Braydon Fuller 2016-04-08 16:00:33 -04:00
parent 90e354093c
commit f3f2f59615
3 changed files with 13 additions and 5 deletions

View File

@ -248,6 +248,14 @@ Node.prototype.start = function(callback) {
);
};
Node.prototype.getNetworkName = function() {
var network = this.network.name;
if (this.network.regtestEnabled) {
network = 'regtest';
}
return network;
};
/**
* Will stop all running services in the reverse order that they
* were initially started.

View File

@ -1301,10 +1301,7 @@ Bitcoin.prototype.getInfo = function(callback) {
return callback(self._wrapRPCError(err));
}
var result = response.result;
result.network = self.node.network.name;
if (self.node.network.regtestEnabled) {
result.network = 'regtest';
}
result.network = self.node.getNetworkName();
callback(null, result);
});
};

View File

@ -49,7 +49,10 @@ describe('Bitcoind Functionality', function() {
exec: path.resolve(__dirname, '../bin/bitcoind')
},
node: {
network: regtestNetwork
network: regtestNetwork,
getNetworkName: function() {
return 'regtest';
}
}
});