-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
contracts/tests/OpenNFTsV4Skale/OpenNFTsV4SkaleInitializeTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MITs | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "OpenNFTs/contracts/interfaces/IERC173.sol"; | ||
import "OpenNFTs/contracts/interfaces/IERC721Metadata.sol"; | ||
import "OpenNFTs/contracts/interfaces/IOpenCloneable.sol"; | ||
import "src/interfaces/IOpenNFTsV4.sol"; | ||
|
||
abstract contract OpenNFTsV4SkaleInitializeTest is Test { | ||
address private _collection; | ||
address private _owner = address(0x1); | ||
address private _minter = address(0x12); | ||
address private _buyer = address(0x13); | ||
address private _tester = address(0x4); | ||
bool[] private _options = new bool[](1); | ||
bytes private _optionsEncoded; | ||
|
||
function constructorTest(address owner_, bool init_) public virtual returns (address); | ||
|
||
function setUpOpenNFTsV4Initialize() public { | ||
_collection = constructorTest(_owner, false); | ||
|
||
_options[0] = true; | ||
_optionsEncoded = abi.encode(abi.encode(0, address(0), 0, _options), address(0), 0); | ||
} | ||
|
||
function testInitializeName() public { | ||
IOpenCloneable(_collection).initialize("OpenNFTsV4InitializeTest", "TEST", _owner, _optionsEncoded); | ||
// assertEq(IERC721Metadata(_collection).name(), "OpenNFTsV4InitializeTest"); | ||
} | ||
|
||
function testInitializeSymbol() public { | ||
IOpenCloneable(_collection).initialize("OpenNFTsV4InitializeTest", "TEST", _owner, _optionsEncoded); | ||
assertEq(IERC721Metadata(_collection).symbol(), "TEST"); | ||
} | ||
|
||
function testInitializeOwner() public { | ||
IOpenCloneable(_collection).initialize("OpenNFTsV4InitializeTest", "TEST", _owner, _optionsEncoded); | ||
assertEq(IERC173(_collection).owner(), _owner); | ||
} | ||
|
||
function testInitializeOpen() public { | ||
IOpenCloneable(_collection).initialize("OpenNFTsV4InitializeTest", "TEST", _owner, _optionsEncoded); | ||
assertEq(IOpenNFTsV4(_collection).open(), true); | ||
} | ||
|
||
function testInitializeNotOpen() public { | ||
_options[0] = false; | ||
IOpenCloneable(_collection).initialize( | ||
"OpenNFTsV4InitializeTest", | ||
"TEST", | ||
_owner, | ||
abi.encode(abi.encode(0, address(0), 0, _options), address(0), 0) | ||
); | ||
assertEq(IOpenNFTsV4(_collection).open(), false); | ||
} | ||
|
||
function testFailInitializeTwice() public { | ||
IOpenCloneable(_collection).initialize("OpenNFTsV4InitializeTest", "TEST", _owner, _optionsEncoded); | ||
IOpenCloneable(_collection).initialize("OpenNFTsOldTestTwice", "OPTEST2", _tester, _optionsEncoded); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
contracts/tests/OpenNFTsV4Skale/OpenNFTsV4SkaleMintTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MITs | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "OpenNFTs/contracts/interfaces/IERC721.sol"; | ||
import "OpenNFTs/contracts/interfaces/IERC721Enumerable.sol"; | ||
import "OpenNFTs/contracts/interfaces/IERC2981.sol"; | ||
import "OpenNFTs/contracts/interfaces/IOpenMarketable.sol"; | ||
import "OpenNFTs/contracts/interfaces/IOpenNFTs.sol"; | ||
import "src/interfaces/IOpenNFTsV4.sol"; | ||
|
||
abstract contract OpenNFTsV4SkaleMintTest is Test { | ||
string private constant _TOKEN_URI = "ipfs://bafkreidfhassyaujwpbarjwtrc6vgn2iwfjmukw3v7hvgggvwlvdngzllm"; | ||
|
||
address private _collection; | ||
address private _owner = address(0x1); | ||
address private _minter = address(0x12); | ||
address private _buyer = address(0x13); | ||
address private _tester = address(0x4); | ||
uint256 private _tokenID0; | ||
|
||
function constructorTest(address owner_) public virtual returns (address); | ||
|
||
function setUpOpenNFTsV4Mint() public { | ||
_collection = constructorTest(_owner); | ||
} | ||
|
||
function testOpenNFTsV4Mint1() public { | ||
vm.prank(_owner); | ||
IOpenNFTsV4(_collection).mint(_TOKEN_URI); | ||
} | ||
|
||
function testOpenNFTsV4Mint5() public { | ||
vm.prank(_owner); | ||
IOpenNFTsV4(_collection).mint(_minter, _TOKEN_URI); | ||
} | ||
|
||
function testOpenNFTsV4Mint2() public { | ||
vm.prank(_owner); | ||
IOpenNFTs(_collection).mint(_minter, _TOKEN_URI); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
contracts/tests/OpenNFTsV4Skale/OpenNFTsV4SkaleSupportsTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// SPDX-License-Identifier: MITs | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import {IOpenCloneable} from "@opennfts/contracts/interfaces/IOpenCloneable.sol"; | ||
import {IOpenMarketable} from "@opennfts/contracts/interfaces/IOpenMarketable.sol"; | ||
import {IOpenAutoMarket} from "src/interfaces/IOpenAutoMarket.sol"; | ||
import {IOpenNFTs} from "@opennfts/contracts/interfaces/IOpenNFTs.sol"; | ||
import {OpenNFTsResolver} from "src/OpenNFTsResolver.sol"; | ||
import {IOpenPauseable} from "@opennfts/contracts/interfaces/IOpenPauseable.sol"; | ||
import {IOpenChecker} from "@opennfts/contracts/interfaces/IOpenChecker.sol"; | ||
import {IERC721TokenReceiver} from "@opennfts/contracts/interfaces/IERC721TokenReceiver.sol"; | ||
|
||
import "src/interfaces/IOpenNFTsV4.sol"; | ||
import "src/interfaces/IOpenNFTsV4Skale.sol"; | ||
import "src/OpenNFTsResolver.sol"; | ||
|
||
abstract contract OpenNFTsV4SkaleSupportsTest is Test { | ||
OpenNFTsResolver private _resolver; | ||
address private _collection; | ||
address private _owner = address(0x1); | ||
address private _minter = address(0x12); | ||
address private _buyer = address(0x13); | ||
address private _tester = address(0x4); | ||
bool[] private _options = new bool[](1); | ||
|
||
function constructorTest(address owner_) public virtual returns (address); | ||
|
||
function setUpOpenNFTsV4Supports() public { | ||
_collection = constructorTest(_owner); | ||
|
||
_resolver = new OpenNFTsResolver(_owner, address(this)); | ||
} | ||
|
||
function testOpenNFTsV4CheckErcInterfaces() public { | ||
bool[11] memory expected = [false, true, true, true, true, false, false, false, false, true, false]; | ||
|
||
bool[] memory checks = IOpenChecker(_resolver).checkErcInterfaces(_collection); | ||
|
||
for (uint256 i = 0; i < expected.length; i++) { | ||
assertEq(checks[i], expected[i]); | ||
} | ||
} | ||
|
||
function testOpenNFTsV4CheckSupportedInterfaces() public { | ||
bytes4[9] memory ids = [ | ||
type(IOpenCloneable).interfaceId, | ||
type(IOpenMarketable).interfaceId, | ||
type(IOpenAutoMarket).interfaceId, | ||
type(IOpenNFTs).interfaceId, | ||
type(IOpenNFTsV4).interfaceId, | ||
type(IOpenPauseable).interfaceId, | ||
type(IOpenChecker).interfaceId, | ||
type(IERC721TokenReceiver).interfaceId, | ||
0xffffffff | ||
]; | ||
bool[9] memory expected = [true, false, false, false, true, false, false, false, false]; | ||
|
||
bytes4[] memory interfaceIds = new bytes4[](9); | ||
for (uint256 i = 0; i < ids.length; i++) { | ||
interfaceIds[i] = ids[i]; | ||
} | ||
|
||
bool[] memory checks = IOpenChecker(_resolver).checkSupportedInterfaces(_collection, false, interfaceIds); | ||
|
||
for (uint256 i = 0; i < ids.length; i++) { | ||
console.log("testOpenNFTsV4CheckSupportedInterfaces", i); | ||
assertEq(checks[i], expected[i]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: MITs | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "src/OpenNFTsV4.sol"; | ||
|
||
import "./OpenNFTsV4SkaleInitializeTest.t.sol"; | ||
import "./OpenNFTsV4SkaleSupportsTest.t.sol"; | ||
import "./OpenNFTsV4SkaleMintTest.t.sol"; | ||
|
||
import "OpenNFTs/tests/sets/OpenNFTsTest.t.sol"; | ||
import "OpenNFTs/tests/units/ERC173Test.t.sol"; | ||
|
||
contract OpenNFTsV4SkaleTest is | ||
ERC721FullTest, | ||
ERC173Test, | ||
OpenNFTsV4SkaleInitializeTest, | ||
OpenNFTsV4SkaleMintTest, | ||
OpenNFTsV4SkaleSupportsTest | ||
{ | ||
function constructorTest( | ||
address owner | ||
) public override(ERC721FullTest, ERC173Test, OpenNFTsV4SkaleSupportsTest, OpenNFTsV4SkaleMintTest) returns (address) { | ||
return constructorTest(owner, true); | ||
} | ||
|
||
function constructorTest(address owner, bool init) public override(OpenNFTsV4SkaleInitializeTest) returns (address) { | ||
vm.prank(owner); | ||
bool[] memory options = new bool[](1); | ||
options[0] = true; | ||
|
||
OpenNFTsV4 collection = new OpenNFTsV4(); | ||
if (init) { | ||
collection.initialize( | ||
"OpenNFTsV4Test", | ||
"OPTEST", | ||
owner, | ||
abi.encode(abi.encode(0, address(0), 0, options), address(0), 0) | ||
); | ||
} | ||
|
||
return address(collection); | ||
} | ||
|
||
function mintTest( | ||
address collection, | ||
address minter | ||
) public override(ERC721FullTest) returns (uint256, string memory) { | ||
vm.prank(minter); | ||
return (OpenNFTsV4(collection).mint(_TOKEN_URI), _TOKEN_URI); | ||
} | ||
|
||
function burnTest(address collection, uint256 tokenID) public override(ERC721FullTest) { | ||
console.log("burnTest ~ tokenID", tokenID); | ||
vm.prank(OpenNFTsV4(collection).ownerOf(tokenID)); | ||
OpenNFTsV4(collection).burn(tokenID); | ||
} | ||
|
||
function setUp() public { | ||
setUpERC721Full("OpenNFTsV4Test", "OPTEST"); | ||
setUpERC173(); | ||
setUpOpenNFTsV4Initialize(); | ||
setUpOpenNFTsV4Mint(); | ||
setUpOpenNFTsV4Supports(); | ||
} | ||
} |