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

feat: use new Drive's error codes #162

Merged
merged 8 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DRIVE_BRANCH=update-dpp
DAPI_BRANCH=update-dpp
DASHMATE_BRANCH=feat/update-sdk
SDK_BRANCH=feat/driveProtocolVersion
DRIVE_BRANCH=feat/grpc-error-codes
DAPI_BRANCH=error-codes
DASHMATE_BRANCH=error-codes
#SDK_BRANCH=error-codes
134 changes: 80 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"@dashevo/dashcore-lib": "~0.19.25",
"@dashevo/dpns-contract": "github:dashevo/dpns-contract#update-dpp",
"@dashevo/feature-flags-contract": "github:dashevo/feature-flags-contract#update-dpp",
"@dashevo/dpp": "~0.21.0-dev.2",
"@dashevo/dpp": "~0.21.0-dev.4",
"@dashevo/grpc-common": "~0.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~0.4.1

"@dashevo/merk": "git+https://github.com/dashevo/node-merk.git",
"@dashevo/wallet-lib": "~7.21.0-dev.5",
"@dashevo/wallet-lib": "~7.21.0-dev.6",
"blake3": "^2.1.4",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"dash": "~3.21.0-dev.5",
"dash": "~3.21.0-dev.6",
"dirty-chai": "^2.0.1",
"dotenv-safe": "^8.2.0",
"github-api": "^3.3.0",
Expand Down
36 changes: 12 additions & 24 deletions test/e2e/dpns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Action is not allowed');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Action is not allowed');
expect(broadcastError.message).to.be.equal('Action is not allowed');
expect(broadcastError.code).to.equal(4001);
});

it('should not be able to delete domain', async () => {
Expand All @@ -108,10 +106,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Action is not allowed');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Action is not allowed');
expect(broadcastError.message).to.be.equal('Action is not allowed');
expect(broadcastError.code).to.equal(4001);
});
});

Expand All @@ -136,10 +132,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Can\'t create top level domain for this identity');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Can\'t create top level domain for this identity');
expect(broadcastError.message).to.be.equal('Can\'t create top level domain for this identity');
expect(broadcastError.code).to.equal(4001);
});

it('should be able to register a second level domain', async () => {
Expand Down Expand Up @@ -168,10 +162,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Parent domain is not present');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Parent domain is not present');
expect(broadcastError.message).to.be.equal('Parent domain is not present');
expect(broadcastError.code).to.equal(4001);
});

it('should be able to search a domain', async () => {
Expand Down Expand Up @@ -215,10 +207,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Action is not allowed');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Action is not allowed');
expect(broadcastError.message).to.be.equal('Action is not allowed');
expect(broadcastError.code).to.equal(4001);
});

it('should not be able to delete domain', async () => {
Expand All @@ -233,10 +223,8 @@ describe('DPNS', () => {
}

expect(broadcastError).to.exist();
expect(broadcastError.message).to.be.equal('Invalid state transition: DataTriggerConditionError: Action is not allowed');
expect(broadcastError.code).to.equal(2);
expect(broadcastError.data.errors[0].name).to.equal('DataTriggerConditionError');
expect(broadcastError.data.errors[0].message).to.equal('Action is not allowed');
expect(broadcastError.message).to.be.equal('Action is not allowed');
expect(broadcastError.code).to.equal(4001);
});

it('should not be able to register two domains with same `dashAliasIdentityId` record');
Expand Down
24 changes: 18 additions & 6 deletions test/functional/core/getBlock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,28 @@ describe('Core', () => {
expect(block).to.be.an.instanceOf(Block);
});

it('should respond with a null when the block by height was not found', async () => {
const block = await client.getDAPIClient().core.getBlockByHeight(1000000000);
it('should throw NotFound error when the block by height was not found', async () => {
try {
await client.getDAPIClient()
.core
.getBlockByHeight(1000000000);

expect(block).to.be.null();
expect.fail('should throw NotFound error');
} catch (e) {
expect(e.message).to.equal('5 NOT_FOUND: Invalid block height');
expect(e.code).to.equal(5);
}
});

it('should respond with null if the block by hash was not found', async () => {
const block = await client.getDAPIClient().core.getBlockByHash('hash');
it('should throw NotFound error when the block by hash was not found', async () => {
try {
await client.getDAPIClient().core.getBlockByHash('hash');

expect(block).to.equal(null);
expect.fail('should throw NotFound error');
} catch (e) {
expect(e.message).to.equal('5 NOT_FOUND: Block not found');
expect(e.code).to.equal(5);
}
});
});
});
2 changes: 1 addition & 1 deletion test/functional/core/getTransaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
PrivateKey,
} = require('@dashevo/dashcore-lib');

const NotFoundError = require('@dashevo/dapi-client/lib/methods/errors/NotFoundError');
const NotFoundError = require('@dashevo/dapi-client/lib/errors/response/NotFoundError');

const createFaucetClient = require('../../../lib/test/createFaucetClient');
const wait = require('../../../lib/wait');
Expand Down
Loading