Skip to content

Commit

Permalink
Merge pull request #99 from ethdebug/test-cases-folder
Browse files Browse the repository at this point in the history
Move integration test cases into subdirectory
  • Loading branch information
gnidan committed Jul 4, 2024
2 parents ff0b79c + 2e28e3c commit d69dc0a
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 90 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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

<CodeListing
packageName="@ethdebug/pointers"
sourcePath="src/test-cases.ts"
extract={sourceFile => sourceFile.getVariableStatement("stringStorageTest")}
/>

## Tested pointer

<TestedPointer
pointerQuery="string-storage-contract-variable-slot"
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
sidebar_position: 1
sidebar_label: <struct> storage
---

import CodeListing from "@site/src/components/CodeListing";
import TestedPointer from "./TestedPointer";

# Test case: `<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
with a few small fields (`struct Record { uint8 x; uint8 y; bytes4 salt; }`).

## Test source

<CodeListing
packageName="@ethdebug/pointers"
sourcePath="src/test-cases.ts"
extract={sourceFile => sourceFile.getVariableStatement("structStorageTest")}
/>

## Tested pointer

<TestedPointer
pointerQuery="struct-storage-contract-variable-slot"
/>
Original file line number Diff line number Diff line change
@@ -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:

<CodeListing
packageName="@ethdebug/pointers"
sourcePath="src/test-cases.ts"
extract={sourceFile => 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).
Original file line number Diff line number Diff line change
@@ -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

<CodeListing
packageName="@ethdebug/pointers"
sourcePath="src/test-cases.ts"
extract={sourceFile => sourceFile.getVariableStatement("uint256ArrayMemoryTest")}
/>

## Tested pointer

<TestedPointer
pointerQuery="uint256-array-memory-pointer-slot"
/>

0 comments on commit d69dc0a

Please sign in to comment.