Skip to content

Commit

Permalink
refactor(test): remove fuzz testing from integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Dec 7, 2024
1 parent e29f3fc commit 698eaa3
Showing 1 changed file with 14 additions and 49 deletions.
63 changes: 14 additions & 49 deletions test/integration/Grateful.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ contract IntegrationGrateful is IntegrationBase {
//////////////////////////////////////////////////////////////*/

// Tests for Standard Payments
function test_Payment(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_Payment() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];
string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

_approveAndPay(_user, _merchant, tokenAddr, amount, _NOT_YIELDING_FUNDS);

Expand All @@ -36,12 +31,7 @@ contract IntegrationGrateful is IntegrationBase {
}
}

function test_PaymentYieldingFunds(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_PaymentYieldingFunds() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];

Expand All @@ -50,7 +40,7 @@ contract IntegrationGrateful is IntegrationBase {
}

string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

IERC20 token = IERC20(tokenAddr);

Expand Down Expand Up @@ -97,20 +87,15 @@ contract IntegrationGrateful is IntegrationBase {
}
}

function test_PaymentYieldingFundsPartialWithdrawal(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_PaymentYieldingFundsPartialWithdrawal() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];

if (address(grateful.vaults(tokenAddr)) == address(0)) {
continue;
}

uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

// Capture owner's initial balance before payment
uint256 ownerInitialBalance = IERC20(tokenAddr).balanceOf(_owner);
Expand Down Expand Up @@ -173,16 +158,11 @@ contract IntegrationGrateful is IntegrationBase {
}

// Tests for One-Time Payments
function test_OneTimePayment(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_OneTimePayment() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];
string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

_setupAndExecuteOneTimePayment(_user, _merchant, tokenAddr, amount, _PAYMENT_SALT, _NOT_YIELDING_FUNDS);

Expand All @@ -196,12 +176,7 @@ contract IntegrationGrateful is IntegrationBase {
}
}

function test_OneTimePaymentYieldingFunds(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_OneTimePaymentYieldingFunds() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];

Expand All @@ -210,7 +185,7 @@ contract IntegrationGrateful is IntegrationBase {
}

string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

IERC20 token = IERC20(tokenAddr);

Expand Down Expand Up @@ -256,16 +231,11 @@ contract IntegrationGrateful is IntegrationBase {
}
}

function test_OverpaidOneTimePayment(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_OverpaidOneTimePayment() public {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];
string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

uint256 paymentId = _grateful.calculateId(_user, _merchant, tokenAddr, amount);
address precomputed = address(
Expand Down Expand Up @@ -312,12 +282,7 @@ contract IntegrationGrateful is IntegrationBase {
}
}

function test_PaymentWithCustomFee(
uint256 amountMultiplier
) public {
vm.assume(amountMultiplier > 10);
vm.assume(amountMultiplier < 1000);

function test_PaymentWithCustomFee() public {
uint256[] memory customFees = new uint256[](3);
customFees[0] = 0.02 ether; // 2%
customFees[1] = 0; // 0%
Expand All @@ -326,7 +291,7 @@ contract IntegrationGrateful is IntegrationBase {
for (uint256 i = 0; i < _tokens.length; i++) {
address tokenAddr = _tokens[i];
string memory symbol = _tokenSymbols[tokenAddr];
uint256 amount = _tokenAmounts[tokenAddr] * amountMultiplier;
uint256 amount = _tokenAmounts[tokenAddr] * 100;

uint256 expectedOwnerBalance = 0;
uint256 expectedMerchantBalance = 0;
Expand Down

0 comments on commit 698eaa3

Please sign in to comment.