diff --git a/tests/basic.cairo b/tests/basic.cairo index db36a655..6f881507 100644 --- a/tests/basic.cairo +++ b/tests/basic.cairo @@ -1,58 +1,16 @@ use array::ArrayTrait; use core::traits::TryInto; use debug::PrintTrait; +use konoha::constants; -use konoha::contract::IGovernanceDispatcher; -use konoha::contract::IGovernanceDispatcherTrait; -use konoha::proposals::IProposalsDispatcher; -use konoha::proposals::IProposalsDispatcherTrait; +use konoha::contract::{IGovernanceDispatcher, IGovernanceDispatcherTrait}; +use konoha::proposals::{IProposalsDispatcher, IProposalsDispatcherTrait}; use konoha::upgrades::IUpgradesDispatcher; use konoha::upgrades::IUpgradesDispatcherTrait; -use snforge_std::{BlockId, declare, ContractClassTrait, ContractClass, start_prank, CheatTarget}; -use starknet::ContractAddress; - -//#[test] -//#[fork(url: "https://rpc.starknet-testnet.lava.build", block_id: BlockId::Number(904597))] -fn test_submit_proposal() { - let gov_contract_addr: ContractAddress = - 0x7ba1d4836a1142c09dde23cb39b2885fe350912591461b5764454a255bdbac6 - .try_into() - .unwrap(); - let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; - // corresponding govtoken: 0x05151bfdd47826df3669033ea7fb977d3b2d45c4f4d1c439a9edf4062bf34bfa - // has one holder, with 31 CARM: 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 - let _admin_addr: ContractAddress = - 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 - .try_into() - .unwrap(); - //start_prank(gov_contract_addr, admin_addr); - dispatcher.submit_proposal(0x00, 1); -} - - -// Raises the prop_id to 44, fixes prop_id now 0 -fn submit_44_signal_proposals() { - let gov_contract_addr: ContractAddress = - 0x001405ab78ab6ec90fba09e6116f373cda53b0ba557789a4578d8c1ec374ba0f - .try_into() - .unwrap(); - let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; - let scaling_address: ContractAddress = - 0x052df7acdfd3174241fa6bd5e1b7192cd133f8fc30a2a6ed99b0ddbfb5b22dcd - .try_into() - .unwrap(); - - let mut curr_prop: u8 = 0; - - loop { - if curr_prop == 44 { - break; - } - start_prank(CheatTarget::One(gov_contract_addr), scaling_address); - dispatcher.submit_proposal(42, 4); // for signal vote with payload 42 - curr_prop += 1; - } -} +use snforge_std::{ + BlockId, declare, ContractClassTrait, ContractClass, start_prank, CheatTarget, start_warp +}; +use starknet::{ContractAddress, get_block_timestamp}; // This proposes upgrading the current mainnet Carmine governance to the one in master, votes on it with multiple wallets and passes the upgrade turbo. @@ -71,45 +29,30 @@ fn test_upgrade_mainnet_to_master() { .try_into() .unwrap(); top_carm_holders.append(marek_address); - let scaling_address: ContractAddress = - 0x052df7acdfd3174241fa6bd5e1b7192cd133f8fc30a2a6ed99b0ddbfb5b22dcd - .try_into() - .unwrap(); - top_carm_holders.append(scaling_address); let ondrej_address: ContractAddress = 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 .try_into() .unwrap(); top_carm_holders.append(ondrej_address); - let carlote_address: ContractAddress = - 0x021b2b25dd73bc60b0549683653081f8963562cbe5cba2d123ec0cbcbf0913e4 - .try_into() - .unwrap(); - top_carm_holders.append(carlote_address); - let fifth_address: ContractAddress = - 0x02af7135154dc27d9311b79c57ccc7b3a6ed74efd0c2b81116e8eb49dbf6aaf8 + let team1_address: ContractAddress = + 0x06e2c2a5da2e5478b1103d452486afba8378e91f32a124f0712f09edd3ccd923 .try_into() .unwrap(); - top_carm_holders.append(fifth_address); - let sixth_address: ContractAddress = - 0x07824efd915baa421d93909bd7f24e36c022b5cfbc5af6687328848a6490ada7 + top_carm_holders.append(team1_address); + let team2_address: ContractAddress = + 0x00d79a15d84f5820310db21f953a0fae92c95e25d93cb983cc0c27fc4c52273c .try_into() .unwrap(); - top_carm_holders.append(sixth_address); + top_carm_holders.append(team2_address); let madman_address: ContractAddress = 0x06717eaf502baac2b6b2c6ee3ac39b34a52e726a73905ed586e757158270a0af .try_into() .unwrap(); top_carm_holders.append(madman_address); - let eighth_address: ContractAddress = - 0x03d1525605db970fa1724693404f5f64cba8af82ec4aab514e6ebd3dec4838ad - .try_into() - .unwrap(); - top_carm_holders.append(eighth_address); // declare current and submit proposal let new_contract: ContractClass = declare("Governance").expect('unable to declare governance'); - start_prank(CheatTarget::One(gov_contract_addr), scaling_address); + start_prank(CheatTarget::One(gov_contract_addr), team1_address); let new_prop_id = dispatcher.submit_proposal(new_contract.class_hash.into(), 1); loop { match top_carm_holders.pop_front() { @@ -120,6 +63,12 @@ fn test_upgrade_mainnet_to_master() { Option::None(()) => { break (); }, } }; + + //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); + assert(dispatcher.get_proposal_status(new_prop_id) == 1, 'proposal not passed!'); let upgrade_dispatcher = IUpgradesDispatcher { contract_address: gov_contract_addr };