Skip to content

Commit

Permalink
Merge pull request #10 from ProjectOpenSea/dan/2024/02/direct-authori…
Browse files Browse the repository at this point in the history
…ze-tests

WIP - Dan/2024/02/direct authorize tests
  • Loading branch information
0age authored Feb 6, 2024
2 parents 80ed379 + bfa58fb commit 0965384
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 104 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ src = 'reference'
out = 'reference-out'
script = 'reference'
# specify something so it doesn't try to compile the files in test/foundry
test = 'reference'
test = 'test/foundry'

[profile.optimized]
src = 'src'
Expand Down
2 changes: 2 additions & 0 deletions test/foundry/new/FuzzInscribers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ contract FuzzHelpersTest is BaseOrderTest {
== keccak256(abi.encodePacked("test"))
|| keccak256(abi.encodePacked(profile))
== keccak256(abi.encodePacked("lite"))
|| keccak256(abi.encodePacked(profile))
== keccak256(abi.encodePacked("reference"))
) {
expectedReadAccessCount = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions test/foundry/new/helpers/FuzzInscribers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ library FuzzInscribers {
== keccak256(abi.encodePacked("test"))
|| keccak256(abi.encodePacked(profile))
== keccak256(abi.encodePacked("lite"))
|| keccak256(abi.encodePacked(profile))
== keccak256(abi.encodePacked("reference"))
) {
expectedReadAccessCount = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ pragma solidity ^0.8.17;

import { BaseOrderTest } from "../utils/BaseOrderTest.sol";

import { TestZone } from "./impl/TestZone.sol";

import { TestTransferValidationZoneOfferer } from
"seaport/test/TestTransferValidationZoneOfferer.sol";

import { PostFulfillmentStatefulTestZone } from
"./impl/PostFullfillmentStatefulTestZone.sol";
import { StatefulTestZone } from
"./impl/StatefulTestZone.sol";

import {
AdditionalRecipient,
Expand All @@ -31,22 +29,16 @@ import {
import { ConsiderationInterface } from
"seaport-types/src/interfaces/ConsiderationInterface.sol";

contract PostFulfillmentCheckTest is BaseOrderTest {
TestZone zone = new TestZone();
PostFulfillmentStatefulTestZone statefulZone =
new PostFulfillmentStatefulTestZone(50);
contract PreAndPostFulfillmentCheckTest is BaseOrderTest {
StatefulTestZone statefulZone =
new StatefulTestZone(50);

struct Context {
ConsiderationInterface consideration;
uint8 numOriginalAdditional;
uint8 numTips;
}

struct EthConsideration {
address payable recipient;
uint256 amount;
}

function test(function(Context memory) external fn, Context memory context)
internal
{
Expand All @@ -63,18 +55,18 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
referenceConduitController.updateChannel(
address(referenceConduit), address(this), true
);
vm.label(address(zone), "TestZone");
vm.label(address(statefulZone), "TestZone");
}

function testAscendingAmount() public {
test(
this.execAscendingAmount,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execAscendingAmount,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execAscendingAmount,
Context({
Expand Down Expand Up @@ -126,14 +118,14 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
}

function testResolvedCriteria() public {
test(
this.execResolvedCriteria,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execResolvedCriteria,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execResolvedCriteria,
Context({
Expand Down Expand Up @@ -193,14 +185,14 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
}

function testStateChange() public {
test(
this.execStateChange,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execStateChange,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execStateChange,
Context({
Expand Down Expand Up @@ -258,18 +250,19 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
recipient: address(0)
});

assertTrue(statefulZone.called());
assertTrue(statefulZone.authorizeCalled());
assertTrue(statefulZone.validateCalled());
}

function testBasicStateful() public {
test(
this.execBasicStateful,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execBasicStateful,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execBasicStateful,
Context({
Expand Down Expand Up @@ -326,14 +319,14 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
}

function testExectBasicStatefulWithConduit() public {
test(
this.execBasicStatefulWithConduit,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execBasicStatefulWithConduit,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execBasicStatefulWithConduit,
Context({
Expand Down Expand Up @@ -395,14 +388,14 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
function testBasicStateful(uint8 numOriginalAdditional, uint8 numTips)
public
{
test(
this.execBasicStatefulFuzz,
Context({
consideration: consideration,
numOriginalAdditional: numOriginalAdditional,
numTips: numTips
})
);
// test(
// this.execBasicStatefulFuzz,
// Context({
// consideration: consideration,
// numOriginalAdditional: numOriginalAdditional,
// numTips: numTips
// })
// );
test(
this.execBasicStatefulFuzz,
Context({
Expand All @@ -420,7 +413,7 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
);
// make new stateful zone with a larger amount so each additional
// recipient can receive
statefulZone = new PostFulfillmentStatefulTestZone(5000);
statefulZone = new StatefulTestZone(5000);
// clear storage array just in case
delete additionalRecipients;

Expand Down Expand Up @@ -498,7 +491,8 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
});

// assertions
assertTrue(statefulZone.called());
assertTrue(statefulZone.authorizeCalled());
assertTrue(statefulZone.validateCalled());
for (uint256 i = 0; i < allAdditional.length; i++) {
assertEq(
token1.balanceOf(allAdditional[i]),
Expand All @@ -509,14 +503,14 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
}

function testFulfillAvailableAdvancedAscending() public {
test(
this.execFulfillAvailableAdvancedAscending,
Context({
consideration: consideration,
numOriginalAdditional: 0,
numTips: 0
})
);
// test(
// this.execFulfillAvailableAdvancedAscending,
// Context({
// consideration: consideration,
// numOriginalAdditional: 0,
// numTips: 0
// })
// );
test(
this.execFulfillAvailableAdvancedAscending,
Context({
Expand Down Expand Up @@ -584,7 +578,8 @@ contract PostFulfillmentCheckTest is BaseOrderTest {
recipient: address(0),
maximumFulfilled: 1
});
assertTrue(statefulZone.called());
assertTrue(statefulZone.authorizeCalled());
assertTrue(statefulZone.validateCalled());
}

function testExecMatchAdvancedOrdersWithConduit() public {
Expand Down
Loading

0 comments on commit 0965384

Please sign in to comment.