Skip to content

Commit 4485267

Browse files
authored
Merge pull request #25 from wasm-forge/fuzz-tests
test!: Fuzz tests
2 parents 64c095f + 157a5b9 commit 4485267

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3002
-389
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Tests
2+
3+
on:
4+
[push]
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
TERM: xterm-256color
9+
10+
jobs:
11+
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust: [1.88.0]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Cache Cargo
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ matrix.rust }}-cargo-
32+
33+
- name: Install Rust
34+
run: |
35+
rustup update ${{ matrix.rust }} --no-self-update
36+
rustup default ${{ matrix.rust }}
37+
rustup component add rustfmt
38+
rustup component add clippy
39+
rustup target add wasm32-wasip1
40+
41+
- name: Install dfx
42+
uses: dfinity/setup-dfx@main
43+
44+
- name: Check Format
45+
run: cargo fmt --all -- --check
46+
47+
#- name: Clippy
48+
# run: cargo clippy --tests --benches -- -D clippy::all
49+
50+
- name: Install wasi2ic
51+
run: cargo install wasi2ic
52+
53+
- name: Install candid-extractor
54+
run: cargo install candid-extractor
55+
56+
- name: Install ic-test
57+
run: cargo install ic-test
58+
59+
# Build everything
60+
- name: Build test projects
61+
run: ./scripts/build_tests.sh
62+
63+
# Run tests
64+
- name: Run tests
65+
run: cargo test -- --color always
66+
67+
# Prepare coverage
68+
- name: Install llvm-cov
69+
uses: taiki-e/install-action@cargo-llvm-cov
70+
71+
- name: Generate code coverage
72+
run: cargo llvm-cov --features report_wasi_calls,transient,skip_unimplemented_functions --lcov --ignore-filename-regex='(wasi_mock\.rs|bindings|canisters)' --workspace --output-path lcov.info
73+
74+
- uses: codecov/codecov-action@v5
75+
with:
76+
token: ${{ secrets.CODECOV_TOKEN }}
77+
files: lcov.info
78+
fail_ci_if_error: true

.github/workflows/ic.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/pr-title.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: PR title format
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- edited
8+
- synchronize
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
# When getting Rust dependencies, retry on network error:
16+
CARGO_NET_RETRY: 10
17+
# Use the local .curlrc
18+
CURL_HOME: .
19+
20+
jobs:
21+
check:
22+
name: conventional-pr-title:required
23+
runs-on: ubuntu-latest
24+
env:
25+
TITLE: ${{ github.event.pull_request.title }}
26+
steps:
27+
# Conventional commit patterns:
28+
# verb: description
29+
# verb!: description of breaking change
30+
# verb(scope): Description of change to $scope
31+
# verb(scope)!: Description of breaking change to $scope
32+
# verb: feat, fix, ...
33+
# scope: refers to the part of code being changed. E.g. " (accounts)" or " (accounts,canisters)"
34+
# !: Indicates that the PR contains a breaking change.
35+
- run: |
36+
if [[ "$TITLE" =~ ^(feat|fix|chore|build|ci|docs|style|refactor|perf|test)(\([-a-zA-Z0-9,]+\))?\!?\: ]]; then
37+
echo pass
38+
else
39+
echo "PR title does not match conventions"
40+
exit 1
41+
fi

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ target
22
Cargo.lock
33
wasi2ic
44
pocket-ic
5+
56
*.wasm
67
**/*.rs.bk
78

89
test/test_programs
910

10-
tarpaulin-report.html
1111
/.vscode/
12-
lcov.info
12+
a_computed.txt
13+
b_expected.txt
1314

14-
.codegpt
15+
lcov.info
16+
codecov.json
17+
playground

Cargo.toml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
[package]
2-
name = "ic-wasi-polyfill"
3-
version = "0.8.3"
4-
edition = "2024"
5-
keywords = ["ic", "wasi", "wasi-polyfill"]
6-
description = "The project provides polyfill implementation of *wasi_snapshot_preview1* functions using IC System API."
7-
license = "MIT"
8-
repository = "https://github.com/wasm-forge/ic-wasi-polyfill"
9-
10-
[dependencies]
11-
ic-cdk = "0.18.3"
12-
ic-stable-structures = "0.6.7"
13-
stable-fs = "0.8.1"
14-
15-
16-
rand = "0.9.1"
17-
function_name = "0.3.0"
18-
19-
[features]
20-
transient=[]
21-
report_wasi_calls=[]
22-
skip_unimplemented_functions=[]
23-
24-
[lib]
25-
crate-type = ["staticlib","lib"]
26-
27-
[dev-dependencies]
1+
[workspace]
2+
members = [
3+
"ic-wasi-polyfill", "fuzz-tests", "test/canisters/fs_tests/src/fs_tests_backend",
4+
"test/canisters/canister_initial/src/canister_initial_backend",
5+
"test/canisters/canister_upgraded/src/canister_upgraded_backend",
6+
]
7+
resolver = "2"
8+
9+
[workspace.dependencies]
2810
candid = "0.10.14"
29-
pocket-ic = "9.0.2"
11+
ic-cdk = "0.18.3"
12+
ic-stable-structures = "0.16.9"
3013

14+
ic-wasi-polyfill = {path="ic-wasi-polyfill"}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The IC Polyfill library
22

3-
![Tests](https://github.com/wasm-forge/ic-wasi-polyfill/actions/workflows/rust.yml/badge.svg?event=push)
3+
![Tests](https://github.com/wasm-forge/ic-wasi-polyfill/actions/workflows/ci.yml/badge.svg?event=push)
44
[![Coverage](https://codecov.io/gh/wasm-forge/ic-wasi-polyfill/branch/main/graph/badge.svg)](https://codecov.io/gh/wasm-forge/ic-wasi-polyfill/branch/main/)
55

66
The project provides polyfill implementation of *wasi_unstable* and *wasi_snapshot_preview1* functions using IC System API.

fuzz-tests/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "fuzz-tests"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dev-dependencies]
7+
candid = "0.10"
8+
cargo_metadata = "0.20.0"
9+
ic-cdk = "0.18.5"
10+
ic-test = {version = "0.1"}
11+
pocket-ic = "9.0.2"
12+
serde = "1.0.219"
13+
serde_bytes = "0.11.17"
14+
tokio = { version = "1", features = ["full"] }
15+
convert_case = "0.8.0"

0 commit comments

Comments
 (0)