|
|
|
@ -2,18 +2,18 @@
|
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
|
|
|
|
|
|
import "forge-std/Test.sol";
|
|
|
|
|
import {SendIt} from "../src/SendIt.sol";
|
|
|
|
|
import {ShipIt} from "../src/ShipIt.sol";
|
|
|
|
|
import {NFT721} from "../src/sampleERC721.sol";
|
|
|
|
|
import {NFT1155} from "../src/sampleERC1155.sol";
|
|
|
|
|
|
|
|
|
|
contract SendItTest is Test {
|
|
|
|
|
contract ShipItTest is Test {
|
|
|
|
|
using stdStorage for StdStorage;
|
|
|
|
|
SendIt public sendit;
|
|
|
|
|
ShipIt public shipit;
|
|
|
|
|
NFT721 public nft721;
|
|
|
|
|
NFT1155 public nft1155;
|
|
|
|
|
|
|
|
|
|
function setUp() public {
|
|
|
|
|
sendit = new SendIt();
|
|
|
|
|
shipit = new ShipIt();
|
|
|
|
|
nft721 = new NFT721();
|
|
|
|
|
nft1155 = new NFT1155();
|
|
|
|
|
}
|
|
|
|
@ -22,7 +22,7 @@ contract SendItTest is Test {
|
|
|
|
|
|
|
|
|
|
function test721BulkTransferSuccess() public {
|
|
|
|
|
uint256 amt = 20;
|
|
|
|
|
uint256 fee = sendit.usageFee();
|
|
|
|
|
uint256 fee = shipit.usageFee();
|
|
|
|
|
uint256 val = fee * amt;
|
|
|
|
|
uint256[] memory tokenIndexes = new uint256[](amt);
|
|
|
|
|
address[] memory recipients = new address[](amt);
|
|
|
|
@ -33,8 +33,8 @@ contract SendItTest is Test {
|
|
|
|
|
vm.deal(address(5), 1 ether);
|
|
|
|
|
vm.startPrank(address(5));
|
|
|
|
|
nft721.mint(amt);
|
|
|
|
|
nft721.setApprovalForAll(address(sendit), true);
|
|
|
|
|
sendit.contractBulkTransfer{value: val}(
|
|
|
|
|
nft721.setApprovalForAll(address(shipit), true);
|
|
|
|
|
shipit.contractBulkTransfer{value: val}(
|
|
|
|
|
address(nft721),
|
|
|
|
|
tokenIndexes,
|
|
|
|
|
recipients,
|
|
|
|
@ -45,7 +45,7 @@ contract SendItTest is Test {
|
|
|
|
|
|
|
|
|
|
function testFail721NonTokenOwnerCanSend() public {
|
|
|
|
|
uint256 amt = 1;
|
|
|
|
|
uint256 fee = sendit.usageFee();
|
|
|
|
|
uint256 fee = shipit.usageFee();
|
|
|
|
|
uint256 val = fee * amt;
|
|
|
|
|
uint256[] memory tokenIndexes = new uint256[](amt);
|
|
|
|
|
address[] memory recipients = new address[](amt);
|
|
|
|
@ -55,10 +55,10 @@ contract SendItTest is Test {
|
|
|
|
|
vm.deal(address(3), 1 ether);
|
|
|
|
|
vm.startPrank(address(5));
|
|
|
|
|
nft721.mint(amt);
|
|
|
|
|
nft721.setApprovalForAll(address(sendit), true);
|
|
|
|
|
nft721.setApprovalForAll(address(shipit), true);
|
|
|
|
|
vm.stopPrank();
|
|
|
|
|
vm.prank(address(3));
|
|
|
|
|
sendit.contractBulkTransfer{value: val}(
|
|
|
|
|
shipit.contractBulkTransfer{value: val}(
|
|
|
|
|
address(nft721),
|
|
|
|
|
tokenIndexes,
|
|
|
|
|
recipients,
|
|
|
|
@ -68,7 +68,7 @@ contract SendItTest is Test {
|
|
|
|
|
|
|
|
|
|
function test1155BulkTransferSuccess() public {
|
|
|
|
|
uint256 amt = 10;
|
|
|
|
|
uint256 fee = sendit.usageFee();
|
|
|
|
|
uint256 fee = shipit.usageFee();
|
|
|
|
|
uint256 val = fee * amt;
|
|
|
|
|
uint256[] memory tokenIndexes = new uint256[](amt);
|
|
|
|
|
address[] memory recipients = new address[](amt);
|
|
|
|
@ -79,8 +79,8 @@ contract SendItTest is Test {
|
|
|
|
|
vm.deal(address(5), 1 ether);
|
|
|
|
|
vm.startPrank(address(5));
|
|
|
|
|
nft1155.mint(1, amt);
|
|
|
|
|
nft1155.setApprovalForAll(address(sendit), true);
|
|
|
|
|
sendit.contractBulkTransfer{value: val}(
|
|
|
|
|
nft1155.setApprovalForAll(address(shipit), true);
|
|
|
|
|
shipit.contractBulkTransfer{value: val}(
|
|
|
|
|
address(nft1155),
|
|
|
|
|
tokenIndexes,
|
|
|
|
|
recipients,
|
|
|
|
@ -91,7 +91,7 @@ contract SendItTest is Test {
|
|
|
|
|
|
|
|
|
|
function testFail1155NonTokenOwnerCanSend() public {
|
|
|
|
|
uint256 amt = 1;
|
|
|
|
|
uint256 fee = sendit.usageFee();
|
|
|
|
|
uint256 fee = shipit.usageFee();
|
|
|
|
|
uint256 val = fee * amt;
|
|
|
|
|
uint256[] memory tokenIndexes = new uint256[](amt);
|
|
|
|
|
address[] memory recipients = new address[](amt);
|
|
|
|
@ -101,10 +101,10 @@ contract SendItTest is Test {
|
|
|
|
|
vm.deal(address(3), 1 ether);
|
|
|
|
|
vm.startPrank(address(5));
|
|
|
|
|
nft1155.mint(1, amt);
|
|
|
|
|
nft1155.setApprovalForAll(address(sendit), true);
|
|
|
|
|
nft1155.setApprovalForAll(address(shipit), true);
|
|
|
|
|
vm.stopPrank();
|
|
|
|
|
vm.prank(address(3));
|
|
|
|
|
sendit.contractBulkTransfer{value: val}(
|
|
|
|
|
shipit.contractBulkTransfer{value: val}(
|
|
|
|
|
address(nft1155),
|
|
|
|
|
tokenIndexes,
|
|
|
|
|
recipients,
|
|
|
|
@ -116,35 +116,35 @@ contract SendItTest is Test {
|
|
|
|
|
|
|
|
|
|
function testUpdateVault() public {
|
|
|
|
|
vm.prank(address(1));
|
|
|
|
|
sendit.updateVault(address(3));
|
|
|
|
|
assertEq(sendit.addressVault(address(1)), address(3));
|
|
|
|
|
shipit.updateVault(address(3));
|
|
|
|
|
assertEq(shipit.addressVault(address(1)), address(3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// admin
|
|
|
|
|
|
|
|
|
|
function testOwnerCanWithdraw() public {
|
|
|
|
|
address owner = sendit.owner();
|
|
|
|
|
vm.deal(address(sendit), 1 ether);
|
|
|
|
|
address owner = shipit.owner();
|
|
|
|
|
vm.deal(address(shipit), 1 ether);
|
|
|
|
|
vm.deal(owner, 1 ether);
|
|
|
|
|
vm.deal(address(20), 2 ether);
|
|
|
|
|
vm.prank(owner);
|
|
|
|
|
sendit.transferOwnership(address(20));
|
|
|
|
|
shipit.transferOwnership(address(20));
|
|
|
|
|
vm.prank(address(20));
|
|
|
|
|
sendit.withdraw();
|
|
|
|
|
shipit.withdraw();
|
|
|
|
|
vm.startPrank(address(30));
|
|
|
|
|
vm.expectRevert();
|
|
|
|
|
sendit.withdraw();
|
|
|
|
|
shipit.withdraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testOwnerCanUpdateFee() public {
|
|
|
|
|
address owner = sendit.owner();
|
|
|
|
|
address owner = shipit.owner();
|
|
|
|
|
vm.deal(owner, 1 ether);
|
|
|
|
|
vm.prank(owner);
|
|
|
|
|
sendit.updateFee(0.1 ether);
|
|
|
|
|
assertEq(sendit.usageFee(), 0.1 ether);
|
|
|
|
|
shipit.updateFee(0.1 ether);
|
|
|
|
|
assertEq(shipit.usageFee(), 0.1 ether);
|
|
|
|
|
vm.startPrank(address(1));
|
|
|
|
|
vm.expectRevert();
|
|
|
|
|
sendit.updateFee(0.25 ether);
|
|
|
|
|
shipit.updateFee(0.25 ether);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|