Skip to content

Commit f848c3d

Browse files
committed
test: deployment blocks for indexed contracts
1 parent f7121c0 commit f848c3d

File tree

6 files changed

+72
-29
lines changed

6 files changed

+72
-29
lines changed

TODOs.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Priority 1
22

33
- [ ] Add instructions in the README
4-
- [ ] Consider what to do with `admin` and `fee`
54
- [ ] Refactor `data` broadcasts to get rid of `mainnets` and `testnets` dichotomy
65

76
# Priority 2
87

9-
- [ ] Test to ensure that all indexed contracts have a deployment block
108
- [ ] Check why Sophon tests don't work
119
- [ ] Add just script for printing available chain names
1210
- [ ] Add `@unimplemented` tag for `compilerSettings`

biome.jsonc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
},
77
"overrides": [
88
{
9-
"includes": ["**/{scripts,tests}/**/*.ts"],
9+
"includes": ["**/tests/**/*.ts"],
1010
"linter": {
1111
"rules": {
12-
"suspicious": {
13-
"noFocusedTests": "off"
12+
"style": {
13+
"noNonNullAssertion": "off"
1414
}
1515
}
1616
}

tests/contracts.test.ts renamed to tests/contracts/catalog.test.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,8 @@ import queries from "@src/queries";
33
import { releases, releasesByVersion } from "@src/releases";
44
import axios from "axios";
55
import _ from "lodash";
6-
import { isAddress } from "viem";
76
import { describe, expect, it } from "vitest";
8-
import etherscanChainIds from "./setup/etherscan";
9-
10-
/**
11-
* @note Use https://ethsum.netlify.app to fix failing tests
12-
*/
13-
describe("Address checksums", () => {
14-
for (const release of releases) {
15-
describe(`${release.protocol} ${release.version}`, () => {
16-
const contracts = queries.contracts.getAll({ release });
17-
if (!contracts) {
18-
logAndThrow({ msg: "No contracts found", release });
19-
}
20-
21-
for (const contract of contracts) {
22-
it(`${contract.name} should have a checksummed address`, () => {
23-
const message = `Found non-checksummed address: ${contract.address}`;
24-
expect(isAddress(contract.address), message).toBe(true);
25-
});
26-
}
27-
});
28-
}
29-
});
7+
import etherscanChainIds from "../setup/etherscan";
308

319
describe("Contract catalog", () => {
3210
const releasesToTest = [

tests/contracts/checksums.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import queries from "@src/queries";
2+
import { releases } from "@src/releases";
3+
import { isAddress } from "viem";
4+
import { describe, expect, it } from "vitest";
5+
6+
/**
7+
* @note Use https://ethsum.netlify.app to fix failing tests
8+
*/
9+
describe("Address checksums", () => {
10+
for (const release of releases) {
11+
describe(`${release.protocol} ${release.version}`, () => {
12+
const contracts = queries.contracts.getAll({ release })!;
13+
14+
for (const contract of contracts) {
15+
it(`${contract.name} should have a checksummed address`, () => {
16+
const errorMsg = `Found non-checksummed address: ${contract.address}`;
17+
expect(isAddress(contract.address), errorMsg).toBe(true);
18+
});
19+
}
20+
});
21+
}
22+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
import { names } from "@src/contracts";
3+
import { Protocol } from "@src/enums";
4+
import queries from "@src/queries";
5+
import { releases } from "@src/releases";
6+
import type { Sablier } from "@src/types";
7+
import { describe, expect, it } from "vitest";
8+
9+
// These contracts are indexed by the Sablier Indexers, so they require a deployment block number.
10+
// See https://github.com/sablier-labs/indexers
11+
const INDEXED: Record<Sablier.Protocol, string[]> = {
12+
[Protocol.Airdrops]: [
13+
names.SABLIER_MERKLE_FACTORY,
14+
names.SABLIER_V2_MERKLE_LOCKUP_FACTORY,
15+
names.SABLIER_V2_MERKLE_STREAMER_FACTORY,
16+
],
17+
[Protocol.Flow]: [names.SABLIER_FLOW],
18+
[Protocol.Legacy]: [],
19+
[Protocol.Lockup]: [
20+
names.SABLIER_V2_LOCKUP_LINEAR,
21+
names.SABLIER_V2_LOCKUP_DYNAMIC,
22+
names.SABLIER_V2_LOCKUP_TRANCHED,
23+
names.SABLIER_LOCKUP,
24+
],
25+
};
26+
27+
describe("Deployment blocks", () => {
28+
for (const release of releases) {
29+
describe(`${release.protocol} ${release.version}`, () => {
30+
const contracts = queries.contracts.getAll({ release })!;
31+
32+
for (const contract of contracts) {
33+
if (!INDEXED[release.protocol].includes(contract.name)) {
34+
it.skip(`Skipped ${contract.name} because it's not an indexed contract.`, () => {});
35+
continue;
36+
}
37+
38+
it(`${contract.name} should have a deployment block number`, () => {
39+
const errorMsg = `No block number found for ${contract.name}`;
40+
expect(contract.block, errorMsg).toBeDefined();
41+
});
42+
}
43+
});
44+
}
45+
});

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function getInclude() {
88
const paths: string[] = [];
99

1010
if (TEST_ONLY_CONTRACTS) {
11-
paths.push("tests/contracts.test.ts");
11+
paths.push("tests/contracts/**/*.test.ts");
1212
}
1313
if (TEST_ONLY_CHAINS) {
1414
paths.push("tests/chains.test.ts");

0 commit comments

Comments
 (0)