Skip to content

Commit

Permalink
test(operators): full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
re1ro committed Jun 11, 2024
1 parent e283147 commit eedbd56
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions move/operators/sources/operators/operators.move
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ module operators::operators {
destroy_operators(operators);
}


#[test]
#[expected_failure(abort_code = 0, location = operators::operators)]
fun test_remove_operator_fail() {
let ctx = &mut tx_context::dummy();
let mut operators = new_operators(ctx);
let owner_cap = new_owner_cap(ctx);

let owner_id = object::id(&owner_cap);

remove_operator(&mut operators, &owner_cap, owner_id);

destroy_owner_cap(owner_cap);
destroy_operators(operators);
}

#[test]
#[expected_failure(abort_code = 0, location = operators::operators)]
fun test_borrow_cap_not_operator() {
Expand All @@ -209,4 +225,22 @@ module operators::operators {
destroy_owner_cap(owner_cap);
destroy_operators(operators);
}


#[test]
#[expected_failure(abort_code = 1, location = operators::operators)]
fun test_borrow_cap_no_such_cap() {
let ctx = &mut tx_context::dummy();
let mut operators = new_operators(ctx);
let owner_cap = new_owner_cap(ctx);
let operator_cap = new_operator_cap(&mut operators, ctx);

let operator_id = object::id(&operator_cap);

borrow_cap<OwnerCap>(&operators, &operator_cap, operator_id);

destroy_operator_cap(operator_cap);
destroy_owner_cap(owner_cap);
destroy_operators(operators);
}
}

0 comments on commit eedbd56

Please sign in to comment.