Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Oct 21, 2024
1 parent ee0db9d commit 6b9cf33
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 25 deletions.
22 changes: 11 additions & 11 deletions test/EncryptionRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -571,42 +571,42 @@ contract EncryptionRegistryTest is AragonTest {
registry.setOwnPublicKey(0x0000123400000000000000000000000000000000000000000000000000000000);
}

function test_ShouldCountRegisteredAddresses() public {
assertEq(registry.getRegisteredAddressesLength(), 0, "Incorrect count");
function test_RegisteredAddressShouldHaveTheRightLength() public {
assertEq(registry.getRegisteredAddresses().length, 0, "Incorrect length");

// Set public key first

// Alice
vm.startPrank(alice);
registry.setOwnPublicKey(bytes32(uint256(1234)));
assertEq(registry.getRegisteredAddressesLength(), 1, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 1, "Incorrect length");
registry.appointWallet(address(0x1234));
assertEq(registry.getRegisteredAddressesLength(), 1, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 1, "Incorrect length");

// Bob
vm.startPrank(bob);
registry.setOwnPublicKey(bytes32(uint256(2345)));
assertEq(registry.getRegisteredAddressesLength(), 2, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 2, "Incorrect length");
registry.appointWallet(address(0x5678));
assertEq(registry.getRegisteredAddressesLength(), 2, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 2, "Incorrect length");

// Appoint first

// Carol
vm.startPrank(carol);
registry.appointWallet(address(0x90ab));
assertEq(registry.getRegisteredAddressesLength(), 3, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 3, "Incorrect length");
registry.appointWallet(carol);
registry.setPublicKey(carol, bytes32(uint256(3456)));
assertEq(registry.getRegisteredAddressesLength(), 3, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 3, "Incorrect length");

// David
vm.startPrank(david);
registry.appointWallet(address(0xcdef));
assertEq(registry.getRegisteredAddressesLength(), 4, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 4, "Incorrect length");
registry.appointWallet(david);
registry.setPublicKey(david, bytes32(uint256(4567)));
assertEq(registry.getRegisteredAddressesLength(), 4, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 4, "Incorrect length");
}

function test_ShouldEnumerateRegisteredAddresses() public {
Expand Down Expand Up @@ -644,7 +644,7 @@ contract EncryptionRegistryTest is AragonTest {
registry.setPublicKey(david, bytes32(uint256(4567)));
assertEq(registry.registeredAddresses(3), david);

assertEq(registry.getRegisteredAddressesLength(), 4, "Incorrect count");
assertEq(registry.getRegisteredAddresses().length, 4, "Incorrect length");

assertEq(registry.registeredAddresses(0), alice);
assertEq(registry.registeredAddresses(1), bob);
Expand Down
29 changes: 29 additions & 0 deletions test/SignerList.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import {AragonTest} from "./base/AragonTest.sol";
import {Addresslist} from "@aragon/osx/plugins/utils/Addresslist.sol";
import {EncryptionRegistry} from "../src/EncryptionRegistry.sol";
import {DaoBuilder} from "./helpers/DaoBuilder.sol";
import {DAO} from "@aragon/osx/core/dao/DAO.sol";
import {Multisig} from "../src/Multisig.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

contract EncryptionRegistryTest is AragonTest {
EncryptionRegistry registry;
DaoBuilder builder;
DAO dao;
Multisig multisig;

// Events/errors to be tested here (duplicate)

function setUp() public {
// builder = new DaoBuilder();
// (dao,, multisig,,,) = builder.withMultisigMember(alice).withMultisigMember(bob).withMultisigMember(carol)
// .withMultisigMember(david).build();

// registry = new EncryptionRegistry(multisig);
}

function test_AAA() public {}
}
36 changes: 24 additions & 12 deletions test/helpers/DaoBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {DAO} from "@aragon/osx/core/dao/DAO.sol";
import {Multisig} from "../../src/Multisig.sol";
import {EmergencyMultisig} from "../../src/EmergencyMultisig.sol";
import {OptimisticTokenVotingPlugin} from "../../src/OptimisticTokenVotingPlugin.sol";
import {SignerList} from "../../src/SignerList.sol";
import {EncryptionRegistry} from "../../src/EncryptionRegistry.sol";
import {createProxyAndCall} from "../../src/helpers/proxy.sol";
import {RATIO_BASE} from "@aragon/osx/plugins/utils/Ratio.sol";
import {TaikoL1Mock, TaikoL1PausedMock, TaikoL1WithOldLastBlock, TaikoL1Incompatible} from "../mocks/TaikoL1Mock.sol";
Expand Down Expand Up @@ -217,15 +219,10 @@ contract DaoBuilder is Test {
);
}

// Standard multisig
// Encryption registry and signer list
SignerList signerList;
EncryptionRegistry encryptionRegistry;
{
Multisig.MultisigSettings memory settings = Multisig.MultisigSettings({
onlyListed: onlyListed,
minApprovals: minApprovals,
destinationProposalDuration: stdProposalDuration,
proposalExpirationPeriod: multisigProposalExpirationPeriod
});

address[] memory signers;
if (multisigMembers.length > 0) {
signers = multisigMembers;
Expand All @@ -234,10 +231,25 @@ contract DaoBuilder is Test {
signers = new address[](1);
signers[0] = owner;
}

signerList = new SignerList();
signerList.initialize(dao, signers, SignerList.Settings(EncryptionRegistry(address(0)), 0));
encryptionRegistry = new EncryptionRegistry(signerList);
signerList.updateSettings(SignerList.Settings(encryptionRegistry, uint16(signers.length)));
}

// Standard multisig
{
Multisig.MultisigSettings memory settings = Multisig.MultisigSettings({
onlyListed: onlyListed,
minApprovals: minApprovals,
destinationProposalDuration: stdProposalDuration,
signerList: signerList,
proposalExpirationPeriod: multisigProposalExpirationPeriod
});

multisig = Multisig(
createProxyAndCall(
address(MULTISIG_BASE), abi.encodeCall(Multisig.initialize, (dao, signers, settings))
)
createProxyAndCall(address(MULTISIG_BASE), abi.encodeCall(Multisig.initialize, (dao, settings)))
);
}

Expand All @@ -246,7 +258,7 @@ contract DaoBuilder is Test {
EmergencyMultisig.MultisigSettings memory settings = EmergencyMultisig.MultisigSettings({
onlyListed: onlyListed,
minApprovals: minApprovals,
addresslistSource: multisig,
signerList: signerList,
proposalExpirationPeriod: multisigProposalExpirationPeriod
});

Expand Down
4 changes: 2 additions & 2 deletions test/integration/TaikoDaoFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ contract TaikoDaoFactoryTest is AragonTest {
// ENCRYPTION REGISTRY
assertNotEq(address(deployment.encryptionRegistry), address(0), "Empty encryptionRegistry field");
assertEq(
deployment.encryptionRegistry.getRegisteredAddressesLength(), 0, "Invalid getRegisteredAddressesLength"
deployment.encryptionRegistry.getRegisteredAddresses().length, 0, "Invalid getRegisteredAddresses().length"
);
}

Expand Down Expand Up @@ -758,7 +758,7 @@ contract TaikoDaoFactoryTest is AragonTest {
// ENCRYPTION REGISTRY
assertNotEq(address(deployment.encryptionRegistry), address(0), "Empty encryptionRegistry field");
assertEq(
deployment.encryptionRegistry.getRegisteredAddressesLength(), 0, "Invalid getRegisteredAddressesLength"
deployment.encryptionRegistry.getRegisteredAddresses().length, 0, "Invalid getRegisteredAddresses().length"
);
}

Expand Down

0 comments on commit 6b9cf33

Please sign in to comment.