From 3e34e7499f4bd4c05aa43236531d030db12957e3 Mon Sep 17 00:00:00 2001 From: chrismaree Date: Mon, 4 Nov 2024 12:21:22 +0100 Subject: [PATCH] WIP Signed-off-by: chrismaree --- contracts/SpokePool.sol | 4 +++- test/evm/hardhat/SpokePool.Deposit.ts | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index c9280fdee..869d35de1 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -502,7 +502,9 @@ abstract contract SpokePool is // slither-disable-next-line timestamp uint256 currentTime = getCurrentTime(); - if (currentTime - quoteTimestamp > depositQuoteTimeBuffer) revert InvalidQuoteTimestamp(); + if (quoteTimestamp > currentTime || currentTime - quoteTimestamp > depositQuoteTimeBuffer) { + revert InvalidQuoteTimestamp(); + } // fillDeadline is relative to the destination chain. // Don’t allow fillDeadline to be more than several bundles into the future. diff --git a/test/evm/hardhat/SpokePool.Deposit.ts b/test/evm/hardhat/SpokePool.Deposit.ts index 434917ecc..53d20677c 100644 --- a/test/evm/hardhat/SpokePool.Deposit.ts +++ b/test/evm/hardhat/SpokePool.Deposit.ts @@ -30,7 +30,7 @@ import { const { AddressZero: ZERO_ADDRESS } = ethers.constants; -describe("SpokePool Depositor Logic", async function () { +describe.only("SpokePool Depositor Logic", async function () { let spokePool: Contract, weth: Contract, erc20: Contract, unwhitelistedErc20: Contract; let depositor: SignerWithAddress, recipient: SignerWithAddress; let quoteTimestamp: number; @@ -405,6 +405,12 @@ describe("SpokePool Depositor Logic", async function () { ...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.sub(quoteTimeBuffer).sub(1)) ) ).to.be.revertedWith("InvalidQuoteTimestamp"); + await expect( + spokePool.connect(depositor).depositV3( + // quoteTimestamp in the future should also revert with InvalidQuoteTimestamp + ...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.add(500)) + ) + ).to.be.revertedWith("InvalidQuoteTimestamp"); await expect( spokePool.connect(depositor).depositV3( // quoteTimestamp right at the buffer is OK @@ -535,7 +541,10 @@ describe("SpokePool Depositor Logic", async function () { ); }); it("deposit ID state variable incremented", async function () { - await spokePool.connect(depositor).depositV3(...depositArgs); + const tx = await spokePool.connect(depositor).depositV3(...depositArgs); + + const final = await tx.wait(); + console.log("final", final.gasUsed); expect(await spokePool.numberOfDeposits()).to.equal(1); }); it("tokens are always pulled from caller, even if different from specified depositor", async function () {