Add some tests for domains ownership

This commit is contained in:
Theo 2023-08-30 14:34:22 -07:00
parent 322b463917
commit 45dcb16c89

@ -6,15 +6,32 @@ import { UpdateENSDataProposal } from "@root/UpdateENSDataProposal.sol";
import { console2 } from "@forge-std/console2.sol";
import { IENSResolver } from "@interfaces/IENSResolver.sol";
import { IENSRegistry } from "@interfaces/IENSRegistry.sol";
import { ENSNamehash } from "./ENSNamehash.sol";
contract TestExampleProposal is ProposalUtils {
IENSResolver ensResolver = IENSResolver(0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41);
using ENSNamehash for bytes;
IENSResolver internal ensResolver = IENSResolver(0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41);
IENSRegistry ensRegistry = IENSRegistry(ENSAddress);
string internal tornadoContractENSDomain = "contract.tornadocash.eth";
string internal governanceImplementationENSDomain = "governance-impl.contract.tornadocash.eth";
string internal stakingRewardsENSDomain = "staking-rewards.contract.tornadocash.eth";
bytes32 internal tornadoContractsENSNode = calculateDomainNode(tornadoContractENSDomain);
bytes32 internal stakingRewardsENSNode = calculateDomainNode(stakingRewardsENSDomain);
bytes32 internal governanceImplENSNode = calculateDomainNode(governanceImplementationENSDomain);
modifier executeCurrentProposalBefore() {
createAndExecuteProposal();
_;
}
function calculateDomainNode(string memory domain) internal pure returns (bytes32) {
return ENSNamehash.namehash(bytes(domain));
}
function createAndExecuteProposal() public {
address proposalAddress = address(new UpdateENSDataProposal());
@ -22,10 +39,33 @@ contract TestExampleProposal is ProposalUtils {
}
function testStakingAddressChanged() public executeCurrentProposalBefore {
bytes32 stakingRewardsENSNode = 0x3da4b79cd8c20d2fafb1c7cb37a62be8668f543393f6636d421fba0be735e68f;
address stakingAddressAfterProposal = ensResolver.addr(stakingRewardsENSNode);
console2.log("Address on staking ENS Tornado subdomain (staking-rewards.contract.tornadocash.eth): %s", stakingAddressAfterProposal);
require(stakingAddressAfterProposal == stakingAddress);
}
function testGovernanceImplAddressChanged() public executeCurrentProposalBefore {
address expectedGovernanceImplAddress = 0xBa178126C28F50Ee60322a82f5EbCd6b3711e101;
address governanceImplAddressAfterProposal = ensResolver.addr(governanceImplENSNode);
console2.log(
"Address on governance implementation ENS Tornado subdomain (governance-impl.contract.tornadocash.eth): %s",
governanceImplAddressAfterProposal
);
require(expectedGovernanceImplAddress == governanceImplAddressAfterProposal);
}
function testENSSubdomainOwnerChanged() public executeCurrentProposalBefore {
address tornadoContractsENSDomainOwner = ensRegistry.owner(tornadoContractsENSNode);
address governanceImplENSNodeOwner = ensRegistry.owner(governanceImplENSNode);
address stakingRewardsENSNodeOwner = ensRegistry.owner(stakingRewardsENSNode);
console2.log("Tornado contracts ENS domain owner after proposal execution: %s", tornadoContractsENSDomainOwner);
console2.log("Staking rewards ENS domain owner after proposal execution: %s", stakingRewardsENSNodeOwner);
console2.log("Governance implementation ENS domain owner after proposal execution: %s", governanceImplENSNodeOwner);
require(stakingRewardsENSNodeOwner == governanceAddress, "Staking rewards ENS domain owner is not governance");
require(tornadoContractsENSDomainOwner == governanceAddress, "Tornado contracts ENS domain owner is not governance");
require(governanceImplENSNodeOwner == governanceAddress, "Governance implementation ENS domain owner is not governance");
}
}