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
13 changes: 9 additions & 4 deletions packages/conformance/src/adapters/soldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ 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.
function ethdebugResources(artifact: EthdebugArtifact): unknown {
if (artifact.resources) {
return artifact.resources;
const { resources, compilation } = artifact;
if (resources) {
return { compilation, ...resources };
}

if (artifact.compilation) {
if (compilation) {
return Data.stamp("ethdebug/format/info/resources", {
compilation: artifact.compilation,
compilation,
types: {},
pointers: {},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/conformance/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function sourceIds(artifact: EthdebugArtifact): Set<Materials.Id> {
for (const source of artifact.compilation?.sources ?? []) {
ids.add(source.id);
}
for (const source of artifact.resources?.compilation.sources ?? []) {
for (const source of artifact.resources?.compilation?.sources ?? []) {
ids.add(source.id);
}
return ids;
Expand Down Expand Up @@ -180,7 +180,7 @@ export async function validateStaticConformance(
}

if (
artifact.resources &&
artifact.resources?.compilation &&
!Materials.isCompilation(artifact.resources.compilation)
) {
issues.push(
Expand Down
2 changes: 1 addition & 1 deletion packages/conformance/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface EthdebugArtifact {
compilation?: Materials.Compilation;
resources?: {
ethdebug?: Data.Stamp;
compilation: Materials.Compilation;
compilation?: Materials.Compilation;
types: Record<string, unknown>;
pointers: Record<string, unknown>;
};
Expand Down
19 changes: 18 additions & 1 deletion packages/conformance/test/conformance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ describe("@ethdebug/conformance", () => {
expect(result.exitCode).toBe(0);
const json = result.json as any;
expect(json.contracts[0].name).toBe("Counter");
const written = JSON.parse(
await readFile(path.join(debugDir.debugDir, "ethdebug.json"), "utf8"),
);
expect(json.contracts[0].resources).toEqual(
withoutResourcesStamp(artifact.resources, json.contracts[0].resources),
withoutResourcesStamp(written, json.contracts[0].resources),
);
expect(
json.contracts[0].resources.compilation.sources[0].contents,
Expand Down Expand Up @@ -497,6 +500,20 @@ describe("@ethdebug/conformance", () => {
});
});

it("puts a separate compilation into the resources it writes for SolDB", async () => {
const { compilation: _, ...resources } = validResources();
const debugDir = await writeSoldbDebugDir(
validArtifact({ resources: resources as any }),
{ contractName: "Counter" },
);

const written = JSON.parse(
await readFile(path.join(debugDir.debugDir, "ethdebug.json"), "utf8"),
);

expect(written).toEqual({ ...resources, compilation: validCompilation() });
});

it("materializes non-empty resources into SolDB debug directories", async () => {
const debugDir = await writeSoldbDebugDir(
validArtifact({
Expand Down
Loading