Skip to content

Commit

Permalink
Simplified error details in path epic
Browse files Browse the repository at this point in the history
  • Loading branch information
nephix committed Feb 14, 2020
1 parent 222162b commit c48b97a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion raiden-ts/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const getContracts = (network: Network): ContractsInfo => {
...goerliServicesDeploy.contracts,
} as unknown) as ContractsInfo;
default:
throw new RaidenError(ErrorCodes.RDN_UNRECOGNIZED_NETWORK, [{ network }]);
throw new RaidenError(ErrorCodes.RDN_UNRECOGNIZED_NETWORK, [{ network: network.name }]);
}
};

Expand Down
8 changes: 3 additions & 5 deletions raiden-ts/src/path/epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ const prepareNextIOU$ = (
const text = await response.text();
if (!response.ok)
throw new RaidenError(ErrorCodes.PFS_LAST_IOU_REQUEST_FAILED, [
{ responseStatus: response.status },
{ responseText: text },
{ responseStatus: response.status, responseText: text },
]);

const { last_iou: lastIou } = decode(LastIOUResults, losslessParse(text));
Expand All @@ -160,8 +159,8 @@ const prepareNextIOU$ = (
throw new RaidenError(ErrorCodes.PFS_IOU_SIGNATURE_MISMATCH, [
{
signer,
address: deps.address,
},
{ address: deps.address },
]);
return lastIou;
}),
Expand Down Expand Up @@ -334,8 +333,7 @@ export const pathFindServiceEpic = (
// if error, don't proceed
if (!data.paths) {
throw new RaidenError(ErrorCodes.PFS_ERROR_RESPONSE, [
{ errorCode: data.error.error_code },
{ errors: data.error.errors },
{ errorCode: data.error.error_code, errors: data.error.errors },
]);
}
const filteredPaths: Paths = [],
Expand Down
2 changes: 1 addition & 1 deletion raiden-ts/src/transport/epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ export const matrixPresenceUpdateEpic = (
const recovered = verifyMessage(userId, displayName) as Address | undefined;
if (!recovered || recovered !== address)
throw new RaidenError(ErrorCodes.TRNS_USERNAME_VERIFICATION_FAILED, [
{ userId, receivedSignature: recovered },
{ userId, receivedSignature: recovered! },
]);
return recovered;
}),
Expand Down
21 changes: 10 additions & 11 deletions raiden-ts/tests/unit/epics/path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: [{ errorCode: 1337 }, { errors: 'No route' }],
details: [{ errorCode: 1337, errors: 'No route' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -925,10 +925,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: expect.arrayContaining([
{ errorCode: 2201 },
{ errors: 'No route between nodes found.' },
]),
details: [{ errorCode: 2201, errors: 'No route between nodes found.' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -975,7 +972,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_LAST_IOU_REQUEST_FAILED,
details: expect.arrayContaining([{ responseStatus: 500 }, { responseText: '{}' }]),
details: [{ responseStatus: 500, responseText: '{}' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -1031,8 +1028,10 @@ describe('PFS: pathFindServiceEpic', () => {
expect.objectContaining({
message: ErrorCodes.PFS_IOU_SIGNATURE_MISMATCH,
details: expect.arrayContaining([
{ signer: '0x9EE8539c8C7215AcAE56Fed72E7035a307e24989' },
{ address: '0x14791697260E4c9A71f18484C9f997B308e59325' },
{
signer: '0x9EE8539c8C7215AcAE56Fed72E7035a307e24989',
address: '0x14791697260E4c9A71f18484C9f997B308e59325',
},
]),
}),
{ tokenNetwork, target, value },
Expand Down Expand Up @@ -1101,13 +1100,13 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: expect.arrayContaining([
details: [
{
errors:
'The IOU is already claimed. Please start new session with different `expiration_block`.',
errorCode: 2105,
},
{ errorCode: 2105 },
]),
],
}),
{ tokenNetwork, target, value },
),
Expand Down

0 comments on commit c48b97a

Please sign in to comment.