Skip to content

Commit

Permalink
get tests to work; fix erc20votes deployer serializing error
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott committed Jun 13, 2024
1 parent 7b65149 commit 098f798
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
mod AlwaysFailProposalValidationStrategy {
use starknet::ContractAddress;
use sx::types::UserAddress;
use sx::interfaces::{IProposalValidationStrategy,};

#[storage]
struct Storage {}

#[generate_trait]
impl AlwaysFailProposalValidationStrategy of IAlwaysFailProposalValidationStrategy {
#[abi(embed_v0)]
impl AlwaysFailProposalValidationStrategy of IProposalValidationStrategy<ContractState> {
fn validate(
self: @ContractState,
author: UserAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ mod tests {

// deploy erc20 voting strategy
let owner = starknet::contract_address_const::<'owner'>();
let mut constructor = array!['TEST', 'TST'];
let mut constructor = array![];
let name: ByteArray = "TEST";
let symbol: ByteArray = "TST";

name.serialize(ref constructor);
symbol.serialize(ref constructor);
SUPPLY.serialize(ref constructor);
owner.serialize(ref constructor);

Expand Down
1 change: 0 additions & 1 deletion starknet/src/tests/space/space.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ mod tests {
use sx::tests::utils::strategy_trait::{StrategyImpl, StrategyDefault};
use sx::tests::mocks::executor::ExecutorWithoutTxExecutionStrategy;


fn assert_correct_proposal_event(
space_address: ContractAddress,
proposal_id: u256,
Expand Down
24 changes: 17 additions & 7 deletions starknet/src/tests/voting_strategies/erc20_votes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,30 @@ mod tests {
use sx::utils::constants::{PROPOSE_SELECTOR, VOTE_SELECTOR};
use sx::tests::mocks::vanilla_execution_strategy::VanillaExecutionStrategy;

const NAME: felt252 = 'TEST';
const SYMBOL: felt252 = 'TST';

const INITIAL_SUPPLY: u256 = 1_000;

fn OWNER() -> ContractAddress {
starknet::contract_address_const::<0x111111>()
}

fn deploy_token_contract() -> ContractAddress {
// Deploy ERC20
let constructor_data = array![
NAME, SYMBOL, INITIAL_SUPPLY.low.into(), INITIAL_SUPPLY.high.into(), OWNER().into()
];
let NAME: ByteArray = "TEST";
let SYMBOL: ByteArray = "TST";

let mut constructor_data = array![];
NAME.serialize(ref constructor_data);
SYMBOL.serialize(ref constructor_data);
INITIAL_SUPPLY.low.serialize(ref constructor_data);
INITIAL_SUPPLY.high.serialize(ref constructor_data);
OWNER().serialize(ref constructor_data);

// let constructor_data = array![
// NAME, SYMBOL, INITIAL_SUPPLY.low.into(), INITIAL_SUPPLY.high.into(), OWNER().into()
// ];
// let constructor_data = (NAME, SYMBOL, INITIAL_SUPPLY.low, INITIAL_SUPPLY, OWNER());

// Deploy ERC20
let (token_contract, _) = syscalls::deploy_syscall(
ERC20VotesPreset::TEST_CLASS_HASH.try_into().unwrap(),
0,
Expand Down Expand Up @@ -149,7 +159,7 @@ mod tests {

#[test]
#[available_gas(1000000000)]
fn works() {
fn scott_works() {
let (config, space) = setup_space();
let vanilla_execution_strategy = get_vanilla_execution_strategy();
let accounts = setup_accounts(space.voting_strategies(1));
Expand Down

0 comments on commit 098f798

Please sign in to comment.