exo-digital-labs / ERC721R

https://erc721r.super.site/
MIT License
240 stars 60 forks source link

test: update test and fixed conflict test deploy #15

Closed madeinfree closed 2 years ago

madeinfree commented 2 years ago

Maybe ready.

TODO LIST

madeinfree commented 2 years ago

Hi, @elie222 I think all the test coverage is done, if any suggestions please let me know, I'd happy to help. and this PR install the hardhat gas-report plugin and add a script for it, thank you!

> npx hardhat test

  ERC721RExample
    ✔ [Check] Check maxMintSupply = 8000
    ✔ [Check] Check mintPrice = 0.1
    ✔ [Check] Check refundPeriod 3888000
    ✔ [Check] Check maxUserMintAmount 5
    ✔ [Check] Check refundEndTime is same with block timestamp in first deploy
    ✔ [Check] Check refundGuaranteeActive = true
    ✔ Should be able to deploy
    ✔ Should be able to mint and request a refund (76ms)
    ✔ [OwnerMint] Should able to mint
    ✔ [PublicMint:Revert] Should not be able to mint when `Public sale is not active` (54ms)
    ✔ [PublicMint:Revert] Should not be able to mint when `Not enough eth sent`
    ✔ [PublicMint:Revert] Should not be able to mint when `Max mint supply reached`
    ✔ [PublicMint:Revert] Should not be able to mint when `Over mint limit`
    ✔ [PreSaleMint:Revert] Should not presale mint when `Not on allow list`
    ✔ [PreSaleMint] Should presale mint merkle tree with valid leaf (43ms)
    ✔ [PreSaleMint:Revert] Should not be mint when `Presale is not active`
    ✔ [PreSaleMint:Revert] Should not be mint when `Value` not enough
    ✔ [PreSaleMint:Revert] Should not be mint when `Max amount` (48ms)
    ✔ [PreSaleMint:Revert] Should not be mint when `Max mint supply`
    ✔ [Refund] Check hasRefunded store correct tokenId (51ms)
    ✔ [Refund:Revert] Should not be refunded when `Not token owner`
    ✔ [Refund:Revert] `Freely minted NFTs cannot be refunded`
    ✔ [Refund:Revert] NFT cannot be refunded twice `Already refunded` (73ms)
    ✔ [Refund] NFT refund should in 45 days (44ms)
    ✔ [Refund:Revert] NFT refund expired after 45 days `Refund expired`
    ✔ [Owner:Revert] Owner should not be able to mint when `Max mint supply reached`
    ✔ [Owner:Revert] Owner can not withdraw when `Refund period not over`
    ✔ [Owner] Owner can withdraw after refundEndTime
    ✔ [Toggle] Owner can call toggleRefundCountdown and refundEndTime add `refundPeriod` days.
    ✔ [Toggle] Owner can call togglePresaleStatus
    ✔ [Toggle] Owner can call togglePublicSaleStatus
    ✔ [Setter] Owner can call setRefundAddress
    ✔ [Setter] Owner can call setMerkleRoot

  33 passing (4s)
elie222 commented 2 years ago

Awesome PR! Really helpful :)

madeinfree commented 2 years ago

@elie222 thank you for quick reply and suggestions, I'll update it soon.

madeinfree commented 2 years ago

@elie222 I updated the hardcode test and using the merkletreejs, and I move merkletree function to scripts folder, what do you think ? thank you for your reply ~

elie222 commented 2 years ago

Left a few more comments. Some minor stylistic issues

madeinfree commented 2 years ago

@elie222 thank you, I updated and checked all test hardcode address, merkle tree and some stylistic issue, rebase the main branch, using new contract method and fixed some unnecessary code.

elie222 commented 2 years ago

thanks. you didn't want to use describe blocks instead of starting each test with something like this: [PublicMint:Revert]?

elie222 commented 2 years ago

I just merged in in any case but maybe the describe blocks approach would be cleaner naming wise

madeinfree commented 2 years ago

Ok, I'll update later and create a new PR!