Skip to content

Commit

Permalink
feat: module length verification
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyRo1 committed Jul 10, 2024
1 parent e6388f3 commit 5a2c5bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/src/contracts/isms/aggregation/aggregation.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ pub mod aggregation {
pub const THRESHOLD_NOT_SET: felt252 = 'Threshold not set';
pub const MODULES_ALREADY_STORED: felt252 = 'Modules already stored';
pub const NO_MODULES_PROVIDED: felt252 = 'No modules provided';
pub const TOO_MANY_MODULES_PROVIDED: felt252 = 'Too many modules provided';
}

#[constructor]
fn constructor(ref self: ContractState, _owner: ContractAddress, _modules: Span<felt252>) {
self.ownable.initializer(_owner);
assert(_modules.len()<255, Errors::TOO_MANY_MODULES_PROVIDED);
self.set_modules(_modules);
}

Expand Down
16 changes: 16 additions & 0 deletions contracts/src/tests/isms/test_aggregation.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ fn test_aggregation_set_threshold() {
aggregation.set_threshold(threshold);
}

#[test]
#[should_panic]
fn test_aggregation_initialize_with_too_many_modules(){
let mut modules = array![];
let mut cur_idx = 0;
loop{
if (cur_idx == 256) {
break;
}
modules.append('module_1'.into());
cur_idx +=1;
};
setup_aggregation(modules.span());
}


#[test]
#[should_panic(expected: ('Threshold not set',))]
fn test_aggregation_verify_fails_if_treshold_not_set() {
Expand Down

0 comments on commit 5a2c5bd

Please sign in to comment.