Skip to content

Commit

Permalink
Delete redundant tests (#621)
Browse files Browse the repository at this point in the history
* Delete redundant contract-deployer tests

* Delete redundant native-minter test

* Delete redundant reward-manager tests

* Delete redundant tx-allow-list tests
  • Loading branch information
richardpringle authored Apr 26, 2023
1 parent 4dd29dc commit 94c973d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 138 deletions.
74 changes: 0 additions & 74 deletions contract-examples/test/contract_deployer_allow_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ describe("ExampleDeployerList", function () {

});

it("should add contract deployer as owner", async function () {
const contractOwnerAddr: string = await contract.owner()
expect(owner.address).to.equal(contractOwnerAddr)
});

it("precompile should see owner address has admin role", async function () {
// test precompile first
const allowList = await ethers.getContractAt("IAllowList", ALLOWLIST_ADDRESS, owner);
Expand Down Expand Up @@ -85,31 +80,6 @@ describe("ExampleDeployerList", function () {
expect.fail("should have errored")
});

it("should not allow deployer to enable itself", async function () {
try {
await contract.connect(deployer).addDeployer(deployer.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});

it("should not allow admin to enable deployer without enabling contract", async function () {
const allowList = await ethers.getContractAt("IAllowList", ALLOWLIST_ADDRESS, owner);
let role = await allowList.readAllowList(contract.address);
expect(role).to.be.equal(ROLES.NONE)
const result = await contract.isEnabled(contract.address);
expect(result).to.be.false
try {
await contract.addDeployer(deployer.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});

it("should allow admin to add contract as admin", async function () {
const allowList = await ethers.getContractAt("IAllowList", ALLOWLIST_ADDRESS, owner);
let role = await allowList.readAllowList(contract.address);
Expand Down Expand Up @@ -137,55 +107,11 @@ describe("ExampleDeployerList", function () {
expect(token.address).not.null
});

it("should not let deployer add another deployer", async function () {
try {
const signers: SignerWithAddress[] = await ethers.getSigners()
const testAddress = signers.slice(-2)[0]
await contract.connect(deployer).addDeployer(testAddress.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});

it("should not let deployer to revoke admin", async function () {
try {
await contract.connect(deployer).revoke(owner.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});


it("should not let deployer to revoke itself", async function () {
try {
await contract.connect(deployer).revoke(deployer.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});

it("should let admin to revoke deployer", async function () {
let tx = await contract.revoke(deployer.address);
await tx.wait()
const allowList = await ethers.getContractAt("IAllowList", ALLOWLIST_ADDRESS, owner);
let noRole = await allowList.readAllowList(deployer.address);
expect(noRole).to.be.equal(ROLES.NONE)
});


it("should not let admin to revoke itself", async function () {
try {
await contract.revoke(owner.address);
}
catch (err) {
return
}
expect.fail("should have errored")
});
})
5 changes: 0 additions & 5 deletions contract-examples/test/contract_native_minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ describe("ERC20NativeMinter", function () {
})
});

it("should add contract deployer as owner", async function () {
const contractOwnerAddr: string = await contract.owner()
expect(owner.address).to.equal(contractOwnerAddr)
});

// this contract is not given minter permission yet, so should not mintdraw
it("contract should not be able to mintdraw", async function () {
const minterList = await ethers.getContractAt("INativeMinter", MINT_PRECOMPILE_ADDRESS, owner);
Expand Down
27 changes: 0 additions & 27 deletions contract-examples/test/reward_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ describe("ExampleRewardManager", function () {
await tx.wait()
});

it("should add contract deployer as owner", async function () {
const contractOwnerAddr: string = await contract.owner()
expect(owner.address).to.equal(contractOwnerAddr)
});

// this contract is not selected as the reward address yet, so should not be able to receive fees
it("should send fees to blackhole", async function () {
let rewardAddress = await contract.currentRewardAddress();
Expand Down Expand Up @@ -119,28 +114,6 @@ describe("ExampleRewardManager", function () {
expect(balance.gt(previousBalance)).to.be.true
})

it("signer1 should be appointed as reward address", async function () {
let tx = await contract.setRewardAddress(signer1.address);
await tx.wait()
let rewardAddress = await contract.currentRewardAddress();
expect(rewardAddress).to.be.equal(signer1.address)
});

it("signer1 should be able to receive fees", async function () {
let previousBalance = await ethers.provider.getBalance(signer1.address)

// Send a transaction to mine a new block
const tx = await owner.sendTransaction({
to: signer2.address,
value: ethers.utils.parseEther("0.0001")
})
await tx.wait()

let balance = await ethers.provider.getBalance(signer1.address)
expect(balance.gt(previousBalance)).to.be.true
})


it("should return false for allowFeeRecipients check", async function () {
let res = await contract.areFeeRecipientsAllowed();
expect(res).to.be.false
Expand Down
32 changes: 0 additions & 32 deletions contract-examples/test/tx_allow_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ describe("ExampleTxAllowList", function () {
})

it("should not allow noRole to enable itself", async function () {
try {
await contract.connect(noRole).addDeployer(noRole.address)
}
catch (err) {
return
}
expect.fail("should have errored")
})

it("should not allow admin to enable noRole without enabling contract", async function () {
const allowList = await ethers.getContractAt("IAllowList", TX_ALLOW_LIST_ADDRESS, admin)
let role = await allowList.readAllowList(contract.address)
expect(role).to.be.equal(ROLES.NONE)
Expand Down Expand Up @@ -167,33 +157,11 @@ describe("ExampleTxAllowList", function () {
expect.fail("should have errored")
})


it("should not let allowed to revoke itself", async function () {
try {
await contract.connect(allowed).revoke(allowed.address)
}
catch (err) {
return
}
expect.fail("should have errored")
})

it("should let admin to revoke allowed", async function () {
let tx = await contract.revoke(allowed.address)
await tx.wait()
const allowList = await ethers.getContractAt("IAllowList", TX_ALLOW_LIST_ADDRESS, admin)
let noRole = await allowList.readAllowList(allowed.address)
expect(noRole).to.be.equal(ROLES.NONE)
})


it("should not let admin to revoke itself", async function () {
try {
await contract.revoke(admin.address)
}
catch (err) {
return
}
expect.fail("should have errored")
})
})

0 comments on commit 94c973d

Please sign in to comment.