Skip to content

Commit

Permalink
More tests for DomainTokenReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Sep 20, 2024
1 parent 7650972 commit d687576
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ jobs:
paths:
- coverage-chainid-100
- coverage-chainid-42161
- coverage-chainid-1
coverage-test-bridging:
<<: *job_common
resource_class: large
Expand Down
28 changes: 28 additions & 0 deletions test/contracts-network/colony-funding.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const IMetaColony = artifacts.require("IMetaColony");
const Token = artifacts.require("Token");
const Resolver = artifacts.require("Resolver");
const DomainTokenReceiver = artifacts.require("DomainTokenReceiver");
const ToggleableToken = artifacts.require("ToggleableToken");

contract("Colony Funding", (accounts) => {
const MANAGER = accounts[0];
Expand Down Expand Up @@ -610,6 +611,33 @@ contract("Colony Funding", (accounts) => {
await checkErrorRevert(colonyNetwork.checkDomainTokenReceiverDeployed(2), "colony-caller-must-be-colony");
});

it("only the owner (which should be colonyNetwork) can call setColonyAddress on DomainTokenReceiver", async () => {
await colony.addDomain(1, UINT256_MAX, 1);
await colony.claimDomainFunds(ethers.constants.AddressZero, 2);

const receiverAddress = await colonyNetwork.getDomainTokenReceiverAddress(colony.address, 2);
const receiverAsEtherRouter = await EtherRouter.at(receiverAddress);
const receiver = await DomainTokenReceiver.at(receiverAddress);
const owner = await receiverAsEtherRouter.owner();
expect(owner).to.equal(colonyNetwork.address);

await checkErrorRevert(receiver.setColonyAddress(colony.address), "ds-auth-unauthorized");
await receiver.setColonyAddress.estimateGas(colony.address, { from: colonyNetwork.address });
});

it("If transfer fails from receiver, then the funds are not claimed", async () => {
await colony.addDomain(1, UINT256_MAX, 1);
const receiverAddress = await colonyNetwork.getDomainTokenReceiverAddress(colony.address, 2);

const toggleableToken = await ToggleableToken.new(200);
await toggleableToken.mint(receiverAddress, 100);

await toggleableToken.toggleLock();

// Try to claim the funds
await checkErrorRevert(colony.claimDomainFunds(toggleableToken.address, 2), "domain-token-receiver-transfer-failed");
});

it("If the receiver resolver is updated, then the resolver is updated at the next claim", async () => {
await colony.addDomain(1, UINT256_MAX, 1);
const receiverAddress = await colonyNetwork.getDomainTokenReceiverAddress(colony.address, 2);
Expand Down

0 comments on commit d687576

Please sign in to comment.