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

feat: added unit tests for deposit and withdrawal functionalities. #12

Merged
merged 13 commits into from
Dec 1, 2024
3 changes: 2 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
notes.md
notes.md
.snfoundry_cache
107 changes: 107 additions & 0 deletions contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,116 @@ version = 1
name = "contract_strapex"
version = "0.1.0"
dependencies = [
"openzeppelin",
"snforge_std",
]

[[package]]
name = "openzeppelin"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_merkle_tree",
"openzeppelin_presets",
"openzeppelin_security",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_access"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_finance"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_access",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_governance"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"

[[package]]
name = "openzeppelin_presets"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_security"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"

[[package]]
name = "openzeppelin_token"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"

[[package]]
name = "openzeppelin_utils"
version = "0.19.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.19.0#8d49e8c445efd9bdc99b050c8b7d11ae5ad19628"

[[package]]
name = "snforge_scarb_plugin"
version = "0.33.0"
Expand Down
9 changes: 8 additions & 1 deletion contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ edition = "2023_10"
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.8.5"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.19.0" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.33.0" }
starknet = "2.8.2"
assert_macros = "2.8.5"

[[target.starknet-contract]]
casm = true
sierra = true

[scripts]
test = "snforge test"
6 changes: 3 additions & 3 deletions contracts/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod ownership_component;
mod strapex_contract;
mod strapex_factory;
pub mod ownership_component;
pub mod strapex_contract;
pub mod strapex_factory;
12 changes: 6 additions & 6 deletions contracts/src/strapex_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ trait IStrapex<TContractState> {
}

#[starknet::contract]
mod strapex_contract {
pub mod StrapexContract {
use contract_strapex::strapex_contract::IStrapex;
use core::traits::Into;
use core::box::BoxTrait;
Expand Down Expand Up @@ -75,15 +75,15 @@ mod strapex_contract {

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
pub enum Event {
OwnableEvent: ownable_component::Event,
Deposit: Deposit,
Withdraw: Withdraw,
FeeCollection: FeeCollection,
}

#[derive(Drop, starknet::Event)]
struct Deposit {
pub struct Deposit {
#[key]
from: ContractAddress,
#[key]
Expand All @@ -94,13 +94,13 @@ mod strapex_contract {
}

#[derive(Drop, starknet::Event)]
struct Withdraw {
pub struct Withdraw {
#[key]
Amount: u256,
}

#[derive(Drop, starknet::Event)]
struct FeeCollection {
pub struct FeeCollection {
#[key]
Amount: u256,
}
Expand Down Expand Up @@ -322,4 +322,4 @@ mod strapex_contract {
(caller, this, currentBalance)
}
}
}
}
4 changes: 2 additions & 2 deletions contracts/src/strapex_factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait IStrapexFactory<TContractState> {
}

#[starknet::contract]
mod strapex_factory {
mod StrapexFactory {
use core::traits::Into;
use core::array::ArrayTrait;
// Core StarkNet and contract utilities.
Expand Down Expand Up @@ -188,4 +188,4 @@ mod strapex_factory {
currentHash
}
}
}
}
1 change: 1 addition & 0 deletions contracts/tests/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod test_strapex_contract;
Loading