Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: migrate to sn foundry #329

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ jobs:
name: test
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3
- name: Step 2 - Getting scarb
uses: software-mansion/[email protected]
- name: Step 3 - Running tests
run: scarb test
- uses: actions/checkout@v3
- uses: foundry-rs/setup-snfoundry@v3
- uses: software-mansion/[email protected]
- run: scarb test

check-format:
needs: build
Expand All @@ -47,6 +45,7 @@ jobs:
uses: actions/checkout@v3
- name: Step 2 - Getting scarb
uses: software-mansion/[email protected]
- uses: foundry-rs/setup-snfoundry@v3
- name: Step 3 - Generate and compare gas report
run: ./scripts/generate_gas_report.sh
shell: bash
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
scarb 2.7.0
starknet-foundry 0.28.0
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ scarb build

### Test

Install [Starknet-Foundry](https://foundry-rs.github.io/starknet-foundry/getting-started/installation.html) and then run the following command to run all the tests:

```bash
scarb test
```
Running a specific subset of tests
```bash
scarb test -f math
scarb test math
```

### Format
Expand Down
36 changes: 36 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "alexandria_ascii"
version = "0.1.0"
dependencies = [
"alexandria_data_structures",
"snforge_std",
]

[[package]]
Expand All @@ -14,13 +15,15 @@ version = "0.1.0"
dependencies = [
"alexandria_data_structures",
"alexandria_math",
"snforge_std",
]

[[package]]
name = "alexandria_data_structures"
version = "0.2.0"
dependencies = [
"alexandria_encoding",
"snforge_std",
]

[[package]]
Expand All @@ -30,53 +33,86 @@ dependencies = [
"alexandria_bytes",
"alexandria_math",
"alexandria_numeric",
"snforge_std",
]

[[package]]
name = "alexandria_linalg"
version = "0.1.0"
dependencies = [
"alexandria_math",
"snforge_std",
]

[[package]]
name = "alexandria_macros"
version = "0.1.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "alexandria_math"
version = "0.2.1"
dependencies = [
"snforge_std",
]

[[package]]
name = "alexandria_merkle_tree"
version = "0.1.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "alexandria_numeric"
version = "0.1.0"
dependencies = [
"alexandria_math",
"alexandria_searching",
"snforge_std",
]

[[package]]
name = "alexandria_searching"
version = "0.1.0"
dependencies = [
"alexandria_data_structures",
"snforge_std",
]

[[package]]
name = "alexandria_sorting"
version = "0.1.0"
dependencies = [
"alexandria_data_structures",
"snforge_std",
]

[[package]]
name = "alexandria_storage"
version = "0.3.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "alexandria_utils"
version = "0.1.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "snforge_scarb_plugin"
version = "0.1.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.28.0#4dfe39d96690ed6b3d56971512700de3f58288ea"

[[package]]
name = "snforge_std"
version = "0.28.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.28.0#4dfe39d96690ed6b3d56971512700de3f58288ea"
dependencies = [
"snforge_scarb_plugin",
]
800 changes: 148 additions & 652 deletions gas_report.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion packages/ascii/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ fmt.workspace = true
alexandria_data_structures = { path = "../data_structures" }

[dev-dependencies]
cairo_test.workspace = true
assert_macros = "0.1.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.28.0" }

[scripts]
test = "snforge test"
test-profiling = "snforge test --build-profile"
6 changes: 0 additions & 6 deletions packages/ascii/src/tests/test_ascii_integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use alexandria_ascii::ToAsciiTrait;
use core::num::traits::Bounded;

#[test]
#[available_gas(2000000000)]
fn u256_to_ascii() {
// ------------------------------ max u256 test ----------------------------- //
// max u256 int in cairo is GitHub Copilot: The maximum u256 number in Cairo is `
Expand Down Expand Up @@ -32,7 +31,6 @@ fn u256_to_ascii() {
}

#[test]
#[available_gas(2000000)]
fn u128_to_ascii() {
// ------------------------------ max u128 test ----------------------------- //
// max u128 int in cairo is 340282366920938463463374607431768211455
Expand All @@ -55,7 +53,6 @@ fn u128_to_ascii() {
}

#[test]
#[available_gas(2000000)]
fn u64_to_ascii() {
// ------------------------------ max u64 test ------------------------------ //
let num: u64 = Bounded::MAX;
Expand All @@ -66,7 +63,6 @@ fn u64_to_ascii() {
}

#[test]
#[available_gas(2000000)]
fn u32_to_ascii() {
// ------------------------------ max u32 test ------------------------------ //
let num: u32 = Bounded::MAX;
Expand All @@ -77,7 +73,6 @@ fn u32_to_ascii() {
}

#[test]
#[available_gas(2000000)]
fn u16_to_ascii() {
// ------------------------------ max u16 test ------------------------------ //
let num: u16 = Bounded::MAX;
Expand All @@ -88,7 +83,6 @@ fn u16_to_ascii() {
}

#[test]
#[available_gas(2000000)]
fn u8_to_ascii() {
// ------------------------------- max u8 test ------------------------------ //
let num: u8 = Bounded::MAX;
Expand Down
7 changes: 6 additions & 1 deletion packages/bytes/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ alexandria_data_structures = { path = "../data_structures" }
starknet.workspace = true

[dev-dependencies]
cairo_test.workspace = true
assert_macros = "0.1.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.28.0" }

[scripts]
test = "snforge test"
test-profiling = "snforge test --build-profile"
4 changes: 4 additions & 0 deletions packages/bytes/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
pub mod bytes;
pub mod storage;

#[cfg(target: 'test')]
mod test_utils;

#[cfg(test)]
mod tests;

pub mod utils;

pub use bytes::{Bytes, BytesTrait, BytesIndex};
Expand Down
1 change: 1 addition & 0 deletions packages/bytes/src/test_utils.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use alexandria_bytes::Bytes;
Loading
Loading