Skip to content

Commit

Permalink
Merge pull request #174 from sasasamaes/dev
Browse files Browse the repository at this point in the history
add test_fund_deployed_event in test_fund_manager.cairo and add pub f…
  • Loading branch information
EmmanuelAR authored Nov 1, 2024
2 parents 8c19158 + 08568f2 commit 3298bf5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait IFundManager<TContractState> {
}

#[starknet::contract]
mod FundManager {
pub mod FundManager {
// ***************************************************************************************
// IMPORT
// ***************************************************************************************
Expand Down
37 changes: 36 additions & 1 deletion contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use starknet::class_hash::{ClassHash};
use starknet::syscalls::deploy_syscall;

use snforge_std::{
ContractClass, declare, ContractClassTrait, start_cheat_caller_address_global, get_class_hash
ContractClass, declare, ContractClassTrait, start_cheat_caller_address_global, get_class_hash,
spy_events, EventSpyAssertionsTrait
};

use openzeppelin::utils::serde::SerializedAppend;

use gostarkme::fundManager::IFundManagerDispatcher;
use gostarkme::fundManager::IFundManagerDispatcherTrait;
use gostarkme::fundManager::FundManager;

fn ID() -> u128 {
1
Expand Down Expand Up @@ -79,3 +81,36 @@ fn test_new_fund() {
assert(expected_fund_class_hash == fund_class_hash, 'Invalid fund address');
assert(current_id == 2, 'Invalid current ID');
}


#[test]
fn test_fund_deployed_event() {
let (contract_address, _) = _setup_();
let fund_manager_contract = IFundManagerDispatcher { contract_address };

start_cheat_caller_address_global(OWNER());

let mut spy = spy_events();

let current_id = fund_manager_contract.getCurrentId();
fund_manager_contract.newFund(NAME(), GOAL());

let expected_fund_class_hash = fund_manager_contract.getFund(1);

spy
.assert_emitted(
@array![
(
contract_address,
FundManager::Event::FundDeployed(
FundManager::FundDeployed {
fund_address: expected_fund_class_hash,
fund_id: current_id,
owner: OWNER(),
}
)
)
]
);
}

0 comments on commit 3298bf5

Please sign in to comment.