From 2e28e3c8709fc4c6b5fb94109f5b15074b7ab69a Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Thu, 4 Jul 2024 18:01:51 -0400 Subject: [PATCH] Move integration test cases into subdirectory --- .../pointers/testing/test-cases.mdx | 90 ------------------- .../{ => test-cases}/TestedPointer.tsx | 0 .../testing/test-cases/string-storage.mdx | 29 ++++++ .../testing/test-cases/struct-storage.mdx | 27 ++++++ .../testing/test-cases/test-cases.mdx | 31 +++++++ .../test-cases/uint256-array-memory.mdx | 27 ++++++ 6 files changed, 114 insertions(+), 90 deletions(-) delete mode 100644 packages/web/docs/implementation-guides/pointers/testing/test-cases.mdx rename packages/web/docs/implementation-guides/pointers/testing/{ => test-cases}/TestedPointer.tsx (100%) create mode 100644 packages/web/docs/implementation-guides/pointers/testing/test-cases/string-storage.mdx create mode 100644 packages/web/docs/implementation-guides/pointers/testing/test-cases/struct-storage.mdx create mode 100644 packages/web/docs/implementation-guides/pointers/testing/test-cases/test-cases.mdx create mode 100644 packages/web/docs/implementation-guides/pointers/testing/test-cases/uint256-array-memory.mdx diff --git a/packages/web/docs/implementation-guides/pointers/testing/test-cases.mdx b/packages/web/docs/implementation-guides/pointers/testing/test-cases.mdx deleted file mode 100644 index 8e1387fc..00000000 --- a/packages/web/docs/implementation-guides/pointers/testing/test-cases.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -sidebar_position: 7 ---- - -import CodeListing from "@site/src/components/CodeListing"; -import TestedPointer from "./TestedPointer"; - -# Test cases - -This reference implementation currently defines the following integration test -cases. - -Test cases are aggregated into the `observeTraceTests` variable: - - sourceFile.getVariableStatement("observeTraceTests")} - links={{ - structStorageTest: "#struct-storage", - stringStorageTest: "#string-storage", - uint256ArrayMemoryTest: "#uint256-array-memory", - }} - /> - -This variable will be used to generate automated tests dynamically, as will -be described on the -[next page](/docs/implementation-guides/pointers/testing/jest). - -## Structs in storage {#struct-storage} - -Solidity tightly packs struct storage words starting from the right-hand side. -This test ensures that relative offsets are computed properly for a struct that -defines a few small fields (`struct Record { uint8 x; uint8 y; bytes4 salt; }`). - -### Test source - - sourceFile.getVariableStatement("structStorageTest")} - /> - -### Tested pointer - - - -## Storage strings {#string-storage} - -Representing a Solidity `string storage` using an **ethdebug/format/pointer** -requires the use of conditional logic to identify the one or more regions that -correspond to raw UTF-8 Solidity string data. The `dereference()` function -should behave as expected for such a pointer and observe the changing string -value. - -### Test source - - sourceFile.getVariableStatement("stringStorageTest")} - /> - -### Tested pointer - - - -## Memory arrays of word-sized items {#uint256-array-memory} - -Memory arrays are primarily referenced using stack-located memory offset values, -and so this test case ensures that stack slot indexes are properly adjusted over -the course of the transaction. - -### Test source - - sourceFile.getVariableStatement("uint256ArrayMemoryTest")} - /> - -### Tested pointer - - diff --git a/packages/web/docs/implementation-guides/pointers/testing/TestedPointer.tsx b/packages/web/docs/implementation-guides/pointers/testing/test-cases/TestedPointer.tsx similarity index 100% rename from packages/web/docs/implementation-guides/pointers/testing/TestedPointer.tsx rename to packages/web/docs/implementation-guides/pointers/testing/test-cases/TestedPointer.tsx diff --git a/packages/web/docs/implementation-guides/pointers/testing/test-cases/string-storage.mdx b/packages/web/docs/implementation-guides/pointers/testing/test-cases/string-storage.mdx new file mode 100644 index 00000000..bc52f59a --- /dev/null +++ b/packages/web/docs/implementation-guides/pointers/testing/test-cases/string-storage.mdx @@ -0,0 +1,29 @@ +--- +sidebar_position: 2 +sidebar_label: string storage +--- + +import CodeListing from "@site/src/components/CodeListing"; +import TestedPointer from "./TestedPointer"; + +# Test case: `string storage` + +Representing a Solidity `string storage` using an **ethdebug/format/pointer** +requires the use of conditional logic to identify the one or more regions that +correspond to raw UTF-8 Solidity string data. The `dereference()` function +should behave as expected for such a pointer and observe the changing string +value. + +## Test source + + sourceFile.getVariableStatement("stringStorageTest")} + /> + +## Tested pointer + + diff --git a/packages/web/docs/implementation-guides/pointers/testing/test-cases/struct-storage.mdx b/packages/web/docs/implementation-guides/pointers/testing/test-cases/struct-storage.mdx new file mode 100644 index 00000000..b6269c7f --- /dev/null +++ b/packages/web/docs/implementation-guides/pointers/testing/test-cases/struct-storage.mdx @@ -0,0 +1,27 @@ +--- +sidebar_position: 1 +sidebar_label: storage +--- + +import CodeListing from "@site/src/components/CodeListing"; +import TestedPointer from "./TestedPointer"; + +# Test case: ` storage` + +Solidity tightly packs struct storage words starting from the right-hand side. +This test ensures that relative offsets are computed properly for a struct +with a few small fields (`struct Record { uint8 x; uint8 y; bytes4 salt; }`). + +## Test source + + sourceFile.getVariableStatement("structStorageTest")} + /> + +## Tested pointer + + diff --git a/packages/web/docs/implementation-guides/pointers/testing/test-cases/test-cases.mdx b/packages/web/docs/implementation-guides/pointers/testing/test-cases/test-cases.mdx new file mode 100644 index 00000000..ad35a48d --- /dev/null +++ b/packages/web/docs/implementation-guides/pointers/testing/test-cases/test-cases.mdx @@ -0,0 +1,31 @@ +--- +sidebar_position: 7 +--- + +import CodeListing from "@site/src/components/CodeListing"; +import TestedPointer from "./TestedPointer"; + +# Test cases + +This reference implementation currently defines the following integration test +cases. + +Test cases are aggregated into the `observeTraceTests` variable: + + sourceFile.getVariableStatement("observeTraceTests")} + links={{ + structStorageTest: "/docs/implementation-guides/pointers/testing/test-cases/struct-storage/", + stringStorageTest: "/docs/implementation-guides/pointers/testing/test-cases/string-storage/", + uint256ArrayMemoryTest: "/docs/implementation-guides/pointers/testing/test-cases/uint256-array-memory/", + }} + /> + +To see a brief introduction and the relevant code listings for each test case, +please use the sidebar navigation or the hyperlinks included above. + +This variable will be used to generate automated tests dynamically, as will +be described in the next section +[Hooking up Jest](/docs/implementation-guides/pointers/testing/jest). diff --git a/packages/web/docs/implementation-guides/pointers/testing/test-cases/uint256-array-memory.mdx b/packages/web/docs/implementation-guides/pointers/testing/test-cases/uint256-array-memory.mdx new file mode 100644 index 00000000..c1ff23d2 --- /dev/null +++ b/packages/web/docs/implementation-guides/pointers/testing/test-cases/uint256-array-memory.mdx @@ -0,0 +1,27 @@ +--- +sidebar_position: 3 +sidebar_label: uint256[] memory +--- + +import CodeListing from "@site/src/components/CodeListing"; +import TestedPointer from "./TestedPointer"; + +# Test case: `uint256[] memory` + +Memory arrays are primarily referenced using stack-located memory offset values, +and so this test case ensures that stack slot indexes are properly adjusted over +the course of the transaction. + +## Test source + + sourceFile.getVariableStatement("uint256ArrayMemoryTest")} + /> + +## Tested pointer + +