mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-30 09:05:50 +00:00
test: removes the use of TestSuite (#1566)* switch all methods to new format* clean up rippleClient* rename files to remove ripple from name* additional cleanup
This commit is contained in:
@@ -1,65 +1,70 @@
|
||||
import { assert } from "chai";
|
||||
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite } from "../testUtils";
|
||||
import setupClient from "../setupClient";
|
||||
import { addressTests } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
async getFee(client, address, mockRippled) {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
describe("client.getFee", function () {
|
||||
beforeEach(setupClient.setup);
|
||||
afterEach(setupClient.teardown);
|
||||
|
||||
"getFee default": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
client._feeCushion = undefined as unknown as number;
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
addressTests.forEach(function (test) {
|
||||
describe(test.type, function () {
|
||||
it("getFee", async function () {
|
||||
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
});
|
||||
|
||||
"getFee - high load_factor": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.highLoadFactor);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "2");
|
||||
},
|
||||
it("getFee default", async function () {
|
||||
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
this.client._feeCushion = undefined as unknown as number;
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
});
|
||||
|
||||
"getFee - high load_factor with custom maxFeeXRP": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.highLoadFactor);
|
||||
// Ensure that overriding with high maxFeeXRP of '51540' causes no errors.
|
||||
// (fee will actually be 51539.607552)
|
||||
client._maxFeeXRP = "51540";
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "51539.607552");
|
||||
},
|
||||
it("getFee - high load_factor", async function () {
|
||||
this.mockRippled.addResponse(
|
||||
"server_info",
|
||||
rippled.server_info.highLoadFactor
|
||||
);
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "2");
|
||||
});
|
||||
|
||||
"getFee custom cushion": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
client._feeCushion = 1.4;
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000014");
|
||||
},
|
||||
it("getFee - high load_factor with custom maxFeeXRP", async function () {
|
||||
this.mockRippled.addResponse(
|
||||
"server_info",
|
||||
rippled.server_info.highLoadFactor
|
||||
);
|
||||
// Ensure that overriding with high maxFeeXRP of '51540' causes no errors.
|
||||
// (fee will actually be 51539.607552)
|
||||
this.client._maxFeeXRP = "51540";
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "51539.607552");
|
||||
});
|
||||
|
||||
// This is not recommended since it may result in attempting to pay
|
||||
// less than the base fee. However, this test verifies the existing behavior.
|
||||
"getFee cushion less than 1.0": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
client._feeCushion = 0.9;
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000009");
|
||||
},
|
||||
it("getFee custom cushion", async function () {
|
||||
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
this.client._feeCushion = 1.4;
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "0.000014");
|
||||
});
|
||||
|
||||
"getFee reporting": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
};
|
||||
// This is not recommended since it may result in attempting to pay
|
||||
// less than the base fee. However, this test verifies the existing behavior.
|
||||
it("getFee cushion less than 1.0", async function () {
|
||||
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
this.client._feeCushion = 0.9;
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "0.000009");
|
||||
});
|
||||
|
||||
it("getFee reporting", async function () {
|
||||
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
|
||||
const fee = await this.client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user