-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #47 --------- Co-authored-by: Artur Michałek <52135326+cptartur@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
165 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
starknet-foundry/crates/forge/tests/data/deploy_error_handling_test/Scarb.toml
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "deploy_error_handling_test" | ||
version = "0.1.0" | ||
|
||
[[target.starknet-contract]] | ||
sierra = true | ||
|
||
[dependencies] | ||
starknet = "2.0.1" |
15 changes: 15 additions & 0 deletions
15
starknet-foundry/crates/forge/tests/data/deploy_error_handling_test/src/lib.cairo
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[starknet::contract] | ||
mod PanickingConstructor { | ||
use array::ArrayTrait; | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState) { | ||
let mut panic_data = ArrayTrait::new(); | ||
panic_data.append('PANIK'); | ||
panic_data.append('DEJTA'); | ||
panic(panic_data); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...crates/forge/tests/data/deploy_error_handling_test/tests/test_deploy_error_handling.cairo
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use result::ResultTrait; | ||
use cheatcodes::RevertedTransactionTrait; | ||
use cheatcodes::PreparedContract; | ||
use array::ArrayTrait; | ||
|
||
#[test] | ||
fn test_deploy_error_handling() { | ||
let class_hash = declare('PanickingConstructor').expect('Could not declare'); | ||
let prepared_contract = PreparedContract { | ||
contract_address: 'addr', | ||
class_hash: class_hash, | ||
constructor_calldata: @ArrayTrait::new() | ||
}; | ||
|
||
match deploy(prepared_contract) { | ||
Result::Ok(_) => panic_with_felt252('Should have panicked'), | ||
Result::Err(x) => { | ||
assert(*x.panic_data.at(0_usize) == 'PANIK', *x.panic_data.at(0_usize)); | ||
assert(*x.panic_data.at(1_usize) == 'DEJTA', *x.panic_data.at(1_usize)); | ||
} | ||
} | ||
} |
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