Skip to content

Commit

Permalink
[test] web3wagers#137 add new values to event
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgezerpa committed Oct 25, 2024
1 parent 0047aa2 commit 69daeb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ mod Fund {

#[derive(Drop, starknet::Event)]
pub struct NewVoteReceived {
#[key]
pub voter: ContractAddress,
pub fund: ContractAddress,
pub votes: u32
}


// *************************************************************************
// EXTERNALS
// *************************************************************************
Expand Down Expand Up @@ -121,7 +124,14 @@ mod Fund {
self.state.write(FundStates::RECOLLECTING_DONATIONS);
}

self.emit(NewVoteReceived { voter: get_caller_address() });
self
.emit(
NewVoteReceived {
voter: get_caller_address(),
fund: get_contract_address(),
votes: self.up_votes.read()
}
);
}
fn getUpVotes(self: @ContractState) -> u32 {
return self.up_votes.read();
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ fn test_new_fund() {
let expected_fund_class_hash = get_class_hash(fund_manager_contract.getFund(1));
let current_id = fund_manager_contract.getCurrentId();
assert(expected_fund_class_hash == fund_class_hash, 'Invalid fund address');
assert(current_id == 2 , 'Invalid current ID');
assert(current_id == 2, 'Invalid current ID');
}

0 comments on commit 69daeb9

Please sign in to comment.