Skip to content

Commit

Permalink
feat: add fund test event emit
Browse files Browse the repository at this point in the history
  • Loading branch information
juandiegocv27 committed Oct 30, 2024
1 parent 89b68fe commit e76ee76
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait IFund<TContractState> {
}

#[starknet::contract]
mod Fund {
pub mod Fund {
// *************************************************************************
// IMPORT
// *************************************************************************
Expand All @@ -41,7 +41,7 @@ mod Fund {
// *************************************************************************
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
pub enum Event {
DonationWithdraw: DonationWithdraw,
NewVoteReceived: NewVoteReceived,
DonationReceived: DonationReceived,
Expand Down
30 changes: 29 additions & 1 deletion contracts/tests/test_fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use starknet::syscalls::call_contract_syscall;

use snforge_std::{
declare, ContractClassTrait, start_cheat_caller_address_global, start_cheat_caller_address,
cheat_caller_address, CheatSpan
cheat_caller_address, CheatSpan, spy_events, EventSpyAssertionsTrait
};

use openzeppelin::utils::serde::SerializedAppend;
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};


use gostarkme::fund::Fund;
use gostarkme::fund::IFundDispatcher;
use gostarkme::fund::IFundDispatcherTrait;
use gostarkme::constants::{funds::{fund_manager_constants::FundManagerConstants},};
Expand Down Expand Up @@ -189,3 +191,29 @@ fn test_set_goal_unauthorized() {
// Change the goal without being the fund manager
dispatcher.setGoal(22);
}


#[test]
fn test_new_vote_received_event_emitted_successful() {
let contract_address = _setup_();
let dispatcher = IFundDispatcher { contract_address };

let mut spy = spy_events();

start_cheat_caller_address(contract_address, OTHER_USER());
dispatcher.receiveVote();

spy
.assert_emitted(
@array![
(
contract_address,
Fund::Event::NewVoteReceived(
Fund::NewVoteReceived {
voter: OTHER_USER(), fund: contract_address, votes: 1
}
)
)
]
);
}

0 comments on commit e76ee76

Please sign in to comment.