Skip to content

Commit

Permalink
fix(types): update type and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored and dtfiedler committed Sep 25, 2024
1 parent 7b3909f commit 877b03f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 89 deletions.
71 changes: 11 additions & 60 deletions src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,67 +66,18 @@ export type EpochInput =

// AO/IO Contract
export type AoBalances = Record<WalletAddress, number>;
export type AoFees = Record<string, number>;

export type AoArNSNameLengths =
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
| 28
| 29
| 30
| 31
| 32
| 33
| 34
| 35
| 36
| 37
| 38
| 39
| 40
| 41
| 42
| 43
| 44
| 45
| 46
| 47
| 48
| 49
| 50
| 51;
export type AoRegistrationFeeList = Record<
1 | 2 | 3 | 4 | 5 | 'permabuy',
number
>;
const nameLengthArray = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
] as const;
const leaseLengthArray = [1, 2, 3, 4, 5] as const;
export type AoRegistrationFees = Record<
AoArNSNameLengths,
AoRegistrationFeeList
(typeof nameLengthArray)[number],
{
lease: Record<(typeof leaseLengthArray)[number], number>;
permabuy: number;
}
>;
export type AoObservations = Record<number, AoEpochObservationData>;
export type AoEpochIndex = number;
Expand Down
13 changes: 7 additions & 6 deletions tests/e2e/cjs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,13 @@ describe('IO', async () => {
assert(registrationFees);
assert.equal(Object.keys(registrationFees).length, 51);
for (const nameLength of Object.keys(registrationFees)) {
assert(registrationFees[nameLength]['1']);
assert(registrationFees[nameLength]['2']);
assert(registrationFees[nameLength]['3']);
assert(registrationFees[nameLength]['4']);
assert(registrationFees[nameLength]['5']);
assert(registrationFees[nameLength]['permabuy']);
// assert lease is length of 5
assert(registrationFees[nameLength]['lease']['1'] > 0);
assert(registrationFees[nameLength]['lease']['2'] > 0);
assert(registrationFees[nameLength]['lease']['3'] > 0);
assert(registrationFees[nameLength]['lease']['4'] > 0);
assert(registrationFees[nameLength]['lease']['5'] > 0);
assert(registrationFees[nameLength]['permabuy'] > 0);
}
});
it('should be able to create IOWriteable with valid signers', async () => {
Expand Down
13 changes: 7 additions & 6 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ describe('IO', async () => {
assert(registrationFees);
assert.equal(Object.keys(registrationFees).length, 51);
for (const nameLength of Object.keys(registrationFees)) {
assert(registrationFees[nameLength]['1']);
assert(registrationFees[nameLength]['2']);
assert(registrationFees[nameLength]['3']);
assert(registrationFees[nameLength]['4']);
assert(registrationFees[nameLength]['5']);
assert(registrationFees[nameLength]['permabuy']);
// assert lease is length of 5
assert(registrationFees[nameLength]['lease']['1'] > 0);
assert(registrationFees[nameLength]['lease']['2'] > 0);
assert(registrationFees[nameLength]['lease']['3'] > 0);
assert(registrationFees[nameLength]['lease']['4'] > 0);
assert(registrationFees[nameLength]['lease']['5'] > 0);
assert(registrationFees[nameLength]['permabuy'] > 0);
}
});

Expand Down
17 changes: 0 additions & 17 deletions tests/e2e/web/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,4 @@ describe('ESM browser validation', () => {
const result = screen.getByTestId('load-registry-result');
expect(result).toHaveTextContent('true');
});

it('should retrieve registration fees', async () => {
await act(async () => render(<App />));

await waitFor(
() => {
screen.getByTestId('load-registration-fees-result');
},
{
interval: 5_000,
timeout: 60_000,
},
);

const result = screen.getByTestId('load-registration-fees-result');
expect(result).toHaveTextContent('true');
});
});

0 comments on commit 877b03f

Please sign in to comment.