Skip to content

Commit a934570

Browse files
committed
WIP
Signed-off-by: Chris Maree <[email protected]>
1 parent 32731e7 commit a934570

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

test/evm/foundry/local/SpokePoolDeprecatedMethods.t.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ contract SpokePoolOverloadedDeprecatedMethodsTest is Test {
5858
mockWETH.deposit{ value: depositAmount }();
5959
mockWETH.approve(address(spokePool), depositAmount);
6060
vm.stopPrank();
61+
62+
// Assert that the spokePool balance is zero at the start
63+
assertEq(mockWETH.balanceOf(address(spokePool)), 0, "SpokePool balance should be zero at setup");
6164
}
6265

6366
function testDeprecatedDeposit() public {
6467
// Here, we are calling the deprecated deposit method, as defined in the deprecated interface. This should, in
6568
// theory, collide with the function selector depositDeprecated_5947912356, thereby calling the legacy deposit
6669
// method on the spoke pool, while using the old old deposit function signature.
6770
vm.startPrank(depositor);
71+
6872
DeprecatedSpokePoolInterface(address(spokePool)).deposit(
6973
depositor, // recipient
7074
address(mockWETH), // originToken
@@ -76,6 +80,8 @@ contract SpokePoolOverloadedDeprecatedMethodsTest is Test {
7680
0 // maxCount
7781
);
7882

83+
assertEq(mockWETH.balanceOf(address(spokePool)), depositAmount, "SpokePool balance should increase");
84+
7985
// Test depositing native ETH directly
8086
DeprecatedSpokePoolInterface(address(spokePool)).deposit{ value: depositAmount }(
8187
depositor, // recipient
@@ -88,10 +94,13 @@ contract SpokePoolOverloadedDeprecatedMethodsTest is Test {
8894
0 // maxCount
8995
);
9096
vm.stopPrank();
97+
98+
assertEq(mockWETH.balanceOf(address(spokePool)), depositAmount * 2, "SpokePool balance should increase");
9199
}
92100

93101
function testBytes32Deposit() public {
94102
vm.prank(depositor);
103+
95104
// Show the bytes32 variant of the new deposit method works.
96105
spokePool.deposit(
97106
address(depositor).toBytes32(), // depositor
@@ -107,6 +116,8 @@ contract SpokePoolOverloadedDeprecatedMethodsTest is Test {
107116
0, // exclusivityParameter
108117
bytes("") // message
109118
);
119+
120+
assertEq(mockWETH.balanceOf(address(spokePool)), depositAmount, "SpokePool balance should increase");
110121
}
111122

112123
function testAddressDeposit() public {
@@ -126,5 +137,7 @@ contract SpokePoolOverloadedDeprecatedMethodsTest is Test {
126137
0, // exclusivityParameter
127138
bytes("") // message
128139
);
140+
141+
assertEq(mockWETH.balanceOf(address(spokePool)), depositAmount, "SpokePool balance should increase");
129142
}
130143
}

test/evm/hardhat/SpokePool.Deposit.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,44 @@ describe("SpokePool Depositor Logic", async function () {
345345
).to.emit(spokePool, "FundsDeposited");
346346
}
347347
});
348+
it.only("should call legacy deposit through overloaded interface", async function () {
349+
// Define the deprecated interface
350+
const DeprecatedSpokePoolInterface = new ethers.utils.Interface([
351+
"function deposit(address recipient, address originToken, uint256 amount, uint256 destinationChainId, int64 relayerFeePct, uint32 quoteTimestamp, bytes memory message, uint256 maxCount) external payable",
352+
]);
353+
354+
// Create a new instance of the SpokePool with the deprecated interface
355+
const deprecatedSpokePool = new ethers.Contract(spokePool.address, DeprecatedSpokePoolInterface, depositor);
356+
357+
// Call the deprecated deposit method
358+
await expect(
359+
await deprecatedSpokePool.deposit(
360+
depositor.address, // recipient
361+
erc20.address, // originToken
362+
amountToDeposit, // amount
363+
destinationChainId, // destinationChainId
364+
0, // relayerFeePct
365+
quoteTimestamp, // quoteTimestamp
366+
"0x", // message
367+
0 // maxCount
368+
)
369+
).to.emit(spokePool, "FundsDeposited");
370+
371+
// Test depositing native ETH directly
372+
await expect(
373+
deprecatedSpokePool.deposit(
374+
depositor.address, // recipient
375+
weth.address, // originToken - still WETH address for native deposits
376+
amountToDeposit, // amount
377+
destinationChainId, // destinationChainId
378+
0, // relayerFeePct
379+
quoteTimestamp, // quoteTimestamp
380+
"0x", // message
381+
0, // maxCount
382+
{ value: amountToDeposit } // Send ETH
383+
)
384+
).to.emit(spokePool, "FundsDeposited");
385+
});
348386

349387
describe("deposit V3", function () {
350388
let relayData: V3RelayData, depositArgs: any[];

0 commit comments

Comments
 (0)