Skip to content

Commit

Permalink
feat: add test for creating account with same owner and index
Browse files Browse the repository at this point in the history
  • Loading branch information
Aboudjem committed Jul 31, 2024
1 parent c10eb71 commit 082591d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ contract TestK1ValidatorFactory_Deployments is NexusTest_Base {
assertEq(deployedAccountAddress, expectedAddress, "Computed address mismatch");
}

/// @notice Tests that creating an account with the same owner and index results in the same address.
function test_CreateAccount_SameOwnerAndIndex() public payable {
uint256 index = 0;
address expectedOwner = user.addr;
/// @notice Tests that creating an account with the same owner and index results in the same address.
function test_CreateAccount_SameOwnerAndIndex() public payable {
uint256 index = 0;
address expectedOwner = user.addr;

address payable firstAccountAddress = validatorFactory.createAccount{ value: 1 ether }(expectedOwner, index, ATTESTERS, THRESHOLD);
address payable secondAccountAddress = validatorFactory.createAccount{ value: 1 ether }(expectedOwner, index, ATTESTERS, THRESHOLD);
// Create the first account with the given owner and index
address payable firstAccountAddress = validatorFactory.createAccount{ value: 1 ether }(expectedOwner, index, ATTESTERS, THRESHOLD);

assertEq(firstAccountAddress, secondAccountAddress, "Addresses should match for the same owner and index");
}
// Expect the second call to revert with InnerCallFailed
vm.expectRevert(K1ValidatorFactory.InnerCallFailed.selector);
address payable secondAccountAddress = validatorFactory.createAccount{ value: 1 ether }(expectedOwner, index, ATTESTERS, THRESHOLD);
}

/// @notice Tests that creating accounts with different indexes results in different addresses.
function test_CreateAccount_DifferentIndexes() public payable {
Expand Down

0 comments on commit 082591d

Please sign in to comment.