From 6245e12b837e54e19048cb7ffaf3b0d9562f5109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sojka?= Date: Tue, 6 Aug 2024 11:53:31 +0000 Subject: [PATCH] Update snforge --- .devcontainer/devcontainer.json | 2 +- Scarb.lock | 8 ++++---- Scarb.toml | 4 ++-- tests/airdrop_tests.cairo | 18 ++++++++--------- tests/basic.cairo | 8 ++++---- tests/proposals_tests.cairo | 34 ++++++++++++++++----------------- tests/setup.cairo | 10 +++++----- tests/staking_tests.cairo | 14 +++++++------- tests/test_streaming.cairo | 10 +++++----- tests/test_treasury.cairo | 6 +++--- tests/vesting.cairo | 24 +++++++++++------------ 11 files changed, 69 insertions(+), 69 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 46d09606..2c951b04 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.6.3; curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh; snfoundryup -v 0.23.0", + "postCreateCommand": "curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.7.0; curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh; snfoundryup -v 0.27.0", "customizations": { "vscode": { "extensions": [ diff --git a/Scarb.lock b/Scarb.lock index 2f30d287..451241f9 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -11,10 +11,10 @@ dependencies = [ [[package]] name = "openzeppelin" -version = "0.10.0" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.10.0#d77082732daab2690ba50742ea41080eb23299d3" +version = "0.14.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.14.0#f091c4f51ddeb10297db984acae965328c5a4e5b" [[package]] name = "snforge_std" -version = "0.23.0" -source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.23.0#f2bff8f796763ada77fe6033ec1b034ceee22abd" +version = "0.27.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.27.0#2d99b7c00678ef0363881ee0273550c44a9263de" diff --git a/Scarb.toml b/Scarb.toml index 4b22e4dc..46433e28 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -6,10 +6,10 @@ cairo-version = "2.6.3" [dependencies] starknet = ">=2.0.0" -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.10.0" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.14.0" } [dev-dependencies] -snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.23.0" } +snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.27.0" } [lib] diff --git a/tests/airdrop_tests.cairo b/tests/airdrop_tests.cairo index 4a9c1c8f..69a80a8b 100644 --- a/tests/airdrop_tests.cairo +++ b/tests/airdrop_tests.cairo @@ -4,7 +4,7 @@ // use governance::airdrop::{airdrop, IAirdropDispatcher, IAirdropDispatcherTrait}; // use airdrop::STRK_ADDRESS; // use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; -// use snforge_std::{ContractClassTrait, declare, start_prank, CheatTarget}; +// use snforge_std::{ContractClassTrait, declare, start_cheat_caller_address, CheatTarget}; // use starknet::{ContractAddress, deploy_syscall}; // const ADMIN_ADDR: felt252 = 0x42; @@ -25,12 +25,12 @@ // let airdrop_contract = deploy(); // let token_contract = deploy_token(airdrop_contract.contract_address); -// start_prank( +// start_cheat_caller_address( // CheatTarget::One(airdrop_contract.contract_address), ADMIN_ADDR.try_into().unwrap() // ); // airdrop_contract.add_root(valid_root); -// start_prank(CheatTarget::One(airdrop_contract.contract_address), CLAIMEE_1.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(airdrop_contract.contract_address), CLAIMEE_1.try_into().unwrap()); // let initial_proof = array![valid_proof_element]; // airdrop_contract.claim(CLAIMEE_1, valid_claim_amount, initial_proof.span()); // assert( @@ -50,10 +50,10 @@ // fn test_claim_invalid_proof() { // let contract = deploy(); // deploy_token(contract.contract_address); -// start_prank(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); // contract.add_root(0xf7c8d3f309262572ad35df8ff6c33f24d8114c60eac3bc27bf42382ca82faf); -// start_prank(CheatTarget::One(contract.contract_address), CLAIMEE_1.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), CLAIMEE_1.try_into().unwrap()); // let proof = array![0x2a18afb0550a011d54ca3940648e59894c06e4c3d0a611256c0b575bd528b3b, 0x1]; // contract.claim(0x88, proof.span()); // } @@ -62,20 +62,20 @@ // fn test_update_root_and_claim_attempts() { // let contract = deploy(); // let tok = deploy_token(contract.contract_address); -// start_prank(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); // // add intial root and valid claim // contract.add_root(initial_root); -// start_prank(CheatTarget::One(contract.contract_address), CLAIMEE_1.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), CLAIMEE_1.try_into().unwrap()); // contract.claim(claim_amount, valid_proof_for_initial_root.span()); // assert(tok.balance_of(CLAIMEE_1.try_into().unwrap()) == claim_amount, 'initial claim failed'); // // update root -// start_prank(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), ADMIN_ADDR.try_into().unwrap()); // contract.add_root(new_root); // // claim with old root + new proof, should fail -// start_prank(CheatTarget::One(contract.contract_address), CLAIMEE_2.try_into().unwrap()); +// start_cheat_caller_address(CheatTarget::One(contract.contract_address), CLAIMEE_2.try_into().unwrap()); // contract.claim(claim_amount, new_proof_not_matching_old_root.span()); // // check fail : to do, use should panic ? diff --git a/tests/basic.cairo b/tests/basic.cairo index 6f881507..b2a8fdca 100644 --- a/tests/basic.cairo +++ b/tests/basic.cairo @@ -8,7 +8,7 @@ use konoha::proposals::{IProposalsDispatcher, IProposalsDispatcherTrait}; use konoha::upgrades::IUpgradesDispatcher; use konoha::upgrades::IUpgradesDispatcherTrait; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, CheatTarget, start_warp + BlockId, declare, ContractClassTrait, ContractClass, start_cheat_caller_address, CheatTarget, start_cheat_block_timestamp }; use starknet::{ContractAddress, get_block_timestamp}; @@ -52,12 +52,12 @@ fn test_upgrade_mainnet_to_master() { // declare current and submit proposal let new_contract: ContractClass = declare("Governance").expect('unable to declare governance'); - start_prank(CheatTarget::One(gov_contract_addr), team1_address); + start_cheat_caller_address(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() { Option::Some(holder) => { - start_prank(CheatTarget::One(gov_contract_addr), holder); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), holder); dispatcher.vote(new_prop_id, 1); }, Option::None(()) => { break (); }, @@ -67,7 +67,7 @@ fn test_upgrade_mainnet_to_master() { //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); + start_cheat_block_timestamp(CheatTarget::One(gov_contract_addr), end_timestamp + 1); assert(dispatcher.get_proposal_status(new_prop_id) == 1, 'proposal not passed!'); diff --git a/tests/proposals_tests.cairo b/tests/proposals_tests.cairo index 60415994..1f2bb163 100644 --- a/tests/proposals_tests.cairo +++ b/tests/proposals_tests.cairo @@ -16,7 +16,7 @@ use openzeppelin::token::erc20::interface::{ IERC20CamelOnlyDispatcherTrait }; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget, + BlockId, declare, ContractClassTrait, ContractClass, start_cheat_caller_address, start_cheat_block_timestamp, CheatTarget, prank, CheatSpan }; use starknet::ContractAddress; @@ -41,10 +41,10 @@ fn test_express_proposal() { let dispatcher = IProposalsDispatcher { contract_address: gov.contract_address }; - start_prank(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); - start_prank(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); dispatcher.vote(prop_id, 1); assert!(dispatcher.get_proposal_status(prop_id) == 1, "proposal not passed!"); @@ -57,13 +57,13 @@ fn test_proposal_expiry() { stake_all(gov.contract_address, floating, admin_addr.try_into().unwrap()); let dispatcher = IProposalsDispatcher { contract_address: gov.contract_address }; - start_prank(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); //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_address), end_timestamp + 1); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), end_timestamp + 1); let status = dispatcher.get_proposal_status(prop_id); assert!(status == constants::MINUS_ONE, "proposal not expired!"); @@ -88,7 +88,7 @@ fn test_vote_on_expired_proposal() { //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_address), end_timestamp + 1); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), end_timestamp + 1); prank( CheatTarget::One(gov.contract_address), @@ -142,7 +142,7 @@ fn test_vote_on_quorum_not_met() { assert(total_votes < quorum_threshold, 'Total votes >= quorum threshold'); 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); + start_cheat_block_timestamp(CheatTarget::One(gov_contract_addr), end_timestamp + 1); assert( dispatcher.get_proposal_status(prop_id) == constants::MINUS_ONE, 'Proposal pass & quorum not met' @@ -220,7 +220,7 @@ fn test_delegate_vote_with_incorrect_calldata() { let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let mut calldata: Array<(ContractAddress, u128)> = ArrayTrait::new(); let addr: felt252 = 0x4; calldata.append((addr.try_into().unwrap(), 50000.try_into().unwrap())); @@ -238,10 +238,10 @@ fn test_withdraw_delegation_with_incorrect_calldata() { let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; stake_all(gov.contract_address, floating, admin_addr.try_into().unwrap()); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); - start_prank(CheatTarget::One(gov_contract_addr), first_address.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), first_address.try_into().unwrap()); let mut calldata: Array<(ContractAddress, u128)> = ArrayTrait::new(); calldata.append((second_address.try_into().unwrap(), 50000.try_into().unwrap())); dispatcher @@ -323,10 +323,10 @@ fn test_delegate_vote_and_delegation_withdrawal() { dispatcher.delegate_vote(second_address.try_into().unwrap(), calldata, 1); stake_all(gov.contract_address, floating, admin_addr.try_into().unwrap()); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); - start_prank(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); dispatcher.vote(prop_id, 1); prank( @@ -365,7 +365,7 @@ fn test_withdraw_more_than_delegated_amount() { let calldata: Array<(ContractAddress, u128)> = ArrayTrait::new(); dispatcher.delegate_vote(second_address.try_into().unwrap(), calldata, 10.try_into().unwrap()); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); prank( @@ -404,7 +404,7 @@ fn test_full_withdraw_and_vote() { dispatcher.delegate_vote(second_address.try_into().unwrap(), calldata, 10.try_into().unwrap()); stake_all(gov.contract_address, floating, admin_addr.try_into().unwrap()); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(42, 1); prank( @@ -416,7 +416,7 @@ fn test_full_withdraw_and_vote() { calldata.append((second_address.try_into().unwrap(), 10)); dispatcher.withdraw_delegation(second_address.try_into().unwrap(), calldata, 10, prop_id); - start_prank(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); dispatcher.vote(prop_id, 1); } @@ -428,7 +428,7 @@ fn test_successful_proposal_submission() { let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; stake_all(gov.contract_address, floating, admin_addr.try_into().unwrap()); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id_1: u128 = dispatcher.submit_proposal(42, 1).try_into().unwrap(); let prop_id_2: u128 = dispatcher.submit_proposal(43, 1).try_into().unwrap(); @@ -463,7 +463,7 @@ fn test_add_comment_on_non_live_proposal() { //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); + start_cheat_block_timestamp(CheatTarget::One(gov_contract_addr), end_timestamp + 1); IDiscussionDispatcher { contract_address: gov_contract_addr } .add_comment(prop_id.try_into().unwrap(), ipfs_hash); diff --git a/tests/setup.cairo b/tests/setup.cairo index 88584a11..f99be6cd 100644 --- a/tests/setup.cairo +++ b/tests/setup.cairo @@ -16,7 +16,7 @@ use konoha::upgrades::IUpgradesDispatcherTrait; use openzeppelin::token::erc20::interface::IERC20; use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget + BlockId, declare, ContractClassTrait, ContractClass, start_cheat_caller_address, start_cheat_block_timestamp, CheatTarget }; use starknet::ContractAddress; use starknet::get_block_timestamp; @@ -92,14 +92,14 @@ fn test_vote_upgrade_root(new_merkle_root: felt252) { let dispatcher = IProposalsDispatcher { contract_address: gov_contract_addr }; - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); let prop_id = dispatcher.submit_proposal(new_merkle_root, 3); - start_prank(CheatTarget::One(gov_contract_addr), first_address.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), first_address.try_into().unwrap()); dispatcher.vote(prop_id, 1); - start_prank(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), second_address.try_into().unwrap()); dispatcher.vote(prop_id, 1); - start_prank(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); + start_cheat_caller_address(CheatTarget::One(gov_contract_addr), admin_addr.try_into().unwrap()); dispatcher.vote(prop_id, 1); assert(dispatcher.get_proposal_status(prop_id) == 1, 'proposal not passed!'); diff --git a/tests/staking_tests.cairo b/tests/staking_tests.cairo index 5adf5859..9123e297 100644 --- a/tests/staking_tests.cairo +++ b/tests/staking_tests.cairo @@ -3,8 +3,8 @@ use konoha::staking::{IStakingDispatcher, IStakingDispatcherTrait}; use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, CheatTarget, prank, CheatSpan, start_warp, - stop_warp + BlockId, declare, ContractClassTrait, ContractClass, CheatTarget, prank, CheatSpan, start_cheat_block_timestamp, + stop_cheat_block_timestamp }; use starknet::{ContractAddress, get_block_timestamp}; use super::setup::{admin_addr, first_address, second_address, deploy_governance_and_both_tokens}; @@ -70,9 +70,9 @@ fn test_basic_stake_unstake() { let stake_id = staking.stake(ONE_MONTH, balance_of_staker); let current_timestamp = get_block_timestamp(); - start_warp(CheatTarget::One(gov.contract_address), current_timestamp + ONE_MONTH + 1); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), current_timestamp + ONE_MONTH + 1); staking.unstake(stake_id); - stop_warp(CheatTarget::One(gov.contract_address)); + stop_cheat_block_timestamp(CheatTarget::One(gov.contract_address)); } #[test] @@ -98,7 +98,7 @@ fn test_multiple_overlapping_stake_unstake() { assert(voting.balance_of(admin) == 420 + 2342, 'wrong bal yearone+monthone'); assert(staking.get_total_voting_power(admin) == 420 + 2342, 'voting power baad'); - start_warp(CheatTarget::One(gov.contract_address), time_zero + ONE_MONTH + 1); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), time_zero + ONE_MONTH + 1); assert(staking.get_total_voting_power(admin) == 2342, 'voting power baaad'); prank(CheatTarget::One(gov.contract_address), admin, CheatSpan::TargetCalls(1)); staking.unstake(stake_id_month_one); @@ -110,9 +110,9 @@ fn test_multiple_overlapping_stake_unstake() { prank(CheatTarget::One(gov.contract_address), admin, CheatSpan::TargetCalls(1)); let stake_id_month_one_three_months = staking.stake(ONE_MONTH * 3, 101); assert(voting.balance_of(admin) == 2342 + 121, 'wrong bal yearone+monthtwo'); - stop_warp(CheatTarget::One(gov.contract_address)); + stop_cheat_block_timestamp(CheatTarget::One(gov.contract_address)); - start_warp(CheatTarget::One(gov.contract_address), time_zero + ONE_YEAR * 4 + 1); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), time_zero + ONE_YEAR * 4 + 1); assert(staking.get_total_voting_power(admin) == 0, 'voting power baaaaad'); prank(CheatTarget::One(gov.contract_address), admin, CheatSpan::TargetCalls(1)); staking.unstake(stake_id_year); diff --git a/tests/test_streaming.cairo b/tests/test_streaming.cairo index 7b5b5df8..593f6df7 100644 --- a/tests/test_streaming.cairo +++ b/tests/test_streaming.cairo @@ -12,7 +12,7 @@ use konoha::vesting::{IVestingDispatcher, IVestingDispatcherTrait, IVesting}; use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget, + BlockId, declare, ContractClassTrait, ContractClass, start_cheat_caller_address, start_cheat_block_timestamp, CheatTarget, prank, CheatSpan }; use starknet::{get_block_timestamp, get_caller_address, get_contract_address, ContractAddress}; @@ -80,7 +80,7 @@ fn test_claimed_amount() { let total_amount: u128 = 0; streaming.add_new_stream(recipient, start_time, end_time, total_amount); - start_warp(CheatTarget::One(gov.contract_address), 150); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), 150); //shouldn't have anything to claim streaming.claim_stream(recipient, start_time, end_time); } @@ -98,7 +98,7 @@ fn test_stream_started() { let end_time: u64 = 200; let total_amount: u128 = 100000; streaming.add_new_stream(recipient, start_time, end_time, total_amount); - start_warp(CheatTarget::One(gov.contract_address), 50); // before of stream + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), 50); // before of stream streaming.claim_stream(recipient, start_time, end_time); } @@ -117,7 +117,7 @@ fn test_claim_stream() { streaming.add_new_stream(recipient, start_time, end_time, total_amount); let (claimable_amount, total_amount) = streaming .get_stream_info(recipient, start_time, end_time,); - start_warp(CheatTarget::One(gov.contract_address), 150); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), 150); streaming.claim_stream(recipient, start_time, end_time); @@ -149,7 +149,7 @@ fn test_cancel_stream() { streaming.add_new_stream(recipient, start_time, end_time, total_amount); - start_warp(CheatTarget::One(gov.contract_address), 150); + start_cheat_block_timestamp(CheatTarget::One(gov.contract_address), 150); //test cancel_stream streaming.cancel_stream(recipient, start_time, end_time); diff --git a/tests/test_treasury.cairo b/tests/test_treasury.cairo index caa57b33..fa1a6662 100644 --- a/tests/test_treasury.cairo +++ b/tests/test_treasury.cairo @@ -15,7 +15,7 @@ use openzeppelin::access::ownable::interface::{ }; use openzeppelin::upgrades::interface::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, prank, CheatSpan, CheatTarget, roll + BlockId, declare, ContractClassTrait, ContractClass, prank, CheatSpan, CheatTarget, cheat_block_number }; use starknet::{ContractAddress, get_block_number, ClassHash}; mod testStorage { @@ -253,7 +253,7 @@ fn test_deposit_withdraw_carmine() { treasury_dispatcher .provide_liquidity_to_carm_AMM(eth_addr, usdc_addr, eth_addr, 0, to_deposit.into()); - roll( + cheat_block_number( CheatTarget::All, get_block_number() + 1, CheatSpan::Indefinite ); // to bypass sandwich guard treasury_dispatcher @@ -298,7 +298,7 @@ fn test_deposit_withdraw_zklend() { assert(bal_before_deposit == bal_after_deposit + deposit_amt, 'deposit to zklend failed'); - roll( + cheat_block_number( CheatTarget::All, get_block_number() + 1, CheatSpan::Indefinite ); // to bypass sandwich guard diff --git a/tests/vesting.cairo b/tests/vesting.cairo index b17bfc1b..12e23fa6 100644 --- a/tests/vesting.cairo +++ b/tests/vesting.cairo @@ -7,7 +7,7 @@ use debug::PrintTrait; use konoha::vesting::{IVestingDispatcher, IVestingDispatcherTrait, IVesting}; use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; use snforge_std::{ - BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget, + BlockId, declare, ContractClassTrait, ContractClass, start_cheat_caller_address, start_cheat_block_timestamp, CheatTarget, prank, CheatSpan }; use starknet::{ContractAddress, get_caller_address}; @@ -30,8 +30,8 @@ fn test_unauthorized_add_vesting_schedule() { let caller = get_caller_address(); - start_warp(CheatTarget::All, 1); - start_prank(CheatTarget::One(gov.contract_address), caller); + start_cheat_block_timestamp(CheatTarget::All, 1); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), caller); let grantee: ContractAddress = 0x1.try_into().unwrap(); @@ -46,8 +46,8 @@ fn test_unauthorized_vest_early() { let gov_vesting = IVestingDispatcher { contract_address: gov.contract_address }; - start_warp(CheatTarget::All, 1); - start_prank(CheatTarget::One(gov.contract_address), gov.contract_address); + start_cheat_block_timestamp(CheatTarget::All, 1); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), gov.contract_address); let grantee: ContractAddress = 0x1.try_into().unwrap(); @@ -64,14 +64,14 @@ fn test_vest_twice() { let gov_vesting = IVestingDispatcher { contract_address: gov.contract_address }; - start_warp(CheatTarget::All, 1); - start_prank(CheatTarget::One(gov.contract_address), gov.contract_address); + start_cheat_block_timestamp(CheatTarget::All, 1); + start_cheat_caller_address(CheatTarget::One(gov.contract_address), gov.contract_address); let grantee: ContractAddress = 0x1.try_into().unwrap(); gov_vesting.add_linear_vesting_schedule(10, 10, 10, 1000000, grantee); - start_warp(CheatTarget::All, 11); + start_cheat_block_timestamp(CheatTarget::All, 11); gov_vesting.vest(grantee, 10); gov_vesting.vest(grantee, 10); @@ -88,18 +88,18 @@ fn test_add_simple_vesting_schedule() { let grantee: ContractAddress = 0x1.try_into().unwrap(); gov_vesting.add_linear_vesting_schedule(10, 10, 10, 1000001, grantee); - start_warp(CheatTarget::All, 11); // past first vest + start_cheat_block_timestamp(CheatTarget::All, 11); // past first vest // anyone can claim for the grantee gov_vesting.vest(grantee, 10); assert(tok.balance_of(grantee) == 100000, 'vesting unsuccessful'); // grantee themselves can claim too - start_prank(CheatTarget::One(gov.contract_address), grantee); - start_warp(CheatTarget::All, 21); // past second vest + start_cheat_caller_address(CheatTarget::One(gov.contract_address), grantee); + start_cheat_block_timestamp(CheatTarget::All, 21); // past second vest gov_vesting.vest(grantee, 20); assert(tok.balance_of(grantee) == 200000, 'vesting unsuccessful'); - start_warp(CheatTarget::All, 101); // past last vest. no requirement to vest in order + start_cheat_block_timestamp(CheatTarget::All, 101); // past last vest. no requirement to vest in order gov_vesting.vest(grantee, 100); // leftover tokens are included in last vest. (remainder after division) assert(tok.balance_of(grantee) == 300001, 'vesting unsuccessful');