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

Commit

Permalink
fix: unnecessary error data sent (#572)
Browse files Browse the repository at this point in the history
Co-authored-by: Konstantin Shuplenkov <[email protected]>
  • Loading branch information
shumkov and Konstantin Shuplenkov authored Sep 29, 2021
1 parent 10b9d1d commit 484ec39
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#DAPI_BRANCH=v0.21-dev
DAPI_BRANCH=v0.21-dev
DASHMATE_BRANCH=update-dpp
# SDK_BRANCH=
TEST_SUITE_BRANCH=update-dpp
7 changes: 6 additions & 1 deletion lib/abci/errors/AbstractAbciError.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ class AbstractAbciError extends DriveError {
getAbciResponse() {
const info = {
message: this.getMessage(),
data: this.getData(),
};

const data = this.getData();

if (Object.keys(data).length > 0) {
info.data = data;
}

return {
code: this.getCode(),
info: cbor.encode(info).toString('base64'),
Expand Down
24 changes: 17 additions & 7 deletions lib/abci/errors/DPPValidationAbciError.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ class DPPValidationAbciError extends AbstractAbciError {
* @param {AbstractConsensusError} consensusError
*/
constructor(message, consensusError) {
const data = {
arguments: consensusError.getConstructorArguments(),
};
const args = consensusError.getConstructorArguments();

const data = { };
if (args.length > 0) {
data.arguments = args;
}

super(consensusError.getCode(), message, data);
}
Expand All @@ -20,13 +23,20 @@ class DPPValidationAbciError extends AbstractAbciError {
* @returns {{code: number, info: string}}
*/
getAbciResponse() {
const info = {
data: this.getData(),
};
const info = { };

const data = this.getData();

let encodedInfo;
if (Object.keys(data).length > 0) {
info.data = data;

encodedInfo = cbor.encode(info).toString('base64');
}

return {
code: this.getCode(),
info: cbor.encode(info).toString('base64'),
info: encodedInfo,
};
}
}
Expand Down

0 comments on commit 484ec39

Please sign in to comment.