Make domainHash internal as _domainHash, publicly expose in TestMultisigValidatorManager

pull/334/head
Trevor Porter 3 years ago
parent 8517a14795
commit 84a705d191
  1. 9
      solidity/core/contracts/test/TestMultisigValidatorManager.sol
  2. 18
      solidity/core/contracts/validator-manager/MultisigValidatorManager.sol
  3. 4
      solidity/core/test/validator-manager/multisigValidatorManager.test.ts

@ -17,4 +17,13 @@ contract TestMultisigValidatorManager is MultisigValidatorManager {
)
MultisigValidatorManager(_outboxDomain, _validatorSet, _quorumThreshold)
{}
/**
* @notice Hash of domain concatenated with "ABACUS".
* @dev This is a public getter of _domainHash to test with.
* @param _domain The domain to hash.
*/
function domainHash(uint32 _domain) external pure returns (bytes32) {
return _domainHash(_domain);
}
}

@ -68,7 +68,7 @@ abstract contract MultisigValidatorManager is Ownable {
) Ownable() {
// Set immutables.
outboxDomain = _outboxDomain;
outboxDomainHash = domainHash(_outboxDomain);
outboxDomainHash = _domainHash(_outboxDomain);
// Enroll validators. Reverts if there are any duplicates.
uint256 _validatorSetLength = _validatorSet.length;
@ -169,14 +169,6 @@ abstract contract MultisigValidatorManager is Ownable {
return _validatorSignatureCount >= quorumThreshold;
}
/**
* @notice Hash of domain concatenated with "ABACUS".
* @param _domain The domain to hash.
*/
function domainHash(uint32 _domain) public pure returns (bytes32) {
return keccak256(abi.encodePacked(_domain, "ABACUS"));
}
// ============ Internal Functions ============
/**
@ -236,4 +228,12 @@ abstract contract MultisigValidatorManager is Ownable {
quorumThreshold = _quorumThreshold;
emit SetQuorumThreshold(_quorumThreshold);
}
/**
* @notice Hash of domain concatenated with "ABACUS".
* @param _domain The domain to hash.
*/
function _domainHash(uint32 _domain) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(_domain, "ABACUS"));
}
}

@ -246,12 +246,14 @@ describe('MultisigValidatorManager', async () => {
});
});
describe('#domainHash', () => {
describe('#_domainHash', () => {
it('matches Rust-produced domain hashes', async () => {
// Compare Rust output in json file to solidity output (json file matches
// hash for local domain of 1000)
for (let testCase of domainHashTestCases) {
const { expectedDomainHash } = testCase;
// This public function on TestMultisigValidatorManager exposes
// the internal _domainHash on MultisigValidatorManager.
const domainHash = await validatorManager.domainHash(
testCase.outboxDomain,
);

Loading…
Cancel
Save