Skip to content

Commit

Permalink
fix: get rid of error [object Object] for spencon simulation (#321)
Browse files Browse the repository at this point in the history
* return logs and message

* fix tests
  • Loading branch information
troggy committed Aug 22, 2019
1 parent 3a609b0 commit 69b4c9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/api/methods/checkSpendingCondition.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ module.exports = async (bridgeState, rawTx) => {
try {
logOuts = await checkSpendCond(bridgeState.currentState, tx, bridgeState);
} catch (err) {
// return err + the calculated logOuts <if any>
return { error: err.toString(), outputs: err.logOuts };
return {
error: err.message ? err.message : JSON.stringify(err),
outputs: err.logOuts,
};
}

return { outputs: logOuts };
return {
outputs: logOuts,
};
};
4 changes: 1 addition & 3 deletions src/tx/applyTx/checkSpendCond.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ describe('checkSpendCond', () => {
apiResult = await checkSpendingCondition(bridgeState, condition.hex());
expect(apiResult.outputs).toEqual(outs);
expect(
apiResult.error.startsWith(
'Error: outputs do not match computation results'
)
apiResult.error.startsWith('outputs do not match computation results')
).toEqual(true);
});

Expand Down

0 comments on commit 69b4c9a

Please sign in to comment.