Skip to content

Commit

Permalink
fix testcase names
Browse files Browse the repository at this point in the history
  • Loading branch information
onemicky committed Jun 11, 2024
1 parent 01b46e8 commit 4233559
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/lib/__tests__/getBestNonce.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ describe("getBestNonce", () => {
jest.spyOn(console, "error").mockImplementation(jest.fn());
});

test("Should resolve to the highest nonce from successful responses under timeout", async () => {
test("Case 1", async () => {
const providers: any[] = [new MockWallet(1, true, 100), new MockWallet(2, true, 200), new MockWallet(3, true, 300)];
const res = getBestNonce(providers);
jest.advanceTimersByTime(400);
expect(res).resolves.toBe(3);
});

test("Should resolve to the highest nonce from successful responses, excluding failed ones", async () => {
test("Case 2", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, true, 200),
Expand All @@ -49,7 +49,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(2);
});

test("Should resolve with the only successful response when others fail", async () => {
test("Case 3", async () => {
const providers: any[] = [
new MockWallet(1, false, 100),
new MockWallet(2, true, 200),
Expand All @@ -60,7 +60,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(2);
});

test("Should throw error when all providers fail", async () => {
test("Case 4", async () => {
const providers: any[] = [
new MockWallet(1, false, 100),
new MockWallet(2, false, 200),
Expand All @@ -73,7 +73,7 @@ describe("getBestNonce", () => {
});
});

test("Should resolve to the highest nonce under intermediate timeouts", async () => {
test("Case 5", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, true, 200),
Expand All @@ -86,7 +86,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(2);
});

test("Should resolve to the highest nonce even if later response is delayed", async () => {
test("Case 6", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, false, 900),
Expand All @@ -97,7 +97,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(3);
});

test("Should resolve to the first nonce if later responses fail", async () => {
test("Case 7", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, false, 900),
Expand All @@ -108,7 +108,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(1);
});

test("Should resolve to nonce from the provider that responds within timeout", async () => {
test("Case 8", async () => {
const providers: any[] = [
new MockWallet(1, false, 100),
new MockWallet(2, false, 200),
Expand All @@ -119,7 +119,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(3);
});

test("Should resolve to the first nonce when later providers fail", async () => {
test("Case 9", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, false, 300),
Expand All @@ -132,7 +132,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(1);
});

test("", async () => {
test("Case 10", async () => {
const providers: any[] = [
new MockWallet(1, true, 4000),
new MockWallet(2, true, 5800),
Expand All @@ -145,7 +145,7 @@ describe("getBestNonce", () => {
await await expect(res).resolves.toBe(1);
});

test("", async () => {
test("Case 11", async () => {
const providers: any[] = [
new MockWallet(1, true, 4900),
new MockWallet(2, true, 6100),
Expand All @@ -158,7 +158,7 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(1);
});

test("Should throw error when all providers respond past their timeout", async () => {
test("Case 12", async () => {
const providers: any[] = [
new MockWallet(1, true, 6000),
new MockWallet(2, true, 7000),
Expand All @@ -171,14 +171,14 @@ describe("getBestNonce", () => {
});
});

test("", async () => {
test("Case 13", async () => {
const providers: any[] = [new MockWallet(1, true, 100)];
const res = getBestNonce(providers);
jest.advanceTimersByTime(200);
expect(res).resolves.toBe(1);
});

test("", async () => {
test("Case 14", async () => {
const providers: any[] = [new MockWallet(1, true, 4900)];
const res = getBestNonce(providers);
jest.advanceTimersByTime(4950);
Expand All @@ -187,21 +187,21 @@ describe("getBestNonce", () => {
expect(res).resolves.toBe(1);
});

test("", async () => {
test("Case 15", async () => {
const providers: any[] = [new MockWallet(1, true, 100), new MockWallet(2, true, 200)];
const res = getBestNonce(providers);
jest.advanceTimersByTime(300);
expect(res).resolves.toBe(2);
});

test("", async () => {
test("Case 16", async () => {
const providers: any[] = [new MockWallet(1, true, 100), new MockWallet(2, true, 1000)];
const res = getBestNonce(providers);
jest.advanceTimersByTime(1100);
expect(res).resolves.toBe(2);
});

test("", async () => {
test("Case 17", async () => {
const providers: any[] = [
new MockWallet(1, true, 100),
new MockWallet(2, true, 200),
Expand Down

0 comments on commit 4233559

Please sign in to comment.