refactor: move fixtures closer to tests (part 2) (#1561)

* move echo

* move fee

* move subscribe/unsubscribe

* move ledger_current

* move ledger_data

* move submit/submit_multisigned

* remove account_tx/account_offers/gateway_balances

* move account_info

* remove ledger_entry

* remove tx

* remove account_lines

* remove ripple_path_find

* remove ledger

* remove book_offers

* move ping

* remove global_config

* move test_command

* additional mock-rippled cleanup

* add explanatory comment to mock.addResponse
This commit is contained in:
Mayukha Vadari
2021-08-26 14:02:48 -04:00
parent f9fe5936b1
commit 09ef8595e7
31 changed files with 657 additions and 752 deletions

View File

@@ -2,10 +2,18 @@ import assert from 'assert-diff'
import { assertRejects, TestSuite } from '../testUtils'
import requests from '../fixtures/requests'
// import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import addresses from '../fixtures/addresses.json'
const {getPaths: REQUEST_FIXTURES} = requests
// const {getPaths: RESPONSE_FIXTURES} = responses
const rippledResponse = rippled.path_find.generate.generateIOUPaymentPaths(
0,
REQUEST_FIXTURES.normal.source.address,
REQUEST_FIXTURES.normal.destination.address,
REQUEST_FIXTURES.normal.destination.amount
)
/**
* Every test suite exports their tests in the default object.
* - Check out the "TestSuite" type for documentation on the interface.
@@ -38,7 +46,8 @@ export default <TestSuite>{
// const response = await client.getPaths(REQUEST_FIXTURES.XrpToXrp)
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToXrp, 'getPaths')
// },
'source with issuer': async (client) => {
'source with issuer': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths(REQUEST_FIXTURES.issuer),
client.errors.NotFoundError
@@ -50,36 +59,42 @@ export default <TestSuite>{
// client.errors.NotFoundError
// )
// },
'invalid PathFind': async (client) => {
'invalid PathFind': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
assert.throws(() => {
client.getPaths(REQUEST_FIXTURES.invalid)
}, /Cannot specify both source.amount/)
},
'does not accept currency': async (client) => {
'does not accept currency': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NotAcceptCurrency),
client.errors.NotFoundError
)
},
'no paths': async (client) => {
'no paths': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPaths),
client.errors.NotFoundError
)
},
'no paths source amount': async (client) => {
'no paths source amount': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPathsSource),
client.errors.NotFoundError
)
},
'no paths with source currencies': async (client) => {
'no paths with source currencies': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths(REQUEST_FIXTURES.NoPathsWithCurrencies),
client.errors.NotFoundError
)
},
'error: srcActNotFound': async (client) => {
'error: srcActNotFound': async (client, _, mockRippled) => {
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
return assertRejects(
client.getPaths({
...REQUEST_FIXTURES.normal,