Skip to content

Commit

Permalink
Merge branch 'dev' into feat/182
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelAR committed Nov 3, 2024
2 parents 67e6899 + d410957 commit 59ec696
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/src/constants/funds/fund_constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub mod FundConstants {
pub const UP_VOTES_NEEDED: u32 = 100;
pub const INITIAL_UP_VOTES: u32 = 0;
pub const INITIAL_GOAL: u256 = 0;
pub const MINIMUM_GOAL: u256 = 500;
}
2 changes: 2 additions & 0 deletions contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod FundManager {
use starknet::class_hash::ClassHash;
use starknet::get_caller_address;
use openzeppelin::utils::serde::SerializedAppend;
use gostarkme::constants::{ funds::{fund_constants::FundConstants}, };


// ***************************************************************************************
Expand Down Expand Up @@ -71,6 +72,7 @@ pub mod FundManager {
#[abi(embed_v0)]
impl FundManagerImpl of super::IFundManager<ContractState> {
fn newFund(ref self: ContractState, name: ByteArray, goal: u256) {
assert(goal >= FundConstants::MINIMUM_GOAL, 'Goal must be at least 500');
let mut call_data: Array<felt252> = array![];
Serde::serialize(@self.current_id.read(), ref call_data);
Serde::serialize(@get_caller_address(), ref call_data);
Expand Down
11 changes: 11 additions & 0 deletions contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ fn REASON() -> ByteArray {
fn GOAL() -> u256 {
1000
}
fn BAD_GOAL() -> u256 {
400
}

fn _setup_() -> (ContractAddress, ClassHash) {
// Fund
Expand Down Expand Up @@ -82,6 +85,14 @@ fn test_new_fund() {
assert(current_id == 2, 'Invalid current ID');
}

#[test]
#[should_panic(expected: 'Goal must be at least 500')]
fn test_new_fund_bad_goal() {
start_cheat_caller_address_global(OWNER());
let (contract_address, _) = _setup_();
let fund_manager_contract = IFundManagerDispatcher { contract_address };
fund_manager_contract.newFund(NAME(), BAD_GOAL());
}

#[test]
fn test_fund_deployed_event() {
Expand Down

0 comments on commit 59ec696

Please sign in to comment.