Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
feat!: remove getUTXO & getAddressSummary rpc methods (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Shuplenkov authored Sep 3, 2020
1 parent 32d8e18 commit 79ea2ab
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 487 deletions.
113 changes: 0 additions & 113 deletions lib/rpcServer/commands/getAddressSummary.js

This file was deleted.

119 changes: 0 additions & 119 deletions lib/rpcServer/commands/getUTXO.js

This file was deleted.

12 changes: 1 addition & 11 deletions lib/rpcServer/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ const errorHandlerDecorator = require('./errorHandlerDecorator');
const getBestBlockHash = require('./commands/getBestBlockHash');
const getBlockHash = require('./commands/getBlockHash');
const getMnListDiff = require('./commands/getMnListDiff');
const getUTXO = require('./commands/getUTXO');
const generateToAddress = require('./commands/generateToAddress');
const getAddressSummary = require('./commands/getAddressSummary');

// Following commands are not implemented yet:
// const getVersion = require('./commands/getVersion');

const createCommands = (
insightAPI,
dashcoreAPI,
) => ({
const createCommands = dashcoreAPI => ({
getBestBlockHash: getBestBlockHash(dashcoreAPI),
getBlockHash: getBlockHash(dashcoreAPI),
getMnListDiff: getMnListDiff(dashcoreAPI),
getUTXO: getUTXO(insightAPI),
getAddressSummary: getAddressSummary(insightAPI),
});

const createRegtestCommands = dashcoreAPI => ({
Expand All @@ -32,7 +25,6 @@ const createRegtestCommands = dashcoreAPI => ({
* @param options
* @param {number} options.port - port to listen for incoming RPC connections
* @param {string} options.networkType
* @param {object} options.insightAPI
* @param {object} options.dashcoreAPI
* @param {AbstractDriveAdapter} options.driveAPI - Drive api adapter
* @param {object} options.tendermintRpcClient
Expand All @@ -42,12 +34,10 @@ const createRegtestCommands = dashcoreAPI => ({
const start = ({
port,
networkType,
insightAPI,
dashcoreAPI,
log,
}) => {
const commands = createCommands(
insightAPI,
dashcoreAPI,
);

Expand Down
1 change: 0 additions & 1 deletion scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async function main() {
rpcServer.start({
port: config.rpcServer.port,
networkType: config.network,
insightAPI,
dashcoreAPI: dashCoreRpcClient,
log,
});
Expand Down
39 changes: 0 additions & 39 deletions test/unit/api/dashcore/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,45 +249,6 @@ describe('externalApis/dashcore/rpc', async () => {
});
});

describe('getUTXO', () => {
describe('#factory', () => {
it('should return a promise', () => {
const res = rpc.getUTXO();
expect(res).to.be.a('promise');
});
it('should return error with invalid transaction', async () => {
const res = rpc.getUTXO(1);
await expect(res).to.be.rejectedWith('JSON');
});
});

describe('#stub', () => {
const addrStr = 'ygPcCwVy7Fxg7ruxZzqVYdPLtvw7auHAFh';
before(() => {
stub = sinon.stub(rpc, 'getUTXO');
stub
.withArgs(addrStr)
.returns(new Promise(resolve => resolve('fake')));
});

beforeEach(() => {
stub.resetHistory();
});

after(() => {
stub.restore();
});

it('Should return a hash', async () => {
rpc.getUTXO(123);
expect(stub.callCount).to.be.equal(1);
const transaction = await rpc.getUTXO(addrStr);
expect(transaction).to.be.equal('fake');
expect(stub.callCount).to.be.equal(2);
});
});
});

describe('getBlockHash', () => {
describe('#factory', () => {
it('should return a promise', () => {
Expand Down
Loading

0 comments on commit 79ea2ab

Please sign in to comment.