Skip to content

Commit

Permalink
fix: explicitly sort the tokens by addr
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomariscal committed Jul 3, 2024
1 parent 29f6f6e commit 965a4e1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contracts-periphery/test/UmbraBatchSend.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ abstract contract UmbraBatchSendTest is DeployUmbraTest {
error NotSorted();
error TooMuchEthSent();

function _sortSendDataByToken(UmbraBatchSend.SendData[] storage arr) internal {
for (uint256 i = 0; i < arr.length - 1; i++) {
for (uint256 j = 0; j < arr.length - i - 1; j++) {
if (arr[j].tokenAddr > arr[j + 1].tokenAddr) {
UmbraBatchSend.SendData memory temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}

function setUp() public virtual override {
super.setUp();
router = new UmbraBatchSend(IUmbra(address(umbra)));
Expand Down Expand Up @@ -94,6 +106,8 @@ abstract contract UmbraBatchSendTest is DeployUmbraTest {
sendData.push(UmbraBatchSend.SendData(alice, address(token), amount, pkx, ciphertext));
sendData.push(UmbraBatchSend.SendData(bob, address(token), amount2, pkx, ciphertext));

_sortSendDataByToken(sendData);

uint256 totalToll = toll * sendData.length;
token.approve(address(router), totalAmount);
token2.approve(address(router), totalAmount2);
Expand Down

0 comments on commit 965a4e1

Please sign in to comment.