http: more tests.
This commit is contained in:
parent
0d844be588
commit
c0e4c169ba
5
bin/cli
5
bin/cli
@ -105,7 +105,8 @@ CLI.prototype.getAccount = co(function* getAccount() {
|
||||
});
|
||||
|
||||
CLI.prototype.createAccount = co(function* createAccount() {
|
||||
var options = { name: this.config.str(0) };
|
||||
var name = this.config.str(0);
|
||||
var options = {};
|
||||
var account;
|
||||
|
||||
options.type = this.config.str('type');
|
||||
@ -114,7 +115,7 @@ CLI.prototype.createAccount = co(function* createAccount() {
|
||||
options.witness = this.config.bool('witness');
|
||||
options.accountKey = this.config.str('watch');
|
||||
|
||||
account = yield this.wallet.createAccount(options);
|
||||
account = yield this.wallet.createAccount(name, options);
|
||||
|
||||
this.log(account);
|
||||
});
|
||||
|
||||
@ -927,7 +927,7 @@ HTTPClient.prototype.getMaster = function getMaster(id) {
|
||||
* Get wallet account.
|
||||
* @param {WalletID} id
|
||||
* @param {String} account
|
||||
* @returns {Promise} - Returns Array.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
HTTPClient.prototype.getAccount = function getAccount(id, account) {
|
||||
@ -938,22 +938,14 @@ HTTPClient.prototype.getAccount = function getAccount(id, account) {
|
||||
/**
|
||||
* Create account.
|
||||
* @param {WalletID} id
|
||||
* @param {String} name
|
||||
* @param {Object} options
|
||||
* @returns {Promise} - Returns Array.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
HTTPClient.prototype.createAccount = function createAccount(id, options) {
|
||||
var path;
|
||||
|
||||
if (!options)
|
||||
options = {};
|
||||
|
||||
if (typeof options === 'string')
|
||||
options = { account: options };
|
||||
|
||||
path = '/wallet/' + id + '/account' + options.account;
|
||||
|
||||
return this._put(path, options);
|
||||
HTTPClient.prototype.createAccount = function createAccount(id, name, options) {
|
||||
var path = '/wallet/' + id + '/account/' + name;
|
||||
return this._put(path, options || {});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -310,8 +310,8 @@ HTTPWallet.prototype.getAccount = function getAccount(account) {
|
||||
* @see Wallet#createAccount
|
||||
*/
|
||||
|
||||
HTTPWallet.prototype.createAccount = function createAccount(options) {
|
||||
return this.client.createAccount(this.id, options);
|
||||
HTTPWallet.prototype.createAccount = function createAccount(name, options) {
|
||||
return this.client.createAccount(this.id, name, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -17,7 +17,6 @@ var workerPool = require('../workers/workerpool').pool;
|
||||
var ec = require('../crypto/ec');
|
||||
var native = require('../utils/native');
|
||||
var Config = require('./config');
|
||||
var SigCache = require('../script/sigcache');
|
||||
|
||||
/**
|
||||
* Base class from which every other
|
||||
|
||||
@ -275,6 +275,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
||||
type: valid.str('type'),
|
||||
m: valid.u32('m'),
|
||||
n: valid.u32('n'),
|
||||
accountKey: valid.str('accountKey'),
|
||||
lookahead: valid.u32('lookahead')
|
||||
};
|
||||
|
||||
@ -301,6 +302,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
||||
type: valid.str('type'),
|
||||
m: valid.u32('m'),
|
||||
n: valid.u32('n'),
|
||||
accountKey: valid.str('accountKey'),
|
||||
lookahead: valid.u32('lookahead')
|
||||
};
|
||||
|
||||
|
||||
@ -154,6 +154,30 @@ describe('HTTP', function() {
|
||||
assert.equal(info.blocks, 0);
|
||||
}));
|
||||
|
||||
it('should create account', co(function* () {
|
||||
var info = yield wallet.createAccount('foo1');
|
||||
assert(info);
|
||||
assert(info.initialized);
|
||||
assert.equal(info.name, 'foo1');
|
||||
assert.equal(info.accountIndex, 1);
|
||||
assert.equal(info.m, 1);
|
||||
assert.equal(info.n, 1);
|
||||
}));
|
||||
|
||||
it('should create account', co(function* () {
|
||||
var info = yield wallet.createAccount('foo2', {
|
||||
type: 'multisig',
|
||||
m: 1,
|
||||
n: 2
|
||||
});
|
||||
assert(info);
|
||||
assert(!info.initialized);
|
||||
assert.equal(info.name, 'foo2');
|
||||
assert.equal(info.accountIndex, 2);
|
||||
assert.equal(info.m, 1);
|
||||
assert.equal(info.n, 2);
|
||||
}));
|
||||
|
||||
it('should get a block template', co(function* () {
|
||||
var json = yield wallet.client.rpc.execute('getblocktemplate', []);
|
||||
assert.deepStrictEqual(json, {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user