From 1b94c7594d40ae73756cbe0d17dfcb969b283aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sojka?= Date: Mon, 20 May 2024 07:46:08 +0000 Subject: [PATCH] Update snforge_std to v0.23.0 --- .devcontainer/devcontainer.json | 9 ++------- Scarb.lock | 4 ++-- Scarb.toml | 5 +++-- src/testing/setup.cairo | 13 ++++++++----- tests/basic.cairo | 2 +- tests/test_treasury.cairo | 4 ++-- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6ae19b24..46d09606 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,15 +13,12 @@ // "type": "volume" // } // ] - // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, - // 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", + "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", "customizations": { "vscode": { "extensions": [ @@ -29,10 +26,8 @@ ] } } - // Configure tool-specific properties. // "customizations": {}, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" -} +} \ No newline at end of file diff --git a/Scarb.lock b/Scarb.lock index 6c2a6cee..86b050a7 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -16,5 +16,5 @@ source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.10.0#d7 [[package]] name = "snforge_std" -version = "0.20.1" -source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.20.1#fea2db8f2b20148cc15ee34b08de12028eb42942" +version = "0.23.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.23.0#f2bff8f796763ada77fe6033ec1b034ceee22abd" diff --git a/Scarb.toml b/Scarb.toml index abdff298..bee38d50 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -7,10 +7,11 @@ cairo-version = "2.6.3" [dependencies] starknet = ">=2.0.0" openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.10.0" } - -[dev-dependencies] snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.23.0" } + +# [dev-dependencies] sadly can't use this because we have testing in src/ + [lib] [[target.starknet-contract]] diff --git a/src/testing/setup.cairo b/src/testing/setup.cairo index 7e8507b7..e439e88d 100644 --- a/src/testing/setup.cairo +++ b/src/testing/setup.cairo @@ -7,6 +7,7 @@ use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTr use snforge_std::{ BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget }; +use core::ResultTrait; use konoha::contract::IGovernanceDispatcher; @@ -27,10 +28,10 @@ const second_address: felt252 = 0x2; const admin_addr: felt252 = 0x3; fn deploy_governance(token_address: ContractAddress) -> IGovernanceDispatcher { - let gov_contract = declare("Governance"); - let mut args = ArrayTrait::new(); + let gov_contract = declare("Governance").expect('unable to declare governance'); + let mut args: Array = ArrayTrait::new(); args.append(token_address.into()); - let address = gov_contract.deploy(@args).expect('unable to deploy governance'); + let (address, _) = gov_contract.deploy(@args).expect('unable to deploy governance'); IGovernanceDispatcher { contract_address: address } } @@ -40,8 +41,10 @@ fn deploy_and_distribute_gov_tokens(recipient: ContractAddress) -> IERC20Dispatc calldata.append(GOV_TOKEN_INITIAL_SUPPLY); calldata.append(recipient.into()); - let gov_token_contract = declare("FloatingToken"); - let token_addr = gov_token_contract.deploy(@calldata).expect('unable to deploy FloatingToken'); + let gov_token_contract = declare("FloatingToken").expect('unable to declare FloatingToken'); + let (token_addr, _) = gov_token_contract + .deploy(@calldata) + .expect('unable to deploy FloatingToken'); let token: IERC20Dispatcher = IERC20Dispatcher { contract_address: token_addr }; start_prank(CheatTarget::One(token_addr), admin_addr.try_into().unwrap()); diff --git a/tests/basic.cairo b/tests/basic.cairo index a6eb631c..0880888c 100644 --- a/tests/basic.cairo +++ b/tests/basic.cairo @@ -108,7 +108,7 @@ fn test_upgrade_mainnet_to_master() { top_carm_holders.append(eighth_address); // declare current and submit proposal - let new_contract: ContractClass = declare("Governance"); + let new_contract: ContractClass = declare("Governance").expect('unable to declare governance'); start_prank(CheatTarget::One(gov_contract_addr), scaling_address); let new_prop_id = dispatcher.submit_proposal(new_contract.class_hash.into(), 1); loop { diff --git a/tests/test_treasury.cairo b/tests/test_treasury.cairo index 49d54923..4887ca09 100644 --- a/tests/test_treasury.cairo +++ b/tests/test_treasury.cairo @@ -35,7 +35,7 @@ fn get_important_addresses() -> (ContractAddress, ContractAddress, ContractAddre let AMM_contract_address: ContractAddress = testStorage::AMM_CONTRACT_ADDRESS .try_into() .unwrap(); - let contract = declare("Treasury"); + let contract = declare("Treasury").expect('unable to declare'); let mut calldata = ArrayTrait::new(); gov_contract_address.serialize(ref calldata); AMM_contract_address.serialize(ref calldata); @@ -44,7 +44,7 @@ fn get_important_addresses() -> (ContractAddress, ContractAddress, ContractAddre let contract_address = contract.precalculate_address(@calldata); prank(CheatTarget::One(contract_address), gov_contract_address, CheatSpan::TargetCalls(1)); - let deployed_contract = contract.deploy(@calldata).unwrap(); + let (deployed_contract, _) = contract.deploy(@calldata).unwrap(); return (gov_contract_address, AMM_contract_address, deployed_contract,); }