64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
/* eslint-env mocha */
|
|
/* eslint prefer-arrow-callback: "off" */
|
|
|
|
'use strict';
|
|
|
|
const assert = require('bsert');
|
|
const FullNode = require('../lib/node/fullnode');
|
|
|
|
const ports = {
|
|
p2p: 49331,
|
|
node: 49332,
|
|
wallet: 49333
|
|
};
|
|
|
|
const node = new FullNode({
|
|
network: 'regtest',
|
|
apiKey: 'foo',
|
|
walletAuth: true,
|
|
memory: true,
|
|
workers: true,
|
|
workersSize: 2,
|
|
plugins: [require('../lib/wallet/plugin')],
|
|
port: ports.p2p,
|
|
httpPort: ports.node,
|
|
env: {
|
|
'BCOIN_WALLET_HTTP_PORT': ports.wallet.toString()
|
|
}});
|
|
|
|
const {NodeClient} = require('@oipwg/fclient');
|
|
|
|
const nclient = new NodeClient({
|
|
port: ports.node,
|
|
apiKey: 'foo',
|
|
timeout: 15000
|
|
});
|
|
|
|
describe('RPC', function() {
|
|
this.timeout(15000);
|
|
|
|
before(async () => {
|
|
await node.open();
|
|
});
|
|
|
|
after(async () => {
|
|
await node.close();
|
|
});
|
|
|
|
it('should rpc help', async () => {
|
|
assert(await nclient.execute('help', []));
|
|
|
|
await assert.rejects(async () => {
|
|
await nclient.execute('help', ['getinfo']);
|
|
}, {
|
|
name: 'Error',
|
|
message: /^getinfo/
|
|
});
|
|
});
|
|
|
|
it('should rpc getinfo', async () => {
|
|
const info = await nclient.execute('getinfo', []);
|
|
assert.strictEqual(info.blocks, 0);
|
|
});
|
|
});
|