Skip to content

Commit

Permalink
tests: add options via new proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka committed Oct 1, 2024
1 parent 08627a5 commit ab37067
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod contract;
mod options;
pub mod proposals;
pub mod staking;
mod traits;
pub mod traits;
mod types;
mod upgrades;
pub mod vecarm;
Expand Down
1 change: 1 addition & 0 deletions src/traits.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub trait IAMM<TContractState> {
fn set_pragma_checkpoint(ref self: TContractState, key: felt252);
fn set_pragma_required_checkpoints(ref self: TContractState);
fn upgrade(ref self: TContractState, new_implementation: ClassHash);
fn transfer_ownership(ref self: TContractState, new_owner: ContractAddress);
}

#[starknet::interface]
Expand Down
23 changes: 20 additions & 3 deletions tests/add_options_proposal.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use snforge_std::{
use starknet::{ContractAddress, get_block_timestamp};

use amm_governance::proposals::{IProposalsDispatcherTrait, IProposalsDispatcher};
use amm_governance::traits::{IAMMDispatcher, IAMMDispatcherTrait};

use konoha::upgrades::IUpgradesDispatcher;
use konoha::upgrades::IUpgradesDispatcherTrait;
Expand Down Expand Up @@ -55,6 +56,9 @@ fn get_option_calldata() -> @Span<felt252> {
#[test]
#[fork("MAINNET")]
fn test_add_custom_proposal() {

// # ADD CUSTOM PROPOSAL FOR ADDING OPTIONS

let _option_deployer_contract_class: ContractClass = declare("OptionDeployer")
.expect('unable to declare op dep'); // need to declare, is not used
let arbitrary_proposal_contract_class: ContractClass = declare("ArbitraryProposalAddOptions")
Expand Down Expand Up @@ -95,18 +99,31 @@ fn test_add_custom_proposal() {

start_warp(CheatTarget::One(gov_addr), warped_timestamp);
assert(props.get_proposal_status(prop_id) == 1, 'arbitrary proposal not passed');
println!("add arbitrary proposal passed");

let upgrades = IUpgradesDispatcher { contract_address: gov_addr };

upgrades.apply_passed_proposal(prop_id);

prank(CheatTarget::One(gov_addr), user1, CheatSpan::TargetCalls(1));
println!("custom proposal added");

// # TRANSFER OWNERSHIP OF AMM

let amm_owner_address: ContractAddress = 0x74fd7da23e21f0f0479adb435221b23f57ca4c32a0c68aad9409a41c27f3067.try_into().unwrap();
let amm_address: ContractAddress = 0x047472e6755afc57ada9550b6a3ac93129cc4b5f98f51c73e0644d129fd208d9.try_into().unwrap();
let amm = IAMMDispatcher { contract_address: amm_address };

prank(CheatTarget::One(amm_address), amm_owner_address, CheatSpan::TargetCalls(1));
amm.transfer_ownership(gov_addr);

println!("AMM ownership transfered");

// # ADD OPTIONS VIA NEW CUSTOM PROPOSAL

let add_options_calldata = get_option_calldata();

println!("add options calldata: {:?}", add_options_calldata);

prank(CheatTarget::One(gov_addr), user1, CheatSpan::TargetCalls(1));
// propose arbitrary proposal
let prop_id2: felt252 = props.submit_custom_proposal(0x2, *add_options_calldata).into();

Expand All @@ -132,5 +149,5 @@ fn test_add_custom_proposal() {

upgrades.apply_passed_proposal(prop_id2);

println!("add options applied");
println!("options added");
}

0 comments on commit ab37067

Please sign in to comment.