Skip to content

Commit

Permalink
change constructor MCM (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds authored Oct 8, 2024
1 parent 4e597a9 commit 205cf8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 2 additions & 4 deletions contracts/src/mcms.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,10 @@ mod ManyChainMultiSig {
}

#[constructor]
fn constructor(ref self: ContractState) {
let caller = starknet::info::get_caller_address();
self.ownable.initializer(caller);
fn constructor(ref self: ContractState, owner: ContractAddress) {
self.ownable.initializer(owner);
}


#[abi(embed_v0)]
impl ManyChainMultiSigImpl of super::IManyChainMultiSig<ContractState> {
fn set_root(
Expand Down
13 changes: 9 additions & 4 deletions contracts/src/tests/test_mcms/test_set_config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,13 @@ fn test_set_config_success_dont_clear_root() {

// mock the contract state
let test_address = test_address();
start_cheat_caller_address(test_address, contract_address_const::<777>());

let owner = contract_address_const::<1231231111>();
start_cheat_caller_address(test_address, owner);

// test internal function state
let mut state = contract_state_for_testing();
ManyChainMultiSig::constructor(ref state);
ManyChainMultiSig::constructor(ref state, owner);
state
.set_config(
signer_addresses.span(),
Expand Down Expand Up @@ -540,11 +542,14 @@ fn test_set_config_success_and_clear_root() {
// mock the contract state
let test_address = test_address();
let mock_chain_id = 990;
start_cheat_caller_address(test_address, contract_address_const::<777>());

let owner = contract_address_const::<1231231111>();
start_cheat_caller_address(test_address, owner);
start_cheat_chain_id(test_address, mock_chain_id);

let mut state = contract_state_for_testing();
ManyChainMultiSig::constructor(ref state);

ManyChainMultiSig::constructor(ref state, owner);

// initialize s_expiring_root_and_op_count & s_root_metadata
state
Expand Down
5 changes: 4 additions & 1 deletion contracts/src/tests/test_mcms/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ fn set_root_args(
fn setup_mcms_deploy() -> (
ContractAddress, IManyChainMultiSigDispatcher, IManyChainMultiSigSafeDispatcher
) {
let calldata = array![];
let owner = contract_address_const::<213123123>();
start_cheat_caller_address_global(owner);

let calldata = array![owner.into()];

let (mcms_address, _) = declare("ManyChainMultiSig").unwrap().deploy(@calldata).unwrap();

Expand Down

0 comments on commit 205cf8e

Please sign in to comment.