Skip to content

Commit 836bb1a

Browse files
authored
feat: clean up some test related inconsistancies (#130)
* feat: add contract finder to export artifacts and addresses for contracts Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * Restore Ethereum_SpokePool.json * Delete 0cbb34d0852dbbdf983e586f15b99b69.json * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * feat: clean up some test related inconsistancies Signed-off-by: chrismaree <christopher.maree@gmail.com>
1 parent df4d784 commit 836bb1a

12 files changed

+26
-60
lines changed

test/HubPool.Admin.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ import { Contract, ethers, randomAddress, utf8ToHex } from "./utils";
33
import { originChainId, destinationChainId, bondAmount, zeroAddress, mockTreeRoot } from "./constants";
44
import { mockSlowRelayRoot, finalFeeUsdc, finalFee, totalBond } from "./constants";
55
import { hubPoolFixture } from "./fixtures/HubPool.Fixture";
6-
import { ZERO_ADDRESS } from "@uma/common";
76

8-
let hubPool: Contract,
9-
weth: Contract,
10-
usdc: Contract,
11-
mockSpoke: Contract,
12-
mockAdapter: Contract,
13-
identifierWhitelist: Contract;
7+
let hubPool: Contract, weth: Contract, usdc: Contract;
8+
let mockSpoke: Contract, mockAdapter: Contract, identifierWhitelist: Contract;
149
let owner: SignerWithAddress, other: SignerWithAddress;
1510

1611
describe("HubPool Admin functions", function () {
@@ -66,7 +61,7 @@ describe("HubPool Admin functions", function () {
6661
await expect(hubPool.connect(other).relaySpokePoolAdminFunction(destinationChainId, functionData)).to.be.reverted;
6762

6863
// Cannot relay admin function if spoke pool is set to zero address or adapter is set to non contract..
69-
await hubPool.setCrossChainContracts(destinationChainId, mockAdapter.address, ZERO_ADDRESS);
64+
await hubPool.setCrossChainContracts(destinationChainId, mockAdapter.address, zeroAddress);
7065
await expect(hubPool.relaySpokePoolAdminFunction(destinationChainId, functionData)).to.be.revertedWith(
7166
"SpokePool not initialized"
7267
);

test/HubPool.ExecuteRootBundle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { toBNWei, SignerWithAddress, seedWallet, expect, Contract, ethers, rando
22
import * as consts from "./constants";
33
import { hubPoolFixture, enableTokensForLP } from "./fixtures/HubPool.Fixture";
44
import { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves } from "./MerkleLib.utils";
5-
import { ZERO_ADDRESS } from "@uma/common";
65

76
let hubPool: Contract, mockAdapter: Contract, weth: Contract, dai: Contract, mockSpoke: Contract, timer: Contract;
87
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;
@@ -156,7 +155,7 @@ describe("HubPool Root Bundle Execution", function () {
156155
.proposeRootBundle([3117, 3118], 2, tree.getHexRoot(), consts.mockRelayerRefundRoot, consts.mockSlowRelayRoot);
157156

158157
// Set spoke pool to address 0x0
159-
await hubPool.setCrossChainContracts(consts.repaymentChainId, mockAdapter.address, ZERO_ADDRESS);
158+
await hubPool.setCrossChainContracts(consts.repaymentChainId, mockAdapter.address, consts.zeroAddress);
160159

161160
// Advance time so the request can be executed and check that executing the request reverts.
162161
await timer.setCurrentTime(Number(await timer.getCurrentTime()) + consts.refundProposalLiveness + 1);
@@ -194,7 +193,7 @@ describe("HubPool Root Bundle Execution", function () {
194193
);
195194

196195
// Let's set weth pool rebalance route to zero address.
197-
await hubPool.setPoolRebalanceRoute(consts.repaymentChainId, weth.address, ZERO_ADDRESS);
196+
await hubPool.setPoolRebalanceRoute(consts.repaymentChainId, weth.address, consts.zeroAddress);
198197

199198
// Advance time so the request can be executed and check that executing the request reverts.
200199
await timer.setCurrentTime(Number(await timer.getCurrentTime()) + consts.refundProposalLiveness + 1);

test/HubPool.ProtocolFees.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { toWei, toBNWei, SignerWithAddress, seedWallet, expect, Contract, ethers } from "./utils";
2-
import { mockTreeRoot, finalFee, bondAmount, amountToLp, refundProposalLiveness } from "./constants";
2+
import { mockTreeRoot, finalFee, bondAmount, amountToLp, refundProposalLiveness, zeroAddress } from "./constants";
33
import { hubPoolFixture, enableTokensForLP } from "./fixtures/HubPool.Fixture";
44
import { constructSingleChainTree } from "./MerkleLib.utils";
5-
import { ZERO_ADDRESS } from "@uma/common";
65

76
let hubPool: Contract, weth: Contract, timer: Contract;
87
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;
@@ -34,7 +33,7 @@ describe("HubPool Protocol fees", function () {
3433
const newPct = toWei("0.1");
3534

3635
// Can't set to 0 address
37-
await expect(hubPool.connect(owner).setProtocolFeeCapture(ZERO_ADDRESS, newPct)).to.be.reverted;
36+
await expect(hubPool.connect(owner).setProtocolFeeCapture(zeroAddress, newPct)).to.be.reverted;
3837

3938
await hubPool.connect(owner).setProtocolFeeCapture(liquidityProvider.address, newPct);
4039
expect(await hubPool.callStatic.protocolFeeCaptureAddress()).to.equal(liquidityProvider.address);

test/chain-specific-spokepools/Arbitrum_SpokePool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants";
1+
import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress } from "../constants";
22
import { ethers, expect, Contract, FakeContract, SignerWithAddress, createFake, toWei } from "../utils";
33
import { getContractFactory, seedContract, avmL1ToL2Alias, hre, toBN, toBNWei } from "../utils";
44
import { hubPoolFixture } from "../fixtures/HubPool.Fixture";
55
import { constructSingleRelayerRefundTree } from "../MerkleLib.utils";
6-
import { ZERO_ADDRESS } from "@uma/common";
76

87
let hubPool: Contract, arbitrumSpokePool: Contract, timer: Contract, dai: Contract, weth: Contract;
98
let l2Weth: string, l2Dai: string, crossDomainAliasAddress;
@@ -91,7 +90,7 @@ describe("Arbitrum Spoke Pool", function () {
9190
await arbitrumSpokePool.connect(crossDomainAlias).relayRootBundle(tree.getHexRoot(), mockTreeRoot);
9291

9392
// Reverts if route from arbitrum to mainnet for l2Dai isn't whitelisted.
94-
await arbitrumSpokePool.connect(crossDomainAlias).whitelistToken(l2Dai, ZERO_ADDRESS);
93+
await arbitrumSpokePool.connect(crossDomainAlias).whitelistToken(l2Dai, zeroAddress);
9594
await expect(
9695
arbitrumSpokePool.executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0]))
9796
).to.be.revertedWith("Uninitialized mainnet token");

test/chain-specific-spokepools/Polygon_SpokePool.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
import { TokenRolesEnum, ZERO_ADDRESS } from "@uma/common";
2-
import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants";
3-
import {
4-
ethers,
5-
expect,
6-
Contract,
7-
SignerWithAddress,
8-
getContractFactory,
9-
seedContract,
10-
toWei,
11-
randomBigNumber,
12-
seedWallet,
13-
FakeContract,
14-
createFake,
15-
} from "../utils";
1+
import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress, TokenRolesEnum } from "../constants";
2+
import { ethers, expect, Contract, SignerWithAddress, getContractFactory, createFake } from "../utils";
3+
import { seedContract, toWei, randomBigNumber, seedWallet, FakeContract } from "../utils";
164
import { hubPoolFixture } from "../fixtures/HubPool.Fixture";
175
import { constructSingleRelayerRefundTree } from "../MerkleLib.utils";
186
import { randomBytes } from "crypto";
@@ -223,7 +211,7 @@ describe("Polygon Spoke Pool", function () {
223211
// Checks that there's a burn event from the bridger.
224212
await expect(polygonSpokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])))
225213
.to.emit(dai, "Transfer")
226-
.withArgs(bridger, ZERO_ADDRESS, amountToReturn);
214+
.withArgs(bridger, zeroAddress, amountToReturn);
227215
});
228216

229217
it("PolygonTokenBridger retrieves and unwraps tokens correctly", async function () {

test/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { toWei, utf8ToHex, toBN, createRandomBytes32, ethers, hre } from "./utils";
22

3+
export { TokenRolesEnum } from "@uma/common";
4+
35
export const maxUint256 = ethers.constants.MaxInt256;
46

57
export const amountToSeedWallets = toWei("1500");

test/fixtures/HubPool.Fixture.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { TokenRolesEnum } from "@uma/common";
21
import { getContractFactory, randomAddress, hre, Contract, Signer } from "../utils";
3-
42
import { originChainId, bondAmount, refundProposalLiveness, finalFee } from "../constants";
5-
import { repaymentChainId, finalFeeUsdc } from "../constants";
6-
3+
import { repaymentChainId, finalFeeUsdc, TokenRolesEnum } from "../constants";
74
import { umaEcosystemFixture } from "./UmaEcosystem.Fixture";
85

96
export const hubPoolFixture = hre.deployments.createFixture(async ({ ethers }) => {

test/fixtures/SpokePool.Fixture.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { TokenRolesEnum } from "@uma/common";
2-
import { getContractFactory, SignerWithAddress, Contract, hre } from "../utils";
3-
import { ethers, BigNumber, defaultAbiCoder, toBN } from "../utils";
1+
import { getContractFactory, SignerWithAddress, Contract, hre, ethers, BigNumber, defaultAbiCoder } from "../utils";
42
import * as consts from "../constants";
53

64
export const spokePoolFixture = hre.deployments.createFixture(async ({ ethers }) => {
@@ -24,15 +22,15 @@ export async function deploySpokePool(ethers: any): Promise<{
2422
// Create tokens:
2523
const weth = await (await getContractFactory("WETH9", deployerWallet)).deploy();
2624
const erc20 = await (await getContractFactory("ExpandedERC20", deployerWallet)).deploy("USD Coin", "USDC", 18);
27-
await erc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
25+
await erc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);
2826
const unwhitelistedErc20 = await (
2927
await getContractFactory("ExpandedERC20", deployerWallet)
3028
).deploy("Unwhitelisted", "UNWHITELISTED", 18);
31-
await unwhitelistedErc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
29+
await unwhitelistedErc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);
3230
const destErc20 = await (
3331
await getContractFactory("ExpandedERC20", deployerWallet)
3432
).deploy("L2 USD Coin", "L2 USDC", 18);
35-
await destErc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
33+
await destErc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);
3634

3735
// Deploy the pool
3836
const spokePool = await (

test/gas-analytics/HubPool.RootExecution.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { toBNWei, toBN, SignerWithAddress, seedWallet, Contract, ethers, hre, ex
22
import { getContractFactory, BigNumber, randomAddress, createRandomBytes32 } from "../utils";
33
import { deployErc20 } from "./utils";
44
import * as consts from "../constants";
5-
import { ZERO_ADDRESS } from "@uma/common";
65
import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture";
76
import { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, PoolRebalanceLeaf } from "../MerkleLib.utils";
87
import { MerkleTree } from "../../utils/MerkleTree";
@@ -96,14 +95,14 @@ describe("Gas Analytics: HubPool Root Bundle Execution", function () {
9695
const adapter = await (await getContractFactory("Mock_Adapter", owner)).deploy();
9796
const spoke = await (
9897
await getContractFactory("MockSpokePool", owner)
99-
).deploy(randomAddress(), hubPool.address, randomAddress(), ZERO_ADDRESS);
98+
).deploy(randomAddress(), hubPool.address, randomAddress(), consts.zeroAddress);
10099
await hubPool.setCrossChainContracts(hubPoolChainId, adapter.address, spoke.address);
101100

102101
for (let i = 0; i < REFUND_CHAIN_COUNT; i++) {
103102
const adapter = await (await getContractFactory("Mock_Adapter", owner)).deploy();
104103
const spoke = await (
105104
await getContractFactory("MockSpokePool", owner)
106-
).deploy(randomAddress(), hubPool.address, randomAddress(), ZERO_ADDRESS);
105+
).deploy(randomAddress(), hubPool.address, randomAddress(), consts.zeroAddress);
107106
await hubPool.setCrossChainContracts(i, adapter.address, spoke.address);
108107
await Promise.all(
109108
l1Tokens.map(async (token) => {

test/gas-analytics/SpokePool.Deposit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { toBNWei, SignerWithAddress, Contract, ethers, seedWallet, toBN } from "../utils";
22
import { constructDepositParams, sendDeposit, warmSpokePool } from "./utils";
33
import * as constants from "../constants";
4-
import { spokePoolFixture, enableRoutes } from "../fixtures/SpokePool.Fixture";
4+
import { spokePoolFixture } from "../fixtures/SpokePool.Fixture";
55

66
require("dotenv").config();
77

0 commit comments

Comments
 (0)