Skip to content

Commit

Permalink
linted
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDeadCe11 committed Jun 6, 2024
1 parent 6cc656c commit 6eee8c5
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions test/e2e/TestTransferValidationSIP15ZoneOffererTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {

OrderComponentsLib.empty().withOfferer(offerer1.addr).withZone(address(zone)).withOrderType(
OrderType.FULL_RESTRICTED
).withStartTime(block.timestamp).withEndTime(block.timestamp + vault721.timeDelay() + 100000).withZoneHash(bytes32(0))
.withSalt(0).withConduitKey(conduitKeyOne) // not strictly necessary
).withStartTime(block.timestamp).withEndTime(block.timestamp + vault721.timeDelay() + 100_000).withZoneHash(
bytes32(0)
).withSalt(0).withConduitKey(conduitKeyOne) // not strictly necessary
// fill in offer later
// fill in consideration later
.saveDefault(VALIDATION_ZONE);
Expand Down Expand Up @@ -232,7 +233,7 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
}
}

function testFail(function(Context memory) external fn, Context memory context) internal {
function testFail(function(Context memory) external fn, Context memory context) internal {
try fn(context) {
fail();
} catch (bytes memory reason) {
Expand All @@ -258,8 +259,7 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
matchArgs.shouldIncludeNativeConsideration || matchArgs.considerationItemsPerPrimeOrderCount >= 3;
// Only include an excess offer item when NOT using the transfer
// validation zone or the zone will revert.
matchArgs.shouldIncludeExcessOfferItems =
matchArgs.shouldIncludeExcessOfferItems
matchArgs.shouldIncludeExcessOfferItems = matchArgs.shouldIncludeExcessOfferItems
&& !(matchArgs.shouldUseTransferValidationZoneForPrime || matchArgs.shouldUseTransferValidationZoneForMirror);
// Include some excess native tokens to check that they're ending up
// with the caller afterward.
Expand All @@ -281,7 +281,7 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
testFail(this.execMatchAdvancedOrders_Revert_DebtIncrease, Context(consideration, emptyFulfill, matchArgs));
}

function execMatchAdvancedOrdersFuzz(Context memory context) external stateless {
function execMatchAdvancedOrdersFuzz(Context memory context) external stateless {
// Set up the infrastructure for this function in a struct to avoid
// stack depth issues.
MatchAdvancedOrdersInfra memory infra = MatchAdvancedOrdersInfra({
Expand Down Expand Up @@ -333,8 +333,7 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {

// Convert the orders to advanced orders.
for (uint256 i = 0; i < infra.orders.length; i++) {
infra.advancedOrders[i] =
infra.orders[i].toAdvancedOrder(1, 1, _getExtraData(context.matchArgs.tokenId));
infra.advancedOrders[i] = infra.orders[i].toAdvancedOrder(1, 1, _getExtraData(context.matchArgs.tokenId));
}
vm.warp(block.timestamp + vault721.timeDelay());
// Set up event expectations.
Expand Down Expand Up @@ -450,10 +449,8 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
}
}


function execMatchAdvancedOrders_Revert_DebtIncrease(Context memory context) external stateless {

context.matchArgs.shouldIncludeExcessOfferItems = false;
context.matchArgs.shouldIncludeExcessOfferItems = false;
// Set up the infrastructure for this function in a struct to avoid
// stack depth issues.
MatchAdvancedOrdersInfra memory infra = MatchAdvancedOrdersInfra({
Expand All @@ -474,9 +471,9 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
fuzzPrimeOfferer = makeAndAllocateAccount(context.matchArgs.primeOfferer);
// The mirror offerer is offering ERC20/Native and considering NFTs.
fuzzMirrorOfferer = makeAndAllocateAccount(context.matchArgs.mirrorOfferer);
// fuzzMirrorOfferer.addr = address(uint160(bound(uint160(fuzzPrimeOfferer.addr), 1, type(uint160).max)));
vm.assume(fuzzPrimeOfferer.addr != fuzzMirrorOfferer.addr);
// fuzzMirrorOfferer.addr = address(uint160(bound(uint160(fuzzPrimeOfferer.addr), 1, type(uint160).max)));
vm.assume(fuzzPrimeOfferer.addr != fuzzMirrorOfferer.addr);

fuzzPrimeProxy = deployOrFind(fuzzPrimeOfferer.addr);
fuzzMirrorProxy = deployOrFind(fuzzMirrorOfferer.addr);

Expand All @@ -502,16 +499,14 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {

// Convert the orders to advanced orders.
for (uint256 i = 0; i < infra.orders.length; i++) {
infra.advancedOrders[i] =
infra.orders[i].toAdvancedOrder(1, 1, _getExtraData(context.matchArgs.tokenId));
infra.advancedOrders[i] = infra.orders[i].toAdvancedOrder(1, 1, _getExtraData(context.matchArgs.tokenId));
}


// offerer takes on more debt so that vault state changes negatively before sale

uint256[] memory safes = safeManager.getSafes(fuzzPrimeProxy);

for(uint256 i; i < safes.length; i++){
for (uint256 i; i < safes.length; i++) {
vm.prank(fuzzPrimeOfferer.addr);
genDebt(safes[i], context.matchArgs.collateralAmount / 8, fuzzPrimeProxy);
}
Expand All @@ -522,8 +517,7 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
//empty expect revert because I'm too lazy to calculate the exact amount of extra tax getting pulled
// vm.expectRevert(abi.encodeWithSelector(SIP15ZoneEventsAndErrors.InvalidDynamicTraitValue.selector, address(vault721Adapter), safes[0], 3, DEBTKEY, bytes32(context.matchArgs.collateralAmount / 2), bytes32(((context.matchArgs.collateralAmount / 2) + (context.matchArgs.collateralAmount / 8) - 99513020104531))));
vm.expectRevert();



// Store the native token balances before the call for later reference.
infra.callerBalanceBefore = address(this).balance;
infra.primeOffererBalanceBefore = address(fuzzPrimeOfferer.addr).balance;
Expand Down Expand Up @@ -909,21 +903,17 @@ contract TestTransferValidationSIP15ZoneOffererTest is SetUp {
// used as the number of order pairs to make here.
for (i = 0; i < context.matchArgs.orderPairCount; i++) {
// Mint the NFTs for the prime offerer to sell.
vm.prank(fuzzPrimeProxy);
vm.prank(fuzzPrimeProxy);
uint256 currentVaultId = safeManager.openSAFE(TKN, fuzzPrimeProxy); //NOTE: THIS may be causing the order already fullfilled error
test721_1.mint(fuzzPrimeOfferer.addr, (context.matchArgs.tokenId + i) * 2);
vm.startPrank(fuzzPrimeOfferer.addr);

vm.startPrank(fuzzPrimeOfferer.addr);
tokenForTest.mint(context.matchArgs.collateralAmount);
tokenForTest.approve(fuzzPrimeProxy, context.matchArgs.collateralAmount);
depositCollatAndGenDebt(
TKN,
currentVaultId,
context.matchArgs.collateralAmount,
context.matchArgs.collateralAmount / 2,
fuzzPrimeProxy
);
vm.stopPrank();
TKN, currentVaultId, context.matchArgs.collateralAmount, context.matchArgs.collateralAmount / 2, fuzzPrimeProxy
);
vm.stopPrank();
// Build the OfferItem array for the prime offerer's order.
infra.offerItemArray = _buildPrimeOfferItemArray(context, i);
// Build the ConsiderationItem array for the prime offerer's order.
Expand Down

0 comments on commit 6eee8c5

Please sign in to comment.