Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Nov 7, 2023
1 parent 2eb92b6 commit d7a7138
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use governance::timelock::{ITimelockDispatcher};
#[derive(Copy, Drop, Serde)]
struct AirdropConfig {
root: felt252,
total: u256,
total: u128,
}

#[derive(Copy, Drop, Serde)]
Expand Down Expand Up @@ -89,6 +89,8 @@ mod Factory {
)
.unwrap();

let erc20 = IERC20Dispatcher { contract_address: token_address };

let mut governor_constructor_args: Array<felt252> = ArrayTrait::new();
Serde::serialize(
@(token_address, params.governor_config), ref governor_constructor_args
Expand All @@ -115,16 +117,17 @@ mod Factory {
)
.unwrap();

assert(config.total <= params.total_supply, 'AIRDROP_GT_SUPPLY');

(
Option::Some(IAirdropDispatcher { contract_address: airdrop_address }),
params.total_supply.into() - config.total
params.total_supply - config.total
)
},
Option::None => { (Option::None, params.total_supply.into()) }
Option::None => { (Option::None, params.total_supply) }
};

IERC20Dispatcher { contract_address: token_address }
.transfer(get_caller_address(), remaining_amount);
erc20.transfer(get_caller_address(), remaining_amount.into());

let mut timelock_constructor_args: Array<felt252> = ArrayTrait::new();
Serde::serialize(
Expand Down
32 changes: 26 additions & 6 deletions src/factory_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn deploy() -> IFactoryDispatcher {


#[test]
#[available_gas(3000000)]
#[available_gas(30000000)]
fn test_deploy() {
let factory = deploy();

Expand All @@ -67,14 +67,34 @@ fn test_deploy() {
quorum: 1000,
proposal_creation_threshold: 100,
},
timelock_config: TimelockConfig { window: 60, delay: 320, }
timelock_config: TimelockConfig { delay: 320, window: 60, }
}
);

let erc20 = IERC20Dispatcher { contract_address: result.token.contract_address };

assert(erc20.name() == 'token', 'name');
assert(erc20.symbol() == 'tk', 'symbol');
assert(erc20.decimals() == 18, 'decimals');
assert(erc20.totalSupply() == 5678, 'totalSupply');
assert(erc20.balance_of(get_contract_address()) == 5678 - 1111, 'deployer balance');
// assert(erc20.balance_of(result.airdrop.unwrap().contract_address) == 1111, 'airdrop balance');

assert(
result.governor.get_voting_token().contract_address == result.token.contract_address,
'voting_token'
);
assert(
IERC20Dispatcher { contract_address: result.token.contract_address }
.balance_of(get_contract_address()) == 5678
- 1111,
'balance'
result
.governor
.get_config() == GovernorConfig {
voting_start_delay: 0,
voting_period: 180,
voting_weight_smoothing_duration: 30,
quorum: 1000,
proposal_creation_threshold: 100,
},
'governor.config'
);
assert(result.timelock.get_configuration() == (320, 60), 'timelock config');
}
2 changes: 1 addition & 1 deletion src/governor.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct ProposalInfo {
nay: u128,
}

#[derive(Copy, Drop, Serde, starknet::Store)]
#[derive(Copy, Drop, Serde, starknet::Store, PartialEq)]
struct Config {
// how long after a proposal is created does voting start
voting_start_delay: u64,
Expand Down

0 comments on commit d7a7138

Please sign in to comment.