diff --git a/Scarb.toml b/Scarb.toml index e1bebdc..1ee5aef 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -25,6 +25,11 @@ name = "MAINNET" url = "http://178.32.172.148:6060/v0_7" block_id.tag = "Latest" +[[tool.snforge.fork]] +name = "MAINNET_BEFORE_UPGRADE_TO_KONOHA" +url = "http://178.32.172.148:6060/v0_7" +block_id.number = "652000" + [[tool.snforge.fork]] name = "SEPOLIA" url = "http://178.32.172.148:6062/v0_7" diff --git a/tests/lib.cairo b/tests/lib.cairo index 6944483..038e712 100644 --- a/tests/lib.cairo +++ b/tests/lib.cairo @@ -1,5 +1,5 @@ mod test_prop_pass; -mod unstake_airdrop; +//mod unstake_airdrop; //mod add_options; mod upgrade; pub mod utils; diff --git a/tests/upgrade.cairo b/tests/upgrade.cairo index fdaedd2..e7114a4 100644 --- a/tests/upgrade.cairo +++ b/tests/upgrade.cairo @@ -6,6 +6,7 @@ use amm_governance::contract::{ use amm_governance::staking::{IStakingDispatcher, IStakingDispatcherTrait}; use amm_governance::vecarm::{IVeCRMDispatcher, IVeCRMDispatcherTrait}; use core::num::traits::Zero; +use konoha::constants; use konoha::contract::IGovernanceDispatcher; use konoha::contract::IGovernanceDispatcherTrait; @@ -17,15 +18,15 @@ use konoha::upgrades::IUpgradesDispatcher; use konoha::upgrades::IUpgradesDispatcherTrait; use openzeppelin::upgrades::interface::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, CheatTarget, prank, CheatSpan, - roll, start_warp + BlockId, declare, ContractClassTrait, ContractClass, start_prank, stop_prank, CheatTarget, + prank, CheatSpan, roll, start_warp }; use starknet::{ClassHash, ContractAddress, get_block_timestamp, get_block_number}; use super::utils::vote_on_proposal; -// commented out as it fails with 'No voting power' for now -//#[test] -//#[fork("MAINNET")] + +#[test] +#[fork("MAINNET")] fn test_upgrade_to_master() { let gov_contract_addr: ContractAddress = 0x001405ab78ab6ec90fba09e6116f373cda53b0ba557789a4578d8c1ec374ba0f @@ -37,24 +38,21 @@ fn test_upgrade_to_master() { let gov_class: ContractClass = declare("Governance").expect('unable to declare!'); assert(Zero::is_non_zero(@gov_class.class_hash), 'new classhash zero??'); let user2_address: ContractAddress = - 0x052df7acdfd3174241fa6bd5e1b7192cd133f8fc30a2a6ed99b0ddbfb5b22dcd + 0x06e2c2a5da2e5478b1103d452486afba8378e91f32a124f0712f09edd3ccd923 .try_into() .unwrap(); - start_prank(CheatTarget::One(gov_contract_addr), user2_address); + prank(CheatTarget::One(gov_contract_addr), user2_address, CheatSpan::TargetCalls(1)); let new_prop_id = dispatcher.submit_proposal(gov_class.class_hash.into(), 1); println!("Prop submitted: {:?}", new_prop_id); vote_on_proposal(gov_contract_addr, new_prop_id.try_into().unwrap()); + //simulate passage of time + let current_timestamp = get_block_timestamp(); + let end_timestamp = current_timestamp + constants::PROPOSAL_VOTING_SECONDS; + start_warp(CheatTarget::One(gov_contract_addr), end_timestamp + 1); + let upgrade_dispatcher = IUpgradesDispatcher { contract_address: gov_contract_addr }; upgrade_dispatcher.apply_passed_proposal(new_prop_id); - let amm_governance = IMigrateDispatcher { contract_address: gov_contract_addr }; - amm_governance.add_custom_proposals(); - println!("Checking if new gov is healthy..."); - assert(check_if_healthy(gov_contract_addr), 'new gov not healthy'); - upgrade_amm( - gov_contract_addr, - 0x0239b6f9eeb5ffba1df4da7f33e116d3603d724283bc01338125eed82964e729.try_into().unwrap() - ); } fn test_deposit_to_amm_from_treasury(gov_contract_addr: ContractAddress) { @@ -139,7 +137,7 @@ fn test_upgrade_amm_back(amm: ContractAddress, owner: ContractAddress, new_class #[test] -#[fork("MAINNET")] +#[fork("MAINNET_BEFORE_UPGRADE_TO_KONOHA")] fn scenario_airdrop_staked_carm() { let gov_addr: ContractAddress = 0x001405ab78ab6ec90fba09e6116f373cda53b0ba557789a4578d8c1ec374ba0f diff --git a/tests/utils.cairo b/tests/utils.cairo index 919a8a3..851ebf2 100644 --- a/tests/utils.cairo +++ b/tests/utils.cairo @@ -21,30 +21,20 @@ pub(crate) fn vote_on_proposal(gov_contract_addr: ContractAddress, prop_id: u32) .unwrap(); top_carm_holders.append(user1_address); let user2_address: ContractAddress = - 0x052df7acdfd3174241fa6bd5e1b7192cd133f8fc30a2a6ed99b0ddbfb5b22dcd + 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 .try_into() .unwrap(); top_carm_holders.append(user2_address); let user3_address: ContractAddress = - 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 + 0x06e2c2a5da2e5478b1103d452486afba8378e91f32a124f0712f09edd3ccd923 .try_into() .unwrap(); top_carm_holders.append(user3_address); - let carlote_address: ContractAddress = - 0x021b2b25dd73bc60b0549683653081f8963562cbe5cba2d123ec0cbcbf0913e4 - .try_into() - .unwrap(); - top_carm_holders.append(carlote_address); - let fifth_address: ContractAddress = - 0x02af7135154dc27d9311b79c57ccc7b3a6ed74efd0c2b81116e8eb49dbf6aaf8 - .try_into() - .unwrap(); - top_carm_holders.append(fifth_address); - let sixth_address: ContractAddress = - 0x07824efd915baa421d93909bd7f24e36c022b5cfbc5af6687328848a6490ada7 + let user4_address: ContractAddress = + 0x00d79a15d84f5820310db21f953a0fae92c95e25d93cb983cc0c27fc4c52273c .try_into() .unwrap(); - top_carm_holders.append(sixth_address); + top_carm_holders.append(user4_address); let madman_address: ContractAddress = 0x06717eaf502baac2b6b2c6ee3ac39b34a52e726a73905ed586e757158270a0af .try_into()