Skip to content

test: add ethdebug/conformance#215

Open
djolertrk wants to merge 2 commits into
ethdebug:mainfrom
walnuthq:feature/ethdebug-solc
Open

test: add ethdebug/conformance#215
djolertrk wants to merge 2 commits into
ethdebug:mainfrom
walnuthq:feature/ethdebug-solc

Conversation

@djolertrk

Copy link
Copy Markdown

Add conformance tests for ethdebug producers and consumers.

$ yarn --cwd packages/conformance test
 ✓ test/conformance.test.ts (5 tests) 2442ms
   ✓ @ethdebug/conformance > [bug] compiles BUG fixtures into valid ETHDebug programs 7ms
   ✓ @ethdebug/conformance > [solc] compiles Solidity fixtures and validates ETHDebug output 45ms
   ✓ @ethdebug/conformance > [soldb] checks solc ETHDebug resources through the SolDB consumer backend 34ms
   ✓ @ethdebug/conformance > [soldb] checks multi-source solc ETHDebug resources through the SolDB consumer backend 21ms
   ✓ @ethdebug/conformance > [soldb] checks source-line breakpoints against solc output on local anvil  2335ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  16:51:17
   Duration  3.02s (transform 220ms, setup 0ms, collect 430ms, tests 2.44s, environment 0ms, prepare 30ms)

@djolertrk

Copy link
Copy Markdown
Author

cc @gnidan

@djolertrk djolertrk marked this pull request as draft May 15, 2026 14:53
@djolertrk djolertrk marked this pull request as ready for review May 22, 2026 09:24

@gnidan gnidan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conformance suite is awesome! Thank you for putting it together @djolertrk 🙏

Mostly I'm requesting changes to make sure we test against the JSON-Schemas themselves, but maybe you'll agree with my other comments also. Let me know if you run into trouble with the hyperjump stuff.

On a broader note, this stuff might get a bit complicated when we want to add schema versioning, since then suddenly the conformance tests have to grow in dimensionality... Have you thought about this at all? Obviously that conversation remains a bit premature [and definitely shouldn't block getting this PR merged]

}

artifact.programs.forEach((program, index) => {
if (!isProgram(program.program)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and the similar Materials.isCompilation checks) validate against the hand-written type guards, but nothing here checks against the JSON-Schemas themselves.

Type guards will always drift from the schema, of course, and in this instance, there's likely to be many false positives around things like unevaluatedProperties: false, use of if/then/else for discriminators... probably even things like regex matching with pattern I'd bet is pretty incomplete in the TS.

So yeah, heh, for a conformance test, we definitely want to validate against the most normative thing. Of course, it doesn't hurt to keep these type guard checks also!

Hopefully it should be pretty easy to validate against the schemas... this repo already does schema validation here, using a vitest guard defined here.

}

describe("@ethdebug/conformance", () => {
it("[bug] compiles BUG fixtures into valid ETHDebug programs", async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to also check against negative fixtures too. Nothing too complicated, but we do want to prove that the validator itself does validate. Maybe we can just feed it some deliberately malformed examples to make sure that result.ok comes back false when it should.

Comment on lines +87 to +88
types: {},
pointers: {},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mechanisms remain pretty much untested and unused, eh? :)

bugc doesn't generate these... it only currently emits raw inline types and pointers rather than leveraging the format's provided resource lookup table. I guess solc also hasn't touched this yet.

For the conformance tests though, I suppose we do want to make sure that the machinery works here, even if the compilers do not use the machinery!

}

const knownSourceIds = sourceIds(artifact);
if (knownSourceIds.size > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can knownSourceIds ever be empty if referencedSourceIds isn't? If so, we probably don't want to silently skip this check.

Comment on lines +176 to +195
const interactive = await runSoldb({
executable: soldb!,
args: [
"trace",
tx.transactionHash,
"--rpc",
anvil.rpcUrl,
"--ethdebug-dir",
debugDir.spec,
"--interactive",
],
stdin: "break Counter.sol:8\ncontinue\nq\n",
});

expect(interactive.exitCode).toBe(0);
expect(interactive.stdout).toContain(
"Breakpoint set at Counter.sol:8, PC",
);
expect(interactive.stdout).toContain("Breakpoint hit at step");
expect(interactive.stdout).toContain("Counter.sol:8, PC");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff gets a bit brittle, no? No way to control soldb as a library for this?

-DPEDANTIC=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build solidity/build --target solc --parallel 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goodbye fast CI 😭

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I guess the price is worth of paying, right? :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think so. later, builds can be cached and performance can be improved :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants