-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from ethdebug/test-how
Document and improve @ethdebug/pointers integration tests
- Loading branch information
Showing
27 changed files
with
1,191 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import chalk from "chalk"; | ||
import { highlight } from "cli-highlight"; | ||
import { describeSchema } from "@ethdebug/format"; | ||
|
||
import { | ||
type Cursor, | ||
Data | ||
} from "../src/index.js"; | ||
|
||
import { observeTrace } from "../test/index.js"; | ||
|
||
import { observeTraceTests } from "../src/test-cases.js"; | ||
|
||
export async function run() { | ||
const { | ||
pointer, | ||
compileOptions, | ||
observe | ||
} = observeTraceTests["string storage"]; | ||
|
||
console.log( | ||
chalk.bold(chalk.cyan( | ||
"demo: run compiled solidity and watch a changing ethdebug/format pointer\n" | ||
)) | ||
); | ||
|
||
console.group(chalk.bold("ethdebug/format pointer used by demo")); | ||
console.log( | ||
highlight( | ||
describeSchema({ | ||
schema: { id: "schema:ethdebug/format/pointer" }, | ||
pointer: "#/examples/4" | ||
}).yaml, | ||
{ language: "yaml" } | ||
).trim() | ||
); | ||
console.groupEnd(); | ||
console.log(""); | ||
|
||
console.group(chalk.bold("solidity source code used by demo")); | ||
console.log( | ||
compileOptions.sources["StringStorage.sol"].content.trim() | ||
); | ||
console.groupEnd(); | ||
console.log(""); | ||
|
||
console.group(chalk.bold("observing deployment trace")); | ||
|
||
const observedValues = | ||
await observeTrace({ pointer, compileOptions, observe }); | ||
|
||
console.groupEnd(); | ||
console.log(""); | ||
|
||
console.group(chalk.bold("observed values:")); | ||
for (const value of observedValues) { | ||
console.log("- %o", value); | ||
} | ||
console.groupEnd(); | ||
console.log(""); | ||
} | ||
|
||
await run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 0 additions & 76 deletions
76
packages/pointers/src/dereference/index.integration.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { jest, expect, describe, it, beforeEach } from "@jest/globals"; | ||
|
||
import { observeTrace } from "../test/index.js"; | ||
import { observeTraceTests } from "./test-cases.js"; | ||
|
||
describe("dereference (integration)", () => { | ||
describe("changing pointer values over the course of a trace", () => { | ||
for (const [name, test] of Object.entries(observeTraceTests)) { | ||
const { expectedValues, ...options } = test; | ||
|
||
describe(`example pointer: ${name}`, () => { | ||
it("resolves to values containing the expected sequence", async () => { | ||
const observedValues = | ||
await observeTrace(options as Parameters<typeof observeTrace>[0]); | ||
|
||
expect(observedValues) | ||
.toEqual(expect.arrayContaining(expectedValues)); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.