Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/conformance/src/adapters/soldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ function contractName(artifact: EthdebugArtifact, fallback?: string): string {
);
}

// SolDB reads source contents only from the `compilation` of the resources
// file in its debug directory. A compiler can emit the compilation on its
// own instead (solc does since argotorg/solidity#17179), so put it in the
// resources here.
// Shim for an expected failure (#416): SolDB reads source contents only from
// the `compilation` of the resources file in its debug directory. A compiler
// can emit the compilation on its own instead (solc does since
// argotorg/solidity#17179), so put it in the resources here. A tripwire in
// the conformance test fails once SolDB reads the separate compilation; then
// write the resources as they are.
function ethdebugResources(artifact: EthdebugArtifact): unknown {
const { resources, compilation } = artifact;
if (resources) {
Expand Down
55 changes: 54 additions & 1 deletion packages/conformance/test/conformance.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { spawnSync } from "node:child_process";
import { accessSync, constants } from "node:fs";
import { readFile } from "node:fs/promises";
import { readFile, rm, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

Expand Down Expand Up @@ -245,6 +245,59 @@ describe("@ethdebug/conformance", () => {
},
);

// Expected failure (#416): SolDB reads sources only from the compilation
// inside its resources file, and writeSoldbDebugDir shims this by merging
// the separate compilation in. This test gives SolDB the directory as
// solc's `--ethdebug` output writes it: `ethdebug_resources.json` without
// a compilation and `ethdebug_compilation.json` next to it. SolDB now
// rejects that resources file, so it reports no sources. The check fails
// once SolDB reports the sources from this directory; then remove the
// shim in ethdebugResources and this test.
it.skipIf(!soldb || !solc)(
"[soldb] does not yet read a compilation separate from resources",
async () => {
const artifact = await compileEthdebug({
kind: "solc",
solcPath: solc!,
sourcePath: path.join(root, "test/fixtures/solc/Counter.sol"),
});
const { compilation: _, ...resources } = artifact.resources ?? {};
const compilation =
artifact.compilation ?? artifact.resources?.compilation;
expect(compilation).toBeDefined();

const debugDir = await writeSoldbDebugDir(artifact, {
contractName: "Counter",
});
const dir = debugDir.debugDir;
await rm(path.join(dir, "ethdebug.json"));
await writeFile(
path.join(dir, "ethdebug_resources.json"),
JSON.stringify(resources),
);
await writeFile(
path.join(dir, "ethdebug_compilation.json"),
JSON.stringify(compilation),
);

const result = await runSoldb({
executable: soldb!,
args: ["info", "resources", "--ethdebug-dir", debugDir.spec, "--json"],
});
const sources =
result.exitCode === 0
? JSON.parse(result.stdout).contracts[0].resources.compilation
?.sources
: undefined;

expect(
sources,
"SolDB now reads the separate compilation; " +
"remove the shim in ethdebugResources (#416)",
).toBeUndefined();
},
);

it.skipIf(!soldb || !solc)(
"[soldb] checks multi-source solc ETHDebug resources through the SolDB consumer backend",
async () => {
Expand Down
Loading