Skip to content

Commit

Permalink
Add remote integration test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony1060 committed Jan 18, 2024
1 parent 534d1d5 commit d1944b0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 79 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prod_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
schedule:
- cron: "0 0 * * *"
workflow_call:

jobs:
test:
name: Test ENState 🚀
runs-on: arc-runner-set
strategy:
fail-fast: false
matrix:
suite: [enstate.rs, worker.enstate.rs]
steps:
- run: bun install
working-directory: test

- name: Test
run: bun test remote --rerun-each 2
env:
REMOTE_URL: https://${{ matrix.suite }}
working-directory: test
4 changes: 2 additions & 2 deletions server/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#[allow(non_snake_case)]
pub mod IResolver {
use ethers::prelude::abigen;

abigen!(Resolver, "./src/abi/resolver.json");
}

// Universal Resolver (0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62)
#[allow(non_snake_case)]
pub mod UResolver {
use ethers::prelude::abigen;

abigen!(UniversalResolver, "./src/abi/universal_resolver.json");
}
4 changes: 2 additions & 2 deletions shared/src/models/universal_resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abigen!(
);

const MAGIC_UNIVERSAL_RESOLVER_ERROR_MESSAGE: &str =
"execution reverted: UniversalResolver: Wildcard on non-extended resolvers is not supported";
"UniversalResolver: Wildcard on non-extended resolvers is not supported";

pub async fn resolve_universal(
name: &str,
Expand Down Expand Up @@ -73,7 +73,7 @@ pub async fn resolve_universal(
return ProfileError::RPCError(provider_error);
};

if matches!(rpc_err.as_error_response(), Some(rpc_err_raw) if rpc_err_raw.message == MAGIC_UNIVERSAL_RESOLVER_ERROR_MESSAGE) {
if matches!(rpc_err.as_error_response(), Some(rpc_err_raw) if rpc_err_raw.code == 3 && rpc_err_raw.message.contains(MAGIC_UNIVERSAL_RESOLVER_ERROR_MESSAGE)) {
return ProfileError::NotFound;
}

Expand Down
36 changes: 35 additions & 1 deletion test/src/test_implementation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { describe, expect, test } from 'bun:test';

import { Dataset } from '../data';
import {
Dataset,
dataset_address_bulk,
dataset_address_single,
dataset_name_bulk,
dataset_name_single,
dataset_universal_bulk,
dataset_universal_single,
} from '../data';
import { http_fetch } from './http_fetch';

export const test_implementation = <DataSet extends Dataset<DataType>, DataType extends {}>(
function_name: string,
Expand All @@ -17,3 +26,28 @@ export const test_implementation = <DataSet extends Dataset<DataType>, DataType
}
});
};

export const describe_for = (prefix: string, base_url: string) => {
test_implementation(`${prefix}/name`, http_fetch(`${base_url}/n/`), dataset_name_single);
test_implementation(`${prefix}/address`, http_fetch(`${base_url}/a/`), dataset_address_single);
test_implementation(
`${prefix}/universal`,
http_fetch(`${base_url}/u/`),
dataset_universal_single
);
test_implementation(
`${prefix}/bulk/name`,
http_fetch(`${base_url}/bulk/n?`),
dataset_name_bulk
);
test_implementation(
`${prefix}/bulk/address`,
http_fetch(`${base_url}/bulk/a?`),
dataset_address_bulk
);
test_implementation(
`${prefix}/bulk/universal`,
http_fetch(`${base_url}/bulk/u?`),
dataset_universal_bulk
);
};
5 changes: 5 additions & 0 deletions test/tests/remote.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { describe_for } from '../src/test_implementation';

const url = process.env.REMOTE_URL ?? 'https://enstate.rs';

describe_for(`remote (${url})`, url);
39 changes: 2 additions & 37 deletions test/tests/server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Subprocess } from 'bun';
import { afterAll, beforeAll } from 'bun:test';

import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data';
import {
dataset_address_single,
dataset_name_single,
dataset_universal_single,
} from '../data/single';
import { http_fetch } from '../src/http_fetch';
import { test_implementation } from '../src/test_implementation';
import { describe_for } from '../src/test_implementation';

const TEST_RELEASE = true;

Expand Down Expand Up @@ -57,32 +50,4 @@ afterAll(async () => {
server?.kill();
});

const PREFIX = 'server';

test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single);
test_implementation(
`${PREFIX}/address`,
http_fetch('http://0.0.0.0:3000/a/'),
dataset_address_single
);
test_implementation(
`${PREFIX}/universal`,
http_fetch('http://0.0.0.0:3000/u/'),
dataset_universal_single
);

test_implementation(
`${PREFIX}/bulk/name`,
http_fetch('http://0.0.0.0:3000/bulk/n?'),
dataset_name_bulk
);
test_implementation(
`${PREFIX}/bulk/address`,
http_fetch('http://0.0.0.0:3000/bulk/a?'),
dataset_address_bulk
);
test_implementation(
`${PREFIX}/bulk/universal`,
http_fetch('http://0.0.0.0:3000/bulk/u?'),
dataset_universal_bulk
);
describe_for('server', 'http://127.0.0.1:3000');
39 changes: 2 additions & 37 deletions test/tests/worker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Subprocess } from 'bun';
import { afterAll, beforeAll } from 'bun:test';

import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data';
import {
dataset_address_single,
dataset_name_single,
dataset_universal_single,
} from '../data/single';
import { http_fetch } from '../src/http_fetch';
import { test_implementation } from '../src/test_implementation';
import { describe_for } from '../src/test_implementation';

let server: Subprocess<'ignore', 'pipe', 'inherit'> | undefined;

Expand Down Expand Up @@ -44,32 +37,4 @@ afterAll(async () => {
await server?.exited;
});

const PREFIX = 'worker';

test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single);
test_implementation(
`${PREFIX}/address`,
http_fetch('http://0.0.0.0:3000/a/'),
dataset_address_single
);
test_implementation(
`${PREFIX}/universal`,
http_fetch('http://0.0.0.0:3000/u/'),
dataset_universal_single
);

test_implementation(
`${PREFIX}/bulk/name`,
http_fetch('http://0.0.0.0:3000/bulk/n?'),
dataset_name_bulk
);
test_implementation(
`${PREFIX}/bulk/address`,
http_fetch('http://0.0.0.0:3000/bulk/a?'),
dataset_address_bulk
);
test_implementation(
`${PREFIX}/bulk/universal`,
http_fetch('http://0.0.0.0:3000/bulk/u?'),
dataset_universal_bulk
);
describe_for('worker', 'http://127.0.0.1:3000');

0 comments on commit d1944b0

Please sign in to comment.