npm install # download modulesnpx hardhat test # run all test case
REPORT_GAS=true npx hardhat test # run all case and show gas cost
npx hardhat node # run local block chain
npx hardhat run scripts/deploy.ts # deploy Distributor3MC contract on lock block chain-
only owner can set ClaimRoot
- Test points :
- user is not the owner, will cannot set ClaimRoot and raise err 'OwnableUnauthorizedAccount'.
- user is owner , will set ClaimRoot successfully.
- claimRoot is updated
- Test points :
-
only owner can set fee
- Test points :
- user is not the owner, will cannot set fee and raise err 'OwnableUnauthorizedAccount'.
- user is owner , will set fee successfully.
- fee is updated.
- Test points :
-
only owner can withdraw ETH
- Test points :
- user is not the owner, will cannot withdraw ETH of contract and raise err 'OwnableUnauthorizedAccount'.
- user is owner , will withdraw all ETH of contract, user balance += contract ETH balance
- Test points :
-
only owner can withdraw token
- Test points :
- user is not the owner, will cannot withdraw token of contract and raise err 'OwnableUnauthorizedAccount'.
- user is owner , user can withdraw the exact number of tokens, user token balance += withdraw amount.
- if withdraw amount > contract balance , withdraw will be reverted "transfer amount exceeds balance"
- Test points :
-
only owner can toggleActive
- Test points :
- user is not the owner, will cannot toggleActive and raise err 'OwnableUnauthorizedAccount'.
- user is owner , user can toggleActive.
- if active is false, will update to true, vice versa.
- Test points :
-
if claimRoot == bytes32(0), toggleActive should not be allowed, vice versa
- Test points :
- if claimRoot == bytes32(0), will cannot toggleActive and raise err 'MerkleRootNotSet.
- Test points :
-
if msg value >= fee, claim should not be reverted
- Test points :
- if value == fee, will claim successfully.
- if value > fee, will claim successfully.
- Test points :
-
if msg value < fee, claim should be reverted
- Test points :
- if value < fee, will cannot claim and raise err 'InsufficientFee.
- Test points :
-
if user have claimed, claim again should be reverted
- Test points :
- if user have claimed and claim again, will cannot claim and raise err 'AlreadyClaimed'.
- Test points :
-
if contract balance < claim amount, claim should be reverted
- Test points :
- if contract balance < claim amount, will cannot claim and raise err 'InsufficientBalance'.
- Test points :
-
if contract status is not active, claim should be reverted, vice versa
- Test points :
- if contract status is not active, will cannot claim and raise err 'NotActive'.
- Test points :
-
if user claim successfully,merkleProofs and nonces should be updated
- Test points :
- merkleProofs[proof] update to 'true'.
- nonces += 1.
- Test points :
-
if user proof is incorrect, claim should be reverted, vice versa
- Test points :
- if user proof is incorrect, will cannot claim and raise err 'InvalidMerkleProof'.
- Test points :
-
if user claim successfully, will receive the token from contract
- Test points :
- user token balance += claim amount
- Test points :
-
if user claim successfully, will emit AirdropClaimed event
- Test points :
- emit AirdropClaimed
- emit args : sender , withdraw amount
- Test points :