Skip to content

Commit

Permalink
test: add optin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krogla committed Jan 21, 2025
1 parent 9fe5bda commit 95b955a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/CCCP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ contract CCCPOptIn is CCCPCommon {
function test_OptIn() public {
// opt in on behalf of noCsm1
vm.broadcast(noCsm1);
vm.expectEmit(true, true, true, false, address(cccp));
emit CCCP.OptInSucceeded(csmId, noCsm1Id, noCsm1Manager);
vm.expectEmit(true, true, true, false, address(cccp));
emit CCCP.KeyRangeUpdated(csmId, noCsm1Id, 2, 4);

cccp.optIn({
moduleId: csmId,
operatorId: noCsm1Id,
Expand Down Expand Up @@ -310,4 +315,32 @@ contract CCCPOptIn is CCCPCommon {
rpcURL: ""
});
}

function test_OptIn_RevertWhen_KeyIndexWrongOrder() public {
// optin
vm.broadcast(noCsm1);
vm.expectRevert(CCCP.KeyIndexMismatch.selector);
cccp.optIn({
moduleId: csmId,
operatorId: noCsm1Id,
manager: noCsm1Manager,
newKeyIndexRangeStart: 4,
newKeyIndexRangeEnd: 2,
rpcURL: ""
});
}

function test_OptIn_RevertWhen_KeyIndexOutOfRange() public {
// optin
vm.broadcast(noCsm1);
vm.expectRevert(CCCP.KeyIndexOutOfRange.selector);
cccp.optIn({
moduleId: csmId,
operatorId: noCsm1Id,
manager: noCsm1Manager,
newKeyIndexRangeStart: 2,
newKeyIndexRangeEnd: 100,
rpcURL: ""
});
}
}

0 comments on commit 95b955a

Please sign in to comment.