Skip to content

Commit

Permalink
feat: added state tests for erc20/721/1155
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Jul 12, 2024
1 parent 899df4b commit cde2871
Show file tree
Hide file tree
Showing 20 changed files with 438 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ coverage/
artifacts/forge-std
artifacts/ds-test
test/state-registry/states.json
test/state-registry/ercStates.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/openzeppelin/ERC-20/ERC20Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract ERC20Mock is ERC20 {
contract OZERC20Mock is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

function mint(address to, uint256 amount) public virtual {
Expand Down
2 changes: 1 addition & 1 deletion contracts/openzeppelin/ERC-721/ERC721Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract ERC721Mock is ERC721 {
contract OZERC721Mock is ERC721 {
constructor(string memory name, string memory symbol) ERC721(name, symbol) {}

function mint(address to, uint256 tokenId) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const getHederaSmartContractAssets = (HederaSmartContractsRootPath: string) => {
ERC20Mock: {
name: 'ERC20Mock',
contractPath: `${HederaSmartContractsRootPath}/contracts/openzeppelin/ERC-20/ERC20Mock.sol`,
artifactPath: `${HederaSmartContractsRootPath}/artifacts/contracts/openzeppelin/ERC-20/ERC20Mock.sol/ERC20Mock.json`,
artifactPath: `${HederaSmartContractsRootPath}/artifacts/contracts/openzeppelin/ERC-20/ERC20Mock.sol/OZERC20Mock.json`,
},
ERC721Mock: {
name: 'ERC721Mock',
contractPath: `${HederaSmartContractsRootPath}/contracts/openzeppelin/ERC-721/ERC721Mock.sol`,
artifactPath: `${HederaSmartContractsRootPath}/artifacts/contracts/openzeppelin/ERC-721/ERC721Mock.sol/ERC721Mock.json`,
artifactPath: `${HederaSmartContractsRootPath}/artifacts/contracts/openzeppelin/ERC-721/ERC721Mock.sol/OZERC721Mock.json`,
},
};
};
Expand Down
4 changes: 2 additions & 2 deletions system-contract-dapp-playground/src/utils/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/

import { TContractName } from '@/types/common';
import ERC20Mock from '@hashgraph-smartcontract/artifacts/contracts/openzeppelin/ERC-20/ERC20Mock.sol/ERC20Mock.json';
import ERC721Mock from '@hashgraph-smartcontract/artifacts/contracts/openzeppelin/ERC-721/ERC721Mock.sol/ERC721Mock.json';
import ERC20Mock from '@hashgraph-smartcontract/artifacts/contracts/openzeppelin/ERC-20/ERC20Mock.sol/OZERC20Mock.json';
import ERC721Mock from '@hashgraph-smartcontract/artifacts/contracts/openzeppelin/ERC-721/ERC721Mock.sol/OZERC721Mock.json';
import IHRC719Contract from '@hashgraph-smartcontract/artifacts/contracts/system-contracts/hedera-token-service/IHRC719.sol/IHRC719.json';
import ExchangeRatePrecompile from '@hashgraph-smartcontract/artifacts/contracts/system-contracts/exchange-rate/ExchangeRateMock.sol/ExchangeRateMock.json';
import PrngSystemContract from '@hashgraph-smartcontract/artifacts/contracts/system-contracts/pseudo-random-number-generator/PrngSystemContract.sol/PrngSystemContract.json';
Expand Down
7 changes: 5 additions & 2 deletions test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ const Events = {
const Path = {
BLOCK_INFO: 'contracts/solidity/block/BlockInfo.sol:BlockInfo',
CRYPTO_MATH: 'contracts/solidity/cryptomath/CryptoMath.sol:CryptoMath',
ERC20Mock: 'contracts/openzeppelin/ERC-20/ERC20Mock.sol:ERC20Mock',
ERC721Mock: 'contracts/openzeppelin/ERC-721/ERC721Mock.sol:ERC721Mock',
HIP583_ERC20Mock: 'contracts/hip-583/ERC20Mock.sol:ERC20Mock',
HIP583_ERC721Mock: 'contracts/hip-583/ERC721Mock.sol:ERC721Mock',
HRC: 'contracts/hrc/HRC.sol:HRC',
Expand All @@ -75,6 +73,8 @@ const Path = {

const Contract = {
ERC20Mock: 'ERC20Mock',
OZERC20Mock: 'OZERC20Mock',
OZERC721Mock: 'OZERC721Mock',
TokenCreateContract: 'TokenCreateContract',
DiamondCutFacet: 'DiamondCutFacet',
Diamond: 'Diamond',
Expand Down Expand Up @@ -200,6 +200,7 @@ const Contract = {
CryptoOwner: 'CryptoOwner',
CancunOpcodes: 'CancunOpcodes',
KZGPointEvaluation: 'KZGPointEvaluation',
StateRegistry: 'StateRegistry',
};

const CALL_EXCEPTION = 'CALL_EXCEPTION';
Expand All @@ -210,6 +211,7 @@ const GAS_LIMIT_800000 = { gasLimit: 800000 };
const GAS_LIMIT_8000000 = { gasLimit: 8000000 };
const TOKEN_NAME = 'tokenName';
const TOKEN_SYMBOL = 'tokenSymbol';
const TOKEN_URL = 'tokenUrl';
const TX_SUCCESS_CODE = 22;
const SECOND = (WEI = 1);
const MINUTE = 60 * SECOND;
Expand All @@ -228,6 +230,7 @@ module.exports = {
GAS_LIMIT_10_000_000,
GAS_LIMIT_800000,
GAS_LIMIT_8000000,
TOKEN_URL,
TOKEN_NAME,
TOKEN_SYMBOL,
TX_SUCCESS_CODE,
Expand Down
4 changes: 3 additions & 1 deletion test/openzeppelin/ERC-20/ERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ describe('@OZERC20 Test Suite', function () {
before(async function () {
signers = await ethers.getSigners();

const factory = await ethers.getContractFactory(Constants.Path.ERC20Mock);
const factory = await ethers.getContractFactory(
Constants.Contract.OZERC20Mock
);
erc20 = await factory.deploy(Constants.TOKEN_NAME, 'TOKENSYMBOL');
await erc20.mint(signers[0].address, 1000);
});
Expand Down
2 changes: 1 addition & 1 deletion test/openzeppelin/ERC-4626/TokenVault.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('@OZTokenVault Test Suite', function () {
let addrs;

beforeEach(async function () {
ERC20Mock = await ethers.getContractFactory(Constants.Path.ERC20Mock);
ERC20Mock = await ethers.getContractFactory(Constants.Contract.OZERC20Mock);
asset = await ERC20Mock.deploy(
'MockToken',
'MTK',
Expand Down
2 changes: 1 addition & 1 deletion test/openzeppelin/ERC-721-Receiver/ERC721Receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('@OZIERC721Receiver Test Suite', () => {
Constants.Contract.ValidERC721Receiver
);
const erc721TokenFac = await ethers.getContractFactory(
Constants.Path.ERC721Mock
Constants.Contract.OZERC721Mock
);

invalidErc721Receiver = await invalidErc721ReceiverFac.deploy();
Expand Down
4 changes: 3 additions & 1 deletion test/openzeppelin/ERC-721/ERC721.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ describe('@OZERC721 Test Suite', function () {
before(async function () {
signers = await ethers.getSigners();

const factory = await ethers.getContractFactory(Constants.Path.ERC721Mock);
const factory = await ethers.getContractFactory(
Constants.Contract.OZERC721Mock
);
erc721 = await factory.deploy(Constants.TOKEN_NAME, 'TOKENSYMBOL');
await erc721.mint(signers[0].address, tokenId);
});
Expand Down
2 changes: 1 addition & 1 deletion test/openzeppelin/finanace/VestingWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('@OZVestingWallet Test Suite', () => {
);

const erc20MockFactory = await ethers.getContractFactory(
Constants.Path.ERC20Mock
Constants.Contract.OZERC20Mock
);

erc20Mock = await erc20MockFactory.deploy('Hedera', 'HBAR');
Expand Down
5 changes: 4 additions & 1 deletion test/precompile/hedera-token-service/erc-20/IERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ describe('IERC20 Test Suite', function () {
Constants.Contract.TokenCreateContract
);
await utils.grantTokenKyc(tokenCreateContract, tokenAddress);
IERC20 = await ethers.getContractAt(Constants.Path.ERC20Mock, tokenAddress);
IERC20 = await ethers.getContractAt(
Constants.Contract.OZERC20Mock,
tokenAddress
);
});

it('should be able to get token name', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/precompile/hedera-token-service/redirect-for-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute transfer(address,uint256)', async function () {
const erc20 = await ethers.getContractAt(
Constants.Path.ERC20Mock,
Constants.Contract.OZERC20Mock,
tokenAddress
);
await (
Expand All @@ -224,7 +224,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute transferFrom(address,address,uint256)', async function () {
const erc20 = await ethers.getContractAt(
Constants.Path.ERC20Mock,
Constants.Contract.OZERC20Mock,
tokenAddress
);
await (
Expand Down
4 changes: 2 additions & 2 deletions test/safe-hts-precompile/SafeHTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ describe('SafeHTS library Test Suite', function () {
await signers[0].provider.getBalance(signer1AccountID);

const erc20Mock = await ethers.getContractAt(
Constants.Path.ERC20Mock,
Constants.Contract.OZERC20Mock,
fungibleTokenAddress
);
const signers0BeforeTokenBalance =
await erc20Mock.balanceOf(signer0AccountID);
const signers1BeforeTokenBalance =
await erc20Mock.balanceOf(signer1AccountID);
const erc721Mock = await ethers.getContractAt(
Constants.Path.ERC721Mock,
Constants.Contract.OZERC721Mock,
nonFungibleTokenAddress
);
const nftOwnerBefore = await erc721Mock.ownerOf(
Expand Down
Loading

0 comments on commit cde2871

Please sign in to comment.