Skip to content

Commit

Permalink
use snforge for tests (#69)
Browse files Browse the repository at this point in the history
* use snforge for tests

* enable test via github action

* use snforge test

* fix github action test run

* add snfoundry

* use snforge instead of scarb

* remove scarb used

* scarb with snfoundry

* use snforge on run

* snforge test run

* scarb test

* remove second use step

* use asdf to run scarb and snforge

* run scarb test before snforge

* use snforge test

* fix snforge test

* fix snforge test

* run scarb before snforge

* change test command

* run snforge in step

* remove step

* run scarb test after scarb build

* check scarb version in test section

* remove ignore flag on test

* run snforge with 0.23.0 version

* fix formatting
  • Loading branch information
mubarak23 authored May 23, 2024
1 parent 67fc99f commit 1a09aee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/starknet-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
- name: Scarb version
run: scarb --version
working-directory: onchain
- uses: actions/checkout@v3
- uses: foundry-rs/setup-snfoundry@v3
with:
starknet-foundry-version: '0.23.0'
- name: Run cairo tests
run: scarb test
run: snforge test
working-directory: onchain
6 changes: 3 additions & 3 deletions onchain/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ starknet = "2.6.3"
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.21.0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.23.0" }

#[lib]

# [scripts]
# test = "test"
[scripts]
test = "snforge test"

[[target.starknet-contract]]
casm = true
Expand Down
8 changes: 3 additions & 5 deletions onchain/src/social/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {


fn deploy_social_account() -> ContractAddress {
let contract = declare("SocialAccount");
let contract = declare("SocialAccount").unwrap();

let mut social_account_calldata = array![];
public_key.serialize(ref social_account_calldata);
Expand All @@ -106,7 +106,7 @@ mod tests {

let mut spy = spy_events(SpyOn::One(address));

let deployed_contract_address = contract.deploy(@social_account_calldata).unwrap();
let (contract_address, _) = contract.deploy(@social_account_calldata).unwrap();

spy.fetch_events();

Expand All @@ -118,13 +118,11 @@ mod tests {
let event_key = (*event.keys.at(1)).into();

assert(event_key == public_key, 'Wrong Public Key');

deployed_contract_address
contract_address
}


#[test]
#[ignore]
fn test_get_public_key() {
let contract_address = deploy_social_account();
let dispatcher = ISocialAccountDispatcher { contract_address };
Expand Down

0 comments on commit 1a09aee

Please sign in to comment.