refactor: improves mock rippled structure (#1569)

* better error handling + tests

* fix tests

* change addResponse to take a string instead of a Request

* remove unneeded change

* respond to comments

* fix tests, re-lint

* improve error message
This commit is contained in:
Mayukha Vadari
2021-08-27 10:17:39 -04:00
parent 759e075e54
commit b8be6c2f1b
30 changed files with 763 additions and 2110 deletions

View File

@@ -48,7 +48,7 @@ export default <TestSuite>{
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToXrp, 'getPaths')
// },
"source with issuer": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths(REQUEST_FIXTURES.issuer),
client.errors.NotFoundError
@@ -61,41 +61,41 @@ export default <TestSuite>{
// )
// },
"invalid PathFind": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
assert.throws(() => {
client.getPaths(REQUEST_FIXTURES.invalid);
}, /Cannot specify both source.amount/);
},
"does not accept currency": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NotAcceptCurrency),
client.errors.NotFoundError
);
},
"no paths": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPaths),
client.errors.NotFoundError
);
},
"no paths source amount": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPathsSource),
client.errors.NotFoundError
);
},
"no paths with source currencies": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPathsWithCurrencies),
client.errors.NotFoundError
);
},
"error: srcActNotFound": async (client, _, mockRippled) => {
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
mockRippled.addResponse("ripple_path_find", rippledResponse);
return assertRejects(
client.getPaths({
...REQUEST_FIXTURES.normal,