Skip to content

Commit

Permalink
Improved ERC1155 test due to ERO-01 (CertiK)
Browse files Browse the repository at this point in the history
  • Loading branch information
eloi010 committed Dec 19, 2023
1 parent de75b35 commit 5c9ee0e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/foundry/core/erc6551/ERC6551OpenfortAccountTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ contract ERC6551OpenfortAccountTest is OpenfortBaseTest {
assertTrue(erc6551OpenfortAccount.supportsInterface(type(IERC1155Receiver).interfaceId));
assertTrue(erc6551OpenfortAccount.supportsInterface(type(IERC165).interfaceId));
assertFalse(erc6551OpenfortAccount.supportsInterface(bytes4(0x0000)));
assertEq(erc6551OpenfortAccount.onERC1155Received(address(0), address(0), 0, 0, ""), bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")));
uint256[] memory ids = new uint256[](1);
ids[0] = 1;
uint256[] memory values = new uint256[](1);
values[0] = 1;
assertEq(erc6551OpenfortAccount.onERC1155BatchReceived(address(0), address(0), ids, values, ""), bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")));
}

function testUpdateEntryPoint() public {
Expand Down Expand Up @@ -376,4 +382,37 @@ contract ERC6551OpenfortAccountTest is OpenfortBaseTest {
vm.prank(openfortAdmin);
mockERC721.safeTransferFrom(openfortAdmin, accountAddress2, 1);
}

/*
* Test onERC721Received()
*/
function testSafeTransferFrom1155() public {
mockERC1155.mint(openfortAdmin, 7, 7);

assertEq(mockERC1155.balanceOf(openfortAdmin, 7), 7);
assertEq(mockERC1155.balanceOf(address(erc6551OpenfortAccount), 7), 0);

vm.prank(openfortAdmin);
mockERC1155.safeTransferFrom(openfortAdmin, address(erc6551OpenfortAccount), 7, 7, "");

assertEq(mockERC1155.balanceOf(openfortAdmin, 7), 0);
assertEq(mockERC1155.balanceOf(address(erc6551OpenfortAccount), 7), 7);

vm.prank(openfortAdmin);
erc6551OpenfortAccount.execute{value: 1 ether}(
address(mockERC1155),
0,
abi.encodeWithSignature(
"safeTransferFrom(address,address,uint256,uint256,bytes)",
address(erc6551OpenfortAccount),
openfortAdmin,
7,
7,
""
)
);

assertEq(mockERC1155.balanceOf(openfortAdmin, 7), 7);
assertEq(mockERC1155.balanceOf(address(erc6551OpenfortAccount), 7), 0);
}
}

0 comments on commit 5c9ee0e

Please sign in to comment.