-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
523fe8e
commit ba5e274
Showing
4 changed files
with
12 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,20 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "alexandria_data_structures" | ||
version = "0.2.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014" | ||
dependencies = [ | ||
"alexandria_encoding", | ||
] | ||
|
||
[[package]] | ||
name = "alexandria_encoding" | ||
version = "0.1.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014" | ||
dependencies = [ | ||
"alexandria_math", | ||
"alexandria_numeric", | ||
] | ||
|
||
[[package]] | ||
name = "alexandria_math" | ||
version = "0.2.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014" | ||
dependencies = [ | ||
"alexandria_data_structures", | ||
] | ||
|
||
[[package]] | ||
name = "alexandria_numeric" | ||
version = "0.1.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014" | ||
dependencies = [ | ||
"alexandria_math", | ||
] | ||
|
||
[[package]] | ||
name = "cairo_lib" | ||
version = "0.2.0" | ||
source = "git+https://github.com/HerodotusDev/cairo-lib.git#a0c0ee4feeb4edb61e7a35d29595ad8647c3d469" | ||
|
||
[[package]] | ||
name = "contracts" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"alexandria_math", | ||
"cairo_lib", | ||
"openzeppelin", | ||
"pragma_lib", | ||
"snforge_std", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin" | ||
version = "0.8.0" | ||
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#441e6ce76ade91817068e4d4c5168dbd3ed20375" | ||
|
||
[[package]] | ||
name = "pragma_lib" | ||
version = "1.0.0" | ||
source = "git+https://github.com/astraly-labs/pragma-lib.git#24bb4da111ae7eb00e7cf40d4f1767c86d6447cd" | ||
version = "0.11.0" | ||
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.11.0#a83f36b23f1af6e160288962be4a2701c3ecbcda" | ||
|
||
[[package]] | ||
name = "snforge_std" | ||
version = "0.1.0" | ||
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.11.0#5465c41541c44a7804d16318fab45a2f0ccec9e7" | ||
version = "0.20.1" | ||
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.20.1#fea2db8f2b20148cc15ee34b08de12028eb42942" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1 @@ | ||
use contracts::IHelloStarknetSafeDispatcher; | ||
use contracts::IHelloStarknetSafeDispatcherTrait; | ||
|
||
use snforge_std::{declare, ContractClassTrait}; | ||
use starknet::ContractAddress; | ||
|
||
fn deploy_contract(name: felt252) -> ContractAddress { | ||
let contract = declare(name); | ||
contract.deploy(@ArrayTrait::new()).unwrap() | ||
} | ||
|
||
#[test] | ||
fn test_increase_balance() { | ||
let contract_address = deploy_contract('HelloStarknet'); | ||
|
||
let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address }; | ||
|
||
let balance_before = safe_dispatcher.get_balance().unwrap(); | ||
assert(balance_before == 0, 'Invalid balance'); | ||
|
||
safe_dispatcher.increase_balance(42).unwrap(); | ||
|
||
let balance_after = safe_dispatcher.get_balance().unwrap(); | ||
assert(balance_after == 42, 'Invalid balance'); | ||
} | ||
|
||
#[test] | ||
fn test_cannot_increase_balance_with_zero_value() { | ||
let contract_address = deploy_contract('HelloStarknet'); | ||
|
||
let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address }; | ||
|
||
let balance_before = safe_dispatcher.get_balance().unwrap(); | ||
assert(balance_before == 0, 'Invalid balance'); | ||
|
||
match safe_dispatcher.increase_balance(0) { | ||
Result::Ok(_) => panic_with_felt252('Should have panicked'), | ||
Result::Err(panic_data) => { | ||
assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0)); | ||
} | ||
}; | ||
} | ||
// contract test in here |