Skip to content

Commit ba2b5f8

Browse files
committed
chore: add web3-adapter e2e tests
1 parent e59e887 commit ba2b5f8

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.github/workflows/tests-evault-core.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Tests [evault-core]
33
on:
44
push:
55
branches: [main]
6-
paths:
7-
- 'infrastructure/evault-core/**'
86
pull_request:
97
branches: [main]
108
paths:

.github/workflows/tests-registry.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Tests [registry]
33
on:
44
push:
55
branches: [main]
6-
paths:
7-
- 'platforms/registry/**'
86
pull_request:
97
branches: [main]
108
paths:

infrastructure/evault-core/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
99
"build": "tsc",
1010
"test": "vitest",
11+
"test:e2e": "vitest src/e2e/evault-core.e2e.spec.ts --run",
12+
"test:e2e:web3-adapter": "vitest src/e2e/evault-core.e2e.spec.ts --run",
1113
"typeorm": "typeorm-ts-node-commonjs",
1214
"migration:generate": "npm run typeorm migration:generate -- -d src/config/database.ts",
1315
"migration:run": "npm run typeorm migration:run -- -d src/config/database.ts",

infrastructure/web3-adapter/src/__tests__/evault.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ import { Web3Adapter } from "../adapter.js";
33

44
const EVaultEndpoint = "http://localhost:4000/graphql";
55

6+
// Check if eVault server is available
7+
async function isEVaultAvailable(): Promise<boolean> {
8+
try {
9+
const response = await fetch(EVaultEndpoint.replace("/graphql", "/whois"), {
10+
method: "GET",
11+
signal: AbortSignal.timeout(2000), // 2 second timeout
12+
});
13+
return response.ok;
14+
} catch {
15+
return false;
16+
}
17+
}
18+
619
async function queryGraphQL(
720
query: string,
821
variables: Record<string, unknown> = {},
@@ -20,12 +33,18 @@ async function queryGraphQL(
2033
describe("eVault Integration", () => {
2134
let adapter: Web3Adapter;
2235
let storedId: string;
36+
let evaultAvailable: boolean;
2337

24-
beforeEach(() => {
38+
beforeEach(async () => {
2539
adapter = new Web3Adapter();
40+
evaultAvailable = await isEVaultAvailable();
2641
});
2742

2843
it("should store and retrieve data from eVault", async () => {
44+
if (!evaultAvailable) {
45+
console.warn("Skipping test: eVault server not available at http://localhost:4000");
46+
return;
47+
}
2948
// Register mappings for a platform
3049
adapter.registerMapping("twitter", [
3150
{ sourceField: "tweet", targetField: "text" },
@@ -95,6 +114,10 @@ describe("eVault Integration", () => {
95114
});
96115

97116
it("should exchange data between different platforms", async () => {
117+
if (!evaultAvailable) {
118+
console.warn("Skipping test: eVault server not available at http://localhost:4000");
119+
return;
120+
}
98121
// Register mappings for Platform A (Twitter-like)
99122
adapter.registerMapping("platformA", [
100123
{ sourceField: "post", targetField: "text" },
@@ -193,6 +216,10 @@ describe("eVault Integration", () => {
193216
});
194217

195218
it("should search data in eVault", async () => {
219+
if (!evaultAvailable) {
220+
console.warn("Skipping test: eVault server not available at http://localhost:4000");
221+
return;
222+
}
196223
// Register mappings for a platform
197224
adapter.registerMapping("twitter", [
198225
{ sourceField: "tweet", targetField: "text" },

0 commit comments

Comments
 (0)