From d68757672690d52848135efb573fb789bd091e10 Mon Sep 17 00:00:00 2001 From: Alex Rea Date: Fri, 20 Sep 2024 11:41:23 +0100 Subject: [PATCH] More tests for DomainTokenReceiver --- .circleci/config.yml | 1 + test/contracts-network/colony-funding.js | 28 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e074793255..31694b990f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -329,6 +329,7 @@ jobs: paths: - coverage-chainid-100 - coverage-chainid-42161 + - coverage-chainid-1 coverage-test-bridging: <<: *job_common resource_class: large diff --git a/test/contracts-network/colony-funding.js b/test/contracts-network/colony-funding.js index 1f427c2e9f..a1eb71427e 100755 --- a/test/contracts-network/colony-funding.js +++ b/test/contracts-network/colony-funding.js @@ -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]; @@ -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);