Lints top-level test files (#1594)

* lint broadcastClient

* lint client

* fix most of connection

* remove unused files

* lint mockRippled

* lint mockRippledTest

* lint runClientTests

* lint setupClient

* lint setupClientWeb

* lint shamap

* lint testUtils

* resolve tsc issues

* Fix tests

* lint rest of connection

* respond to comments
This commit is contained in:
Mayukha Vadari
2021-09-07 14:25:39 -05:00
parent c8a2a6690b
commit 949cc031ee
44 changed files with 342 additions and 402 deletions

View File

@@ -3,15 +3,15 @@ import binary from 'ripple-binary-codec'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch } from '../testUtils'
const { combine: REQUEST_FIXTURES } = requests
const { combine: RESPONSE_FIXTURES } = responses
describe('client.combine', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('combine', async function () {
const combined = this.client.combine(REQUEST_FIXTURES.setDomain)

View File

@@ -1,10 +1,10 @@
import { assert } from 'chai'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
describe('client errors', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('XrplError with data', async function () {
const error = new this.client.errors.XrplError('_message_', '_data_')

View File

@@ -1,7 +1,7 @@
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import rippledAccountLines from '../fixtures/rippled/accountLines'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
/**
@@ -10,8 +10,8 @@ import { assertResultMatch, addressTests } from '../testUtils'
* - Check out "test/client/index.ts" for more information about the test runner.
*/
describe('getBalances', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,11 +1,11 @@
import { assert } from 'chai'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
describe('client.getFee', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('getFee', async function () {
this.mockRippled.addResponse('server_info', rippled.server_info.normal)

View File

@@ -4,7 +4,7 @@ import { BookOffersRequest } from '../../src'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { addressTests, assertResultMatch, assertRejects } from '../testUtils'
// import BigNumber from 'bignumber.js'
@@ -83,8 +83,8 @@ function xrpRippledResponse(request: BookOffersRequest): object {
}
describe('client.getOrderbook', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,7 +1,7 @@
import addresses from '../fixtures/addresses.json'
import requests from '../fixtures/requests'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertRejects } from '../testUtils'
// import responses from '../fixtures/responses'
const { getPaths: REQUEST_FIXTURES } = requests
@@ -15,8 +15,8 @@ const rippledResponse = rippled.path_find.generate.generateIOUPaymentPaths(
)
describe('client.getPaths', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
// 'simple test', function () {
// const response = await this.client.getPaths(REQUEST_FIXTURES.normal)
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToUsd, 'getPaths')

View File

@@ -1,13 +1,13 @@
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled/accountLines'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const { getTrustlines: RESPONSE_FIXTURES } = responses
describe('client.getTrustlines', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -2,11 +2,11 @@ import { assert } from 'chai'
import { Client } from '../../src'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
describe('client.hasNextPage', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('returns true when there is another page', async function () {
this.mockRippled.addResponse('ledger_data', rippled.ledger_data.first_page)

View File

@@ -1,10 +1,10 @@
import { assert } from 'chai'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
describe('client.isConnected', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('disconnect & isConnected', async function () {
assert.strictEqual(this.client.isConnected(), true)

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareCheckCancel', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareCheckCash', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareCheckCreate', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareEscrowCancellation', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -2,21 +2,14 @@ import addresses from '../fixtures/addresses.json'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
export const config = {
// TODO: The mock server right now returns a hard-coded string, no matter
// what "Account" value you pass. We'll need it to support more accurate
// responses before we can turn these tests on.
skipXAddress: true,
}
describe('client.prepareEscrowCreation', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('prepareEscrowCreation', async function () {
this.mockRippled.addResponse('server_info', rippled.server_info.normal)

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { addressTests, assertRejects, assertResultMatch } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareEscrowExecution', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareOrder', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareOrderCancellation', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -3,7 +3,7 @@ import { ValidationError } from 'xrpl-local/common/errors'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests, assertRejects } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
@@ -12,8 +12,8 @@ const { preparePayment: RESPONSE_FIXTURES } = responses
const RECIPIENT_ADDRESS = 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo'
describe('client.preparePayment', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -3,7 +3,7 @@ import { assert } from 'chai'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
@@ -11,8 +11,8 @@ const { preparePaymentChannelClaim: REQUEST_FIXTURES } = requests
const { preparePaymentChannelClaim: RESPONSE_FIXTURES } = responses
describe('client.preparePaymentChannelClaim', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -2,21 +2,14 @@ import addresses from '../fixtures/addresses.json'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
export const config = {
// TODO: The mock server right now returns a hard-coded string, no matter
// what "Account" value you pass. We'll need it to support more accurate
// responses before we can turn these tests on.
skipXAddress: true,
}
describe('client.preparePaymentChannelCreate', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('preparePaymentChannelCreate', async function () {
this.mockRippled.addResponse('server_info', rippled.server_info.normal)

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.preparePaymentChannelFund', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -4,14 +4,14 @@ import { FormattedSettings } from '../../src/common/types/objects'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareSettings', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,5 +1,5 @@
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
// import responses from '../fixtures/responses'
// import requests from '../fixtures/requests'
@@ -15,8 +15,8 @@ import { assertResultMatch, addressTests } from '../testUtils'
// const ADDRESS = 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo'
describe('client.prepareTicket', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -5,21 +5,14 @@ import { xrpToDrops, ISOTimeToRippleTime } from '../../src/utils'
import addresses from '../fixtures/addresses.json'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertRejects, assertResultMatch } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
export const config = {
// TODO: The mock server right now returns a hard-coded string, no matter
// what "Account" value you pass. We'll need it to support more accurate
// responses before we can turn these tests on.
skipXAddress: true,
}
describe('client.prepareTransaction', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('auto-fillable fields - does not overwrite Fee in txJSON', async function () {
this.mockRippled.addResponse('server_info', rippled.server_info.normal)

View File

@@ -1,14 +1,14 @@
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertResultMatch, addressTests } from '../testUtils'
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 }
describe('client.prepareTrustline', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -1,11 +1,11 @@
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { addressTests, assertResultMatch } from '../testUtils'
describe('client.request', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
addressTests.forEach(function (test) {
describe(test.type, function () {

View File

@@ -2,7 +2,7 @@ import { assert } from 'chai'
import { Client } from '../../src'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { assertRejects } from '../testUtils'
const rippledResponse = function (request: Request): object {
@@ -13,8 +13,8 @@ const rippledResponse = function (request: Request): object {
}
describe('client.requestNextPage', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('requests the next page', async function () {
this.mockRippled.addResponse('ledger_data', rippledResponse)
const response = await this.client.request({ command: 'ledger_data' })

View File

@@ -4,15 +4,15 @@ import binary from 'ripple-binary-codec'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
import { addressTests } from '../testUtils'
const { sign: REQUEST_FIXTURES } = requests
const { sign: RESPONSE_FIXTURES } = responses
describe('client.sign', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('sign', async function () {
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
const result = this.client.sign(REQUEST_FIXTURES.normal.txJSON, secret)

View File

@@ -1,11 +1,11 @@
import { assert } from 'chai'
import rippled from '../fixtures/rippled'
import setupClient from '../setupClient'
import { setupClient, teardownClient } from '../setupClient'
describe('Subscription', function () {
beforeEach(setupClient.setup)
afterEach(setupClient.teardown)
beforeEach(setupClient)
afterEach(teardownClient)
it('Successfully Subscribes', async function () {
this.mockRippled.addResponse('subscribe', rippled.subscribe.success)