Skip to content

Commit

Permalink
Fix vesting tests with snforge v0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
tensojka committed May 23, 2024
1 parent a52387b commit 1612b13
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/vesting.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ use snforge_std::{
BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget
};

use governance::vesting::{IVestingDispatcher, IVestingDispatcherTrait, IVesting};
use konoha::vesting::{IVestingDispatcher, IVestingDispatcherTrait, IVesting};
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};

// returns gov addr, token addr
fn test_setup() -> (ContractAddress, ContractAddress) {
let new_gov_contract: ContractClass = declare('Governance');
let new_token_contract: ContractClass = declare('MyToken');
let new_gov_contract: ContractClass = declare("Governance")
.expect('unable to declare Governance');
let new_token_contract: ContractClass = declare("MyToken").expect('unable to declare MyToken');
let new_gov_addr: ContractAddress =
0x001405ab78ab6ec90fba09e6116f373cda53b0ba557789a4578d8c1ec374ba0f
.try_into()
.unwrap();
let mut token_constructor = ArrayTrait::new();
token_constructor.append(new_gov_addr.into()); // Owner
let token_address = new_token_contract
let (token_address, _) = new_token_contract
.deploy(@token_constructor)
.expect('unable to deploy token');
let mut gov_constructor: Array<felt252> = ArrayTrait::new();
gov_constructor.append(token_address.into());
let gov_address = new_gov_contract
let (gov_address, _) = new_gov_contract
.deploy_at(@gov_constructor, new_gov_addr)
.expect('unable to deploy gov');

Expand All @@ -36,7 +37,7 @@ fn test_setup() -> (ContractAddress, ContractAddress) {
#[test]
#[should_panic(expected: ('not self-call',))]
fn test_unauthorized_add_vesting_schedule() {
let (gov_address, token_address) = test_setup();
let (gov_address, _) = test_setup();

let gov_vesting = IVestingDispatcher { contract_address: gov_address };

Expand All @@ -48,7 +49,7 @@ fn test_unauthorized_add_vesting_schedule() {
#[test]
#[should_panic(expected: ('not yet eligible',))]
fn test_unauthorized_vest_early() {
let (gov_address, token_address) = test_setup();
let (gov_address, _) = test_setup();

let gov_vesting = IVestingDispatcher { contract_address: gov_address };

Expand All @@ -65,7 +66,7 @@ fn test_unauthorized_vest_early() {
#[test]
#[should_panic(expected: ('nothing to vest',))]
fn test_vest_twice() {
let (gov_address, token_address) = test_setup();
let (gov_address, _) = test_setup();

let gov_vesting = IVestingDispatcher { contract_address: gov_address };

Expand Down

0 comments on commit 1612b13

Please sign in to comment.