Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/evm/hardhat/MerkleLib.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
toBNWeiWithDecimals,
createRandomBytes32,
Contract,
hexZeroPadAddress,
addressToBytes,
} from "../../../utils/utils";
import { amountToReturn, repaymentChainId } from "./constants";
import { MerkleTree } from "../../../utils/MerkleTree";
Expand Down Expand Up @@ -110,7 +110,7 @@ export async function constructSingleRelayerRefundTree(l2Token: Contract | Strin
const leaves = buildRelayerRefundLeaves(
[destinationChainId], // Destination chain ID.
[amountToReturn], // amountToReturn.
[hexZeroPadAddress(l2Token as string)], // l2Token.
[addressToBytes(l2Token as string)], // l2Token.
[[]], // refundAddresses.
[[]] // refundAmounts.
);
Expand Down
11 changes: 2 additions & 9 deletions test/evm/hardhat/SpokePool.Admin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
expect,
ethers,
Contract,
SignerWithAddress,
getContractFactory,
hexZeroPadAddress,
} from "../../../utils/utils";
import { expect, ethers, Contract, SignerWithAddress, getContractFactory, addressToBytes } from "../../../utils/utils";
import { hre } from "../../../utils/utils.hre";
import { spokePoolFixture } from "./fixtures/SpokePool.Fixture";
import { destinationChainId, mockRelayerRefundRoot, mockSlowRelayRoot } from "./constants";
Expand All @@ -30,7 +23,7 @@ describe("SpokePool Admin Functions", async function () {
await expect(spokePool.connect(owner).setEnableRoute(erc20.address, destinationChainId, true))
.to.emit(spokePool, "EnabledDepositRoute")
.withArgs(erc20.address, destinationChainId, true);
expect(await spokePool.enabledDepositRoutes(hexZeroPadAddress(erc20.address), destinationChainId)).to.equal(true);
expect(await spokePool.enabledDepositRoutes(addressToBytes(erc20.address), destinationChainId)).to.equal(true);
});

it("Pause deposits", async function () {
Expand Down
133 changes: 66 additions & 67 deletions test/evm/hardhat/SpokePool.Deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
toWei,
randomAddress,
BigNumber,
hexZeroPadAddressLowercase,
hexZeroPadAddress,
addressToBytes,
bytes32ToAddress,
} from "../../../utils/utils";
import {
Expand Down Expand Up @@ -108,18 +107,18 @@ describe("SpokePool Depositor Logic", async function () {
)
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(erc20.address),
hexZeroPadAddressLowercase(ZERO_ADDRESS),
addressToBytes(erc20.address),
addressToBytes(ZERO_ADDRESS),
amountToDeposit,
amountReceived,
destinationChainId,
0,
quoteTimestamp,
MAX_UINT32,
0,
hexZeroPadAddressLowercase(depositor.address),
hexZeroPadAddressLowercase(recipient.address),
hexZeroPadAddressLowercase(ZERO_ADDRESS),
addressToBytes(depositor.address),
addressToBytes(recipient.address),
addressToBytes(ZERO_ADDRESS),
"0x"
);

Expand Down Expand Up @@ -148,18 +147,18 @@ describe("SpokePool Depositor Logic", async function () {
)
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(erc20.address),
hexZeroPadAddressLowercase(ZERO_ADDRESS),
addressToBytes(erc20.address),
addressToBytes(ZERO_ADDRESS),
amountToDeposit,
amountReceived,
destinationChainId,
0,
quoteTimestamp,
BigNumber.from("0xFFFFFFFF"),
0,
hexZeroPadAddressLowercase(newDepositor), // Depositor is overridden.
hexZeroPadAddressLowercase(recipient.address),
hexZeroPadAddressLowercase(ZERO_ADDRESS),
addressToBytes(newDepositor), // Depositor is overridden.
addressToBytes(recipient.address),
addressToBytes(ZERO_ADDRESS),
"0x"
);
});
Expand Down Expand Up @@ -374,16 +373,16 @@ describe("SpokePool Depositor Logic", async function () {
_isAddressOverload = false
) {
return [
_isAddressOverload ? bytes32ToAddress(_relayData.depositor) : hexZeroPadAddress(_relayData.depositor),
_isAddressOverload ? bytes32ToAddress(_relayData.recipient) : hexZeroPadAddress(_relayData.recipient),
_isAddressOverload ? bytes32ToAddress(_relayData.inputToken) : hexZeroPadAddress(_relayData.inputToken),
_isAddressOverload ? bytes32ToAddress(_relayData.outputToken) : hexZeroPadAddress(_relayData.outputToken),
_isAddressOverload ? bytes32ToAddress(_relayData.depositor) : addressToBytes(_relayData.depositor),
_isAddressOverload ? bytes32ToAddress(_relayData.recipient) : addressToBytes(_relayData.recipient),
_isAddressOverload ? bytes32ToAddress(_relayData.inputToken) : addressToBytes(_relayData.inputToken),
_isAddressOverload ? bytes32ToAddress(_relayData.outputToken) : addressToBytes(_relayData.outputToken),
_relayData.inputAmount,
_relayData.outputAmount,
_destinationChainId,
_isAddressOverload
? bytes32ToAddress(_relayData.exclusiveRelayer)
: hexZeroPadAddress(_relayData.exclusiveRelayer),
: addressToBytes(_relayData.exclusiveRelayer),
_quoteTimestamp,
_relayData.fillDeadline,
_relayData.exclusivityDeadline,
Expand All @@ -392,11 +391,11 @@ describe("SpokePool Depositor Logic", async function () {
}
beforeEach(async function () {
relayData = {
depositor: hexZeroPadAddress(depositor.address),
recipient: hexZeroPadAddress(recipient.address),
exclusiveRelayer: hexZeroPadAddress(ZERO_ADDRESS),
inputToken: hexZeroPadAddress(erc20.address),
outputToken: hexZeroPadAddress(randomAddress()),
depositor: addressToBytes(depositor.address),
recipient: addressToBytes(recipient.address),
exclusiveRelayer: addressToBytes(ZERO_ADDRESS),
inputToken: addressToBytes(erc20.address),
outputToken: addressToBytes(randomAddress()),
inputAmount: amountToDeposit,
outputAmount: amountToDeposit.sub(19),
originChainId: originChainId,
Expand Down Expand Up @@ -511,23 +510,23 @@ describe("SpokePool Depositor Logic", async function () {
spokePool
.connect(depositor)
[depositV3NowBytes](
hexZeroPadAddress(relayData.depositor),
hexZeroPadAddress(relayData.recipient),
hexZeroPadAddress(relayData.inputToken),
hexZeroPadAddress(relayData.outputToken),
addressToBytes(relayData.depositor),
addressToBytes(relayData.recipient),
addressToBytes(relayData.inputToken),
addressToBytes(relayData.outputToken),
relayData.inputAmount,
relayData.outputAmount,
destinationChainId,
hexZeroPadAddress(relayData.exclusiveRelayer),
addressToBytes(relayData.exclusiveRelayer),
fillDeadlineOffset,
exclusivityDeadline,
relayData.message
)
)
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(relayData.inputToken),
hexZeroPadAddressLowercase(relayData.outputToken),
addressToBytes(relayData.inputToken),
addressToBytes(relayData.outputToken),
relayData.inputAmount,
relayData.outputAmount,
destinationChainId,
Expand All @@ -536,9 +535,9 @@ describe("SpokePool Depositor Logic", async function () {
currentTime, // quoteTimestamp should be current time
currentTime + fillDeadlineOffset, // fillDeadline should be current time + offset
currentTime,
hexZeroPadAddressLowercase(relayData.depositor),
hexZeroPadAddressLowercase(relayData.recipient),
hexZeroPadAddressLowercase(relayData.exclusiveRelayer),
addressToBytes(relayData.depositor),
addressToBytes(relayData.recipient),
addressToBytes(relayData.exclusiveRelayer),
relayData.message
);
});
Expand All @@ -565,8 +564,8 @@ describe("SpokePool Depositor Logic", async function () {
)
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(relayData.inputToken),
hexZeroPadAddressLowercase(relayData.outputToken),
addressToBytes(relayData.inputToken),
addressToBytes(relayData.outputToken),
relayData.inputAmount,
relayData.outputAmount,
destinationChainId,
Expand All @@ -575,9 +574,9 @@ describe("SpokePool Depositor Logic", async function () {
currentTime, // quoteTimestamp should be current time
currentTime + fillDeadlineOffset, // fillDeadline should be current time + offset
currentTime,
hexZeroPadAddressLowercase(relayData.depositor),
hexZeroPadAddressLowercase(relayData.recipient),
hexZeroPadAddressLowercase(relayData.exclusiveRelayer),
addressToBytes(relayData.depositor),
addressToBytes(relayData.recipient),
addressToBytes(relayData.exclusiveRelayer),
relayData.message
);
});
Expand All @@ -586,8 +585,8 @@ describe("SpokePool Depositor Logic", async function () {
await expect(spokePool.connect(depositor)[depositV3Bytes](...depositArgs))
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(relayData.inputToken),
hexZeroPadAddressLowercase(relayData.outputToken),
addressToBytes(relayData.inputToken),
addressToBytes(relayData.outputToken),
relayData.inputAmount,
relayData.outputAmount,
destinationChainId,
Expand All @@ -596,9 +595,9 @@ describe("SpokePool Depositor Logic", async function () {
quoteTimestamp,
relayData.fillDeadline,
currentTime,
hexZeroPadAddressLowercase(relayData.depositor),
hexZeroPadAddressLowercase(relayData.recipient),
hexZeroPadAddressLowercase(relayData.exclusiveRelayer),
addressToBytes(relayData.depositor),
addressToBytes(relayData.recipient),
addressToBytes(relayData.exclusiveRelayer),
relayData.message
);
});
Expand All @@ -617,8 +616,8 @@ describe("SpokePool Depositor Logic", async function () {
)
.to.emit(spokePool, "V3FundsDeposited")
.withArgs(
hexZeroPadAddressLowercase(relayData.inputToken),
hexZeroPadAddressLowercase(relayData.outputToken),
addressToBytes(relayData.inputToken),
addressToBytes(relayData.outputToken),
relayData.inputAmount,
relayData.outputAmount,
destinationChainId,
Expand All @@ -627,9 +626,9 @@ describe("SpokePool Depositor Logic", async function () {
relayData.fillDeadline,
currentTime,
// New depositor
hexZeroPadAddressLowercase(newDepositor),
hexZeroPadAddressLowercase(relayData.recipient),
hexZeroPadAddressLowercase(relayData.exclusiveRelayer),
addressToBytes(newDepositor),
addressToBytes(relayData.recipient),
addressToBytes(relayData.exclusiveRelayer),
relayData.message
);
expect(await erc20.balanceOf(depositor.address)).to.equal(balanceBefore.sub(amountToDeposit));
Expand Down Expand Up @@ -658,27 +657,27 @@ describe("SpokePool Depositor Logic", async function () {
depositId,
originChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage
);
await spokePool[verifyUpdateV3DepositMessageBytes](
hexZeroPadAddress(depositor.address),
addressToBytes(depositor.address),
depositId,
originChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
signature
);

// Reverts if passed in depositor is the signer or if signature is incorrect
await expect(
spokePool[verifyUpdateV3DepositMessageBytes](
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
depositId,
originChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
signature
)
Expand All @@ -690,16 +689,16 @@ describe("SpokePool Depositor Logic", async function () {
depositId + 1,
originChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage
);
await expect(
spokePool[verifyUpdateV3DepositMessageBytes](
hexZeroPadAddress(depositor.address),
addressToBytes(depositor.address),
depositId,
originChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
invalidSignature
)
Expand All @@ -713,17 +712,17 @@ describe("SpokePool Depositor Logic", async function () {
depositId,
spokePoolChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage
);
await expect(
spokePool
.connect(depositor)
[speedUpV3DepositBytes](
hexZeroPadAddress(depositor.address),
addressToBytes(depositor.address),
depositId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
expectedSignature
)
Expand All @@ -732,8 +731,8 @@ describe("SpokePool Depositor Logic", async function () {
.withArgs(
updatedOutputAmount,
depositId,
hexZeroPadAddressLowercase(depositor.address),
hexZeroPadAddressLowercase(updatedRecipient),
addressToBytes(depositor.address),
addressToBytes(updatedRecipient),
updatedMessage,
expectedSignature
);
Expand All @@ -745,16 +744,16 @@ describe("SpokePool Depositor Logic", async function () {
depositId,
otherChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage
);
await expect(
spokePool[verifyUpdateV3DepositMessageBytes](
hexZeroPadAddress(depositor.address),
addressToBytes(depositor.address),
depositId,
otherChainId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
invalidSignatureForChain
)
Expand All @@ -763,10 +762,10 @@ describe("SpokePool Depositor Logic", async function () {
spokePool
.connect(depositor)
[speedUpV3DepositBytes](
hexZeroPadAddress(depositor.address),
addressToBytes(depositor.address),
depositId,
updatedOutputAmount,
hexZeroPadAddress(updatedRecipient),
addressToBytes(updatedRecipient),
updatedMessage,
invalidSignatureForChain
)
Expand Down Expand Up @@ -815,8 +814,8 @@ describe("SpokePool Depositor Logic", async function () {
.withArgs(
updatedOutputAmount,
depositId,
hexZeroPadAddressLowercase(depositor.address),
hexZeroPadAddressLowercase(updatedRecipient),
addressToBytes(depositor.address),
addressToBytes(updatedRecipient),
updatedMessage,
signature
);
Expand Down
Loading
Loading