Skip to content

Commit

Permalink
feat: Adding Test visibility (#113)
Browse files Browse the repository at this point in the history
* feat: try to panic by calling private fn

* feat: removing panic test

* nit: format

* nit
  • Loading branch information
julienbrs authored Nov 16, 2023
1 parent ea2ba4e commit 362359f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion listings/ch00-getting-started/visibility/src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
mod tests { // TODO
mod tests {
use visibility::{visibility::{IExampleContract, ExampleContract}};

use starknet::{
ContractAddress, get_contract_address, contract_address_const, call_contract_syscall,
testing::{set_contract_address}
};

fn setup() -> ExampleContract::ContractState {
let mut state = ExampleContract::contract_state_for_testing();
let contract_address = contract_address_const::<0x1>();
set_contract_address(contract_address);
state
}

#[test]
#[available_gas(2000000000)]
fn can_call_set_and_get() {
let mut state = setup();
let init_value: u32 = 42;
state.set(init_value);
let received_value = state.get();

assert(received_value == init_value, 'wrong value received');
}
}

0 comments on commit 362359f

Please sign in to comment.