Skip to content

Commit

Permalink
Add ci tests and remove huff tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Feb 11, 2024
1 parent 28d5694 commit a9a3020
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 314 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,55 @@
name: test

on: workflow_dispatch
on: [push]

env:
FOUNDRY_PROFILE: ci

jobs:
check:
test-fast:
strategy:
fail-fast: true

name: Foundry project
name: Fuzz testing (fast)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '>=1.18.0'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
- name: Run tests (fast)
run: |
forge --version
forge build --sizes
id: build
./run_tests.sh -vvv
id: test

test-slow:
strategy:
fail-fast: true

name: Fuzz testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '>=1.18.0'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge tests
- name: Run tests
run: |
forge test -vvv
./run_tests.sh -vvv --fuzz-runs 8192
id: test
305 changes: 0 additions & 305 deletions src/vm.huff
Original file line number Diff line number Diff line change
Expand Up @@ -2225,308 +2225,3 @@
#define table COMMON_4BYTES {
0x00000000a9059cbb095ea7b37ff36ab538ed173918cbafe5202ee0edfb3bdb41e2bbb158ab834bab6ea056a923b872dda68a76cc5f5755298803dbeea22cb465c89e43612da0340990411a321cff79cd223da1ba2e1a7d4df305d71939125215d0e30db0f7654176a694fc3a1a695230b6b55f25791ac94764887334c658695c441a3e704f1d48324a25d94aa454dfa9c18a84bce2b39746178979aec9807539ddd81f82a8a41c70cf557fe33d18b9129cec63924ab0d1900dcd7a6cd9627aa49149bafe672a9400dfbe4a31c6bf3262f242432ae5ab4da240c10f192e7ba6efc23e1a211aa3a008d6b347f7ded9382a00000003e9fad8eefaebafa8ae169a50e8e3370041fe00a0fa558b712e95b6c8c48fdfca000000006a80c33f627dd56a5c11d7954946e2065e83b463ca722cdcfb90b32000000008f7c1e582a32fe0a1db006a75000000010002191ce6d66ac8a0712d685d5d442296aa7368d3392ddf0ea5812fa5d754d1d29dff129979ef457901451ca64f797659d667a500032587865a6b4f379607f57c02520082d2697fc11695488758a5f34e71d92d9ddd67ba183d4e0b8f69c188e3dec8fbedc9af952d2da8066a761202a9b1d507ca120b1ff14fcbc8961c9ae442842e0e2195995c94b918de608060405174e8532505c3d98568523a0e89439bd149d05cefef39a14ce6931a000225879bfcb236415565b0454a2ab3ce558087f7a1696342966c688b4cb0ec4faa8a26e4a76726e8eda9df1519cdeb356282bfe17376b5009952eb3d7989fe34b0793b38bcdfc0f053566e02751cecc01a8c84f463e18e3cd18ca029ada03907d6b3483805550fa59f3e0c89bbb8b2c5ebeaec4997adb6f5e54063761610fcb88a802f3ccfd60b2e2d726ca4202615b44848f51610ca95bcf64e0579b177ec22895118ed436a474d474898c0f4ed31b967cb0ca6e158f8db7fd4089120491ca415bcad8201aa3f6e5110ae5312ea8e3df02124b77d239ba67a6a45156e29f6241735bbd017e8c73f7658fd86b2ecc4c44193c39bc12042d96a094a13d98d135d4c66a3ad4451a32e17de789ec9b36be47d166cbfff3b87f884e54a0b020003ad58bdd147e7ef24bad42590c8fd6ed002032587c6427474f6162b01baa2abde1ff013f11846eac55915d806f6aa658b00024a9c564a515869328dec4454b20df5298aca853828b6f06427e5b6b4af05f3fef3a352a438b81249c58bfeab2e5af9d83bb568c2c5fb02022587d586d8e0db254e5005eec2890e7527028f4af52f6a627842508c1dbd0f694584a6417ed63049105d1e9a6950d9caed120103258748d5c7e3be389d577430e0c649b780f00af49149d508e6238e1e280cae47bea8683fa88d5db3b4df1e83409a852a12e3c2998238343009a2daa6d5560f0439589c1298a06aa1e6d24d559317
}


#[calldata("0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a899")]
#define test TEST_SAVE_BYTES32() = {
0x01 // [rindex]
0x20 // [windex, rindex]

SAVE_BYTES32() // [windex, rindex]

0x40 eq ASSERT() // []
0x21 eq ASSERT() // [rindex]

// Validate that memory was written correctly

0x20 mload // [mem[0x20]] ()
0xd10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a899

eq ASSERT() // []

// Validate that the written address is correct
0x01 0x80 shl sload // [addr]
0xd10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a899 eq ASSERT() // []

// Validate that the total increased to 1
BYTES32_NUM() 0x01 eq ASSERT() // []
}

#[calldata("0x0201f020c002f1e0040203")]
#define test TEST_READ_BYTES32() = {
// Save 3 different bytes32 values

0xfe9716a384ec3b055bb8aae87323a14412cbfceb52c95324dccf071fb3f83855
0x0201 0x80 shl sstore

0xcf85e6408b0191a7ed9970e635257854b95aa7b708f485ae667e6fd467e5f45e
0xf020c002 0x80 shl sstore

0xa577e893e614c9aa4b19f2369e1c177adab9fe3156970a39afc166c0f2d905ee
0xf1e0040203 0x80 shl sstore

// Read the first bytes32
0x00 // [rindex]
0x00 // [windex, rindex]

READ_BYTES32_STORAGE(0x02, 0xf0) // [windex, rindex]

0x20 eq ASSERT() // [rindex]
0x02 eq ASSERT() // []

0x00 mload 0xfe9716a384ec3b055bb8aae87323a14412cbfceb52c95324dccf071fb3f83855 eq ASSERT() // []

// Read the second bytes32
0x02 // [rindex]
0x20 // [windex, rindex]

READ_BYTES32_STORAGE(0x04, 0xe0) // [windex, rindex]

0x40 eq ASSERT() // [rindex]
0x06 eq ASSERT() // []

0x20 mload 0xcf85e6408b0191a7ed9970e635257854b95aa7b708f485ae667e6fd467e5f45e eq ASSERT() // []

// Read the third bytes32
0x06 // [rindex]
0x10 // [windex, rindex]

READ_BYTES32_STORAGE(0x05, 0xd8) // [windex, rindex]

0x30 eq ASSERT() // [rindex]
0x0b eq ASSERT() // []

0x10 mload 0xa577e893e614c9aa4b19f2369e1c177adab9fe3156970a39afc166c0f2d905ee eq ASSERT() // []
}

#[calldata("0x0201f020c002f1e0040203")]
#define test TEST_READ_ADDRESS() = {
// Save 3 different bytes32 values

0x000000000000000000000000d789f5242a537b0584893b564a8c7a4be35b9238
0x0201 ADDRESS_STORAGE_POINTER() sstore

0x000000000000000000000000d5b5127436fd875ab7c334dffb62533ba011c2d9
0xf020c002 ADDRESS_STORAGE_POINTER() sstore

0x0000000000000000000000008a745d2b92c6e02e8ed087581c63d073f98f2479
0xf1e0040203 ADDRESS_STORAGE_POINTER() sstore

// Read the first bytes32
0x00 // [rindex]
0x00 // [windex, rindex]

READ_ADDRESS_STORAGE(0x02, 0xf0) // [windex, rindex]

0x20 eq ASSERT() // [rindex]
0x02 eq ASSERT() // []

0x00 mload 0x000000000000000000000000d789f5242a537b0584893b564a8c7a4be35b9238 eq ASSERT() // []

// Read the second bytes32
0x02 // [rindex]
0x20 // [windex, rindex]

READ_ADDRESS_STORAGE(0x04, 0xe0) // [windex, rindex]

0x40 eq ASSERT() // [rindex]
0x06 eq ASSERT() // []

0x20 mload 0x000000000000000000000000d5b5127436fd875ab7c334dffb62533ba011c2d9 eq ASSERT() // []

// Read the third bytes32
0x06 // [rindex]
0x10 // [windex, rindex]

READ_ADDRESS_STORAGE(0x05, 0xd8) // [windex, rindex]

0x30 eq ASSERT() // [rindex]
0x0b eq ASSERT() // []

0x10 mload 0x0000000000000000000000008a745d2b92c6e02e8ed087581c63d073f98f2479 eq ASSERT() // []
}


#[calldata("0x000203ff00ff")]
#define test TEST_READ_POW_2() = takes (2) returns (2) {
0x00 // [rindex]
0x00 // [windex, rindex]

READ_POW_2() // [windex, rindex]

0x20 eq ASSERT() // [rindex]
0x02 eq ASSERT() // []

0x00 mload 0x07 eq ASSERT() // []

0x01 // [rindex]
0x20 // [windex, rindex]

READ_POW_2() // [windex, rindex]

0x40 eq ASSERT() // [rindex]
0x02 eq ASSERT() // []

0x20 mload 0x04 eq ASSERT() // []

0x02 // [rindex]
0x05 // [windex, rindex]

READ_POW_2() // [windex, rindex]

0x25 eq ASSERT() // [rindex]
0x03 eq ASSERT() // []

0x05 mload 0x08 eq ASSERT() // []

0x03 // [rindex]
0x00 // [windex, rindex]

READ_POW_2() // [windex, rindex]

0x20 eq ASSERT() // [rindex]
0x04 eq ASSERT() // []

0x00 mload 0x8000000000000000000000000000000000000000000000000000000000000000 eq ASSERT() // []

0x04 // [rindex]
0x00 // [windex, rindex]

READ_POW_2() // [windex, rindex]

0x20 eq ASSERT() // [rindex]
0x06 eq ASSERT() // []

0x00 mload 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff eq ASSERT() // []
}

#[calldata("0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a899")]
#define test TEST_LOAD_DYNAMIC_SIZE() = {
0x00 // [rindex]

LOAD_DYNAMIC_SIZE(0x02, 0xf0) // [val, nrindex + size]

0xb2d1 eq ASSERT() // [rindex]
0x02 eq ASSERT() // []

0x04 // [rindex]

LOAD_DYNAMIC_SIZE(0x05, 0xd8) // [val, nrindex + size]

0x7ef5838bb8 eq ASSERT() // [rindex]
0x09 eq ASSERT() // []
}

#[calldata("0x02f1f2")]
#define test TEST_READ_FLAG_2_BYTES() = {
0x00 // [rindex]
[FMS] // [windex, rindex]

READ_FLAG() // [windex, rindex]

0x20 [FMS] add eq ASSERT() // [rindex]
0x03 eq ASSERT() // []

[FMS] mload 0xf1f2 eq ASSERT() // []
}

#define test TEST_NUMS() = {
ADDRESSES_NUM() // [num]
0x00 eq ASSERT() // []

PULL_ADDRESS() // [nnum]
0x01 eq ASSERT() // []

ADDRESSES_NUM() // [num]
0x01 eq ASSERT() // []

PULL_ADDRESS() // [nnum]
0x02 eq ASSERT() // []

ADDRESSES_NUM() // [num]
0x02 eq ASSERT() // []

PULL_BYTES32() // [nnum]
0x01 eq ASSERT() // []

BYTES32_NUM() // [num]
0x01 eq ASSERT() // []

ADDRESSES_NUM() // [num]
0x02 eq ASSERT() // []

PULL_ADDRESS() // [nnum]
0x03 eq ASSERT() // []

BYTES32_NUM() // [nnum]
0x01 eq ASSERT() // []

PULL_BYTES32() // [nnum]
0x02 eq ASSERT() // []

BYTES32_NUM() // [num]
0x02 eq ASSERT() // []

ADDRESSES_NUM() // [num]
0x03 eq ASSERT() // []
}

#[calldata("0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a8")]
#define test TEST_FLAG_READ_WORD() = {
0x01 // [rindex]
[FMS] 0x40 add // [windex, rindex]

READ_WORD(0xf0, 0x02) // [windex, rindex]

[FMS] 0x60 add eq ASSERT() // [rindex]
0x03 eq ASSERT() // []

[FMS] 0x40 add mload 0xd10e eq ASSERT() // []

0x00 // [rindex]
[FMS] // [windex, rindex]

READ_WORD(0x00, 0x20) // [windex, rindex]

[FMS] 0x20 add eq ASSERT() // [rindex]
0x20 eq ASSERT() // []

[FMS] mload 0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a8 eq ASSERT() // []

0x00 // [rindex]
[FMS] 0x40 add // [windex, rindex]

READ_FULL_WORD() // [windex, rindex]

[FMS] 0x60 add eq ASSERT() // [rindex]
0x20 eq ASSERT() // []

[FMS] 0x40 add
mload 0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a8 eq ASSERT() // []
}

// 0xd10eb37ef5838bb835ea71bbd4053daf8de7bd8e
#[calldata("0xb2d10eb37ef5838bb835ea71bbd4053daf8de7bd8ecdf638451a2bc966a145a8")]
#define test TEST_SAVE_ADDRESS() = {
0x01 // [rindex]
[FMS] // [windex, rindex]

SAVE_ADDRESS() // [windex, rindex]

[FMS] 0x20 add eq ASSERT() // [rindex]
0x15 eq ASSERT() // []

// Validate that memory was written correctly

[FMS] mload // [mem[0x20]] ()
0x000000000000000000000000d10eb37ef5838bb835ea71bbd4053daf8de7bd8e
eq ASSERT() // []

// Validate that the written address is correct
0x02 sload // [addr]
0x000000000000000000000000d10eb37ef5838bb835ea71bbd4053daf8de7bd8e
eq ASSERT() // []

// Validate that the total increased to 1
ADDRESSES_NUM() 0x01 eq ASSERT() // []
}

0 comments on commit a9a3020

Please sign in to comment.