Skip to content

Commit aa59b63

Browse files
authored
Merge pull request #10 from ChainSafe/submoduleIntegrationTest
Setup for integration tests, CI, open-creator-rails submodule
2 parents fc7755e + 1d72026 commit aa59b63

22 files changed

+3933
-245
lines changed

.github/workflows/ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
CI:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: "npm"
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Run lint
29+
run: npm run lint
30+
31+
build:
32+
name: Build
33+
runs-on: ubuntu-latest
34+
needs: CI
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
submodules: recursive
40+
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: "npm"
46+
47+
- name: Install dependencies
48+
run: npm ci
49+
50+
- name: Run build
51+
run: npm run build
52+
53+
test:
54+
name: Test (Vitest)
55+
runs-on: ubuntu-latest
56+
needs: CI
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
with:
61+
submodules: recursive
62+
63+
- name: Setup Node
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 20
67+
cache: "npm"
68+
69+
- name: Install dependencies
70+
run: npm ci
71+
72+
- name: Run tests
73+
run: npm test
74+
75+
integration:
76+
name: Integration Tests (Anvil + Forge)
77+
runs-on: ubuntu-latest
78+
needs: build
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v4
82+
with:
83+
submodules: recursive
84+
85+
- name: Setup Node
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: 20
89+
cache: "npm"
90+
91+
- name: Install dependencies
92+
run: npm ci
93+
94+
- name: Install Foundry
95+
uses: foundry-rs/foundry-toolchain@v1
96+
with:
97+
version: "stable"
98+
cache: true
99+
100+
- name: Run integration tests
101+
run: |
102+
export PATH="$HOME/.foundry/bin:$HOME/.cargo/bin:$PATH"
103+
anvil --version
104+
forge --version
105+
npm run test:integration
106+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ pnpm-debug.log*
2121

2222
# misc
2323
*.tsbuildinfo
24+
25+
act.tgz

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "open-creator-rails"]
2+
path = open-creator-rails
3+
url = https://github.com/ChainSafe/open-creator-rails.git

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,57 @@ const sdk = createOcrSdk({
3636
});
3737
```
3838

39+
## Local Node (Anvil) + SDK Testing
40+
41+
This SDK can be tested end-to-end against a local Anvil chain using the contracts from the `open-creator-rails` submodule.
42+
43+
### Prerequisites
44+
1. Install Foundry (provides `anvil` + `forge`).
45+
2. Initialize the contracts submodule:
46+
```bash
47+
git submodule update --init --recursive
48+
```
49+
50+
### Run integration tests (recommended)
51+
These tests start Anvil, deploy `TestToken` and `AssetRegistry`, run `subscribe`/`getSubscriptionStatus`, advance time, and then run `claimCreatorFee`.
52+
53+
```bash
54+
npm run test:integration
55+
```
56+
57+
### Manual debugging (optional)
58+
Start Anvil on the default port:
59+
```bash
60+
anvil --chain-id 31337 --port 8545
61+
```
62+
63+
Then point your SDK clients at it (as shown in the `Usage` section above) by setting:
64+
```bash
65+
export RPC_URL=http://127.0.0.1:8545
66+
```
67+
68+
## Maintenance
69+
70+
### Updating the `open-creator-rails` submodule
71+
This repo includes `open-creator-rails` as a git submodule (used for contract ABIs + deployment JSON). When upstream `main` changes, update the submodule and commit the new submodule SHA (the gitlink) in this repo.
72+
73+
#### Recommended update workflow
74+
1. Ensure submodules are initialized:
75+
```bash
76+
git submodule update --init --recursive
77+
```
78+
79+
2. Update the submodule to the newest remote commit:
80+
```bash
81+
git submodule update --remote --merge open-creator-rails
82+
```
83+
84+
3. Commit the updated gitlink SHA in this repository:
85+
```bash
86+
git status
87+
git add open-creator-rails
88+
git commit -m "chore: update open-creator-rails submodule"
89+
```
90+
3991

4092

eslint.config.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import js from "@eslint/js";
2+
import tseslint from "@typescript-eslint/eslint-plugin";
3+
import tsParser from "@typescript-eslint/parser";
4+
5+
export default [
6+
{
7+
ignores: ["dist/**", "node_modules/**", "open-creator-rails/**"],
8+
},
9+
js.configs.recommended,
10+
{
11+
files: ["**/*.ts"],
12+
languageOptions: {
13+
parser: tsParser,
14+
sourceType: "module",
15+
ecmaVersion: "latest",
16+
globals: {
17+
// Node 18+ global fetch (our SDK uses `fetch` in Node/ESM).
18+
fetch: "readonly",
19+
20+
// Node globals used by integration tests.
21+
process: "readonly",
22+
setTimeout: "readonly",
23+
setInterval: "readonly",
24+
clearTimeout: "readonly",
25+
clearInterval: "readonly",
26+
27+
// Vitest globals used in tests.
28+
describe: "readonly",
29+
it: "readonly",
30+
expect: "readonly",
31+
vi: "readonly",
32+
beforeEach: "readonly",
33+
beforeAll: "readonly",
34+
afterAll: "readonly",
35+
test: "readonly",
36+
},
37+
},
38+
plugins: {
39+
"@typescript-eslint": tseslint,
40+
},
41+
rules: {
42+
...tseslint.configs.recommended.rules,
43+
44+
// This repo uses `as any` in mocks/test doubles.
45+
"@typescript-eslint/no-explicit-any": "off",
46+
47+
// Type assertions are used for hex/address branded types.
48+
"@typescript-eslint/consistent-type-assertions": "off",
49+
"@typescript-eslint/no-unsafe-assignment": "off",
50+
"@typescript-eslint/no-unsafe-call": "off",
51+
"@typescript-eslint/no-unsafe-member-access": "off",
52+
},
53+
},
54+
];
55+

open-creator-rails

Submodule open-creator-rails added at 220514b

0 commit comments

Comments
 (0)