Skip to content

Commit

Permalink
Merge pull request #197 from ar-io/type-fix
Browse files Browse the repository at this point in the history
fix(types): correct totalEpochCount for gateway stats
  • Loading branch information
dtfiedler authored Sep 16, 2024
2 parents 48131fa + 37f07a1 commit 32519dc
Show file tree
Hide file tree
Showing 10 changed files with 1,240 additions and 37 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"rimraf": "^5.0.1",
"semantic-release": "^21.0.7",
"sinon": "^15.2.0",
"testcontainers": "^10.13.1",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
Expand Down
2 changes: 1 addition & 1 deletion src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export type AoGateway = {
export type AoGatewayStats = {
passedConsecutiveEpochs: number;
failedConsecutiveEpochs: number;
totalEpochParticipationCount: number;
totalEpochCount: number;
passedEpochCount: number;
failedEpochCount: number;
observedEpochCount: number;
Expand Down
20 changes: 18 additions & 2 deletions tests/e2e/cjs/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { describe, it, before } = require('node:test');
const { describe, it, before, after } = require('node:test');
const { DockerComposeEnvironment, Wait } = require('testcontainers');
const assert = require('node:assert/strict');
const fs = require('node:fs');
/**
Expand All @@ -19,6 +20,7 @@ const {
} = require('@ar.io/sdk');
const { connect } = require('@permaweb/aoconnect');

const projectRootPath = process.cwd();
const testWalletJSON = fs.readFileSync('../test-wallet.json', {
encoding: 'utf-8',
});
Expand All @@ -32,12 +34,26 @@ const io = IO.init({
process: new AOProcess({
processId: process.env.IO_PROCESS_ID || ioDevnetProcessId,
ao: connect({
CU_URL: process.env.AO_CU_URL || 'https://cu.ao-testnet.xyz',
CU_URL: 'http://localhost:6363',
}),
}),
});

describe('IO', async () => {
let compose;
before(async () => {
compose = await new DockerComposeEnvironment(
projectRootPath,
'../docker-compose.test.yml',
)
.withBuild()
.withWaitStrategy('ao-cu-1', Wait.forHttp('/', 6363))
.up(['ao-cu']);
});

after(async () => {
await compose.down();
});
it('should be able to get the process information', async () => {
const epoch = await io.getInfo();
assert.ok(epoch);
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
ao-cu:
image: ghcr.io/permaweb/ao-cu:latest
restart: on-failure
volumes:
- ${CU_WALLET_FILE:-./test-wallet.json}:/usr/app/test-wallet.json
ports:
- ${CU_PORT:-6363}:${CU_PORT:-6363}
environment:
PORT: ${CU_PORT:-6363}
WALLET_FILE: ${CU_WALLET_FILE:-./test-wallet.json}
NODE_CONFIG_ENV: ${NODE_CONFIG_ENV:-development}
NODE_HEAPDUMP_OPTIONS: ${NODE_HEAPDUMP_OPTIONS:-nosignal}
PROCESS_CHECKPOINT_TRUSTED_OWNERS: ${PROCESS_CHECKPOINT_TRUSTED_OWNERS:-fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY}
GRAPHQL_URL: ${GRAPHQL_URL:-https://arweave-search.goldsky.com/graphql}
CHECKPOINT_GRAPHQL_URL: ${CHECKPOINT_GRAPHQL_URL:-https://arweave-search.goldsky.com/graphql}
DISABLE_PROCESS_CHECKPOINT_CREATION: ${DISABLE_PROCESS_CHECKPOINT_CREATION:-true}
21 changes: 19 additions & 2 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import {
import { connect } from '@permaweb/aoconnect';
import { strict as assert } from 'node:assert';
import fs from 'node:fs';
import { describe, it } from 'node:test';
import { after, before, describe, it } from 'node:test';
import { DockerComposeEnvironment, Wait } from 'testcontainers';

const projectRootPath = process.cwd();
const testWalletJSON = fs.readFileSync('../test-wallet.json', {
encoding: 'utf-8',
});
Expand All @@ -34,12 +36,27 @@ const io = IO.init({
process: new AOProcess({
processId: ioDevnetProcessId,
ao: connect({
CU_URL: process.env.AO_CU_URL || 'https://cu.ao-testnet.xyz',
CU_URL: 'http://localhost:6363',
}),
}),
});

describe('IO', async () => {
let compose;
before(async () => {
compose = await new DockerComposeEnvironment(
projectRootPath,
'../docker-compose.test.yml',
)
.withBuild()
.withWaitStrategy('ao-cu-1', Wait.forHttp('/', 6363))
.up(['ao-cu']);
});

after(async () => {
await compose.down();
});

it('should be able to get the process information', async () => {
const epoch = await io.getInfo();
assert.ok(epoch);
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.2.1",
"jsdom": "^24.1.0",
"testcontainers": "^10.13.1",
"typescript": "^4.9.5",
"vite": "^5.2.10",
"vitest": "^1.6.0",
"vite-plugin-node-polyfills": "^0.22.0"
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^1.6.0"
},
"scripts": {
"start": "vite --config vite.config.js",
Expand Down
15 changes: 14 additions & 1 deletion tests/e2e/web/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import '@testing-library/jest-dom';
import { act, render, screen, waitFor } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { DockerComposeEnvironment, Wait } from 'testcontainers';
import { beforeAll, describe, expect, it } from 'vitest';

import App from './App';

const projectRootPath = process.cwd();

describe('ESM browser validation', () => {
let compose;
beforeAll(async () => {
compose = await new DockerComposeEnvironment(
projectRootPath,
'../docker-compose.test.yml',
)
.withBuild()
.withWaitStrategy('ao-cu-1', Wait.forHttp('/', 6363))
.up(['ao-cu']);
});
it('should load the app and SDK', async () => {
await act(async () => render(<App />));

Expand Down
18 changes: 14 additions & 4 deletions tests/e2e/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { ANTRegistry, AOProcess, IO, ioDevnetProcessId } from '@ar.io/sdk/web';
import {
ANTRegistry,
ANT_REGISTRY_ID,
AOProcess,
IO,
ioDevnetProcessId,
} from '@ar.io/sdk/web';
import { connect } from '@permaweb/aoconnect';
import { useEffect, useState } from 'react';
import Markdown from 'react-markdown';
Expand All @@ -10,7 +16,7 @@ const io = IO.init({
process: new AOProcess({
processId: process.env.IO_PROCESS_ID || ioDevnetProcessId,
ao: connect({
CU_URL: process.env.AO_CU_URL || 'https://cu.ao-testnet.xyz',
CU_URL: 'http://localhost:6363',
}),
}),
});
Expand All @@ -21,6 +27,7 @@ function App() {
const [ioContractSuccess, setIoContractSuccess] = useState<boolean>(false);
const [antRegistrySuccess, setAntRegistrySuccess] = useState<boolean>(false);
const [loaded, setLoaded] = useState<boolean>(false);
const [registryLoaded, setRegistryLoaded] = useState<boolean>(false);

useEffect(() => {
io.getInfo()
Expand All @@ -38,7 +45,7 @@ function App() {
});
antRegistry
.accessControlList({
address: '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk',
address: ANT_REGISTRY_ID,
})
.then((affiliatedAnts: { Owned: string[]; Controlled: string[] }) => {
setAnts(`\`\`\`json\n${JSON.stringify(affiliatedAnts, null, 2)}`);
Expand All @@ -48,6 +55,9 @@ function App() {
console.error(error);
setAntRegistrySuccess(false);
setAnts('Error loading affiliated ants');
})
.finally(() => {
setRegistryLoaded(true);
});
}, []);

Expand All @@ -61,7 +71,7 @@ function App() {
{contract}
</Markdown>
</div>
{loaded && (
{registryLoaded && (
<div data-testid="load-registry-result">{`${antRegistrySuccess}`}</div>
)}
<Markdown className="markdown" remarkPlugins={[remarkGfm]}>
Expand Down
Loading

0 comments on commit 32519dc

Please sign in to comment.