Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds tests that verify IHRC904 airdropToken targeted to an EOA are functional when called by a contract #1185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented Jan 17, 2025

Description:
This PR adds tests that verify IHRC904 airdropToken targeted to an EOA are functional when called by a contract, by using the already existing smart contract. This test coverage was in a previous PR and was already reviewed once. Here we separated it from the example contracts so it didn't block the PR and the requested changes, mainly by @quiet-node were addressed.

Related issue(s):

Closes #1109

Notes for reviewer:
One of the tests is currently skipped due to a bug uncovered in the services repo, while testing. The test will fail until the issue is fixed, and a new issue will be created here to remove the skip once the issue in services is resolved.
hashgraph/hedera-services#17409

Checklist

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Left some blocking suggestions tho.

@@ -169,16 +169,14 @@ contract Airdrop is HederaTokenService {
// @param sender The address sending the NFTs
// @param receivers Array of addresses to receive the NFTs
// @return responseCode The response code from the airdrop operation (22 = success)
function nftAirdropDistribute(address token, address sender, address[] memory receivers) public payable returns (int64 responseCode) {
function nftAirdropDistribute(address token, address sender, address[] memory receivers, int64[] memory serials) public payable returns (int64 responseCode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NatSpec is missing the new param, serials.

Comment on lines +228 to +229
const HTS_SYSTEM_CONTRACT_ADDRESS = '0.0.359';
const HAS_SYSTEM_CONTRACT_ADDRESS = '0.0.362';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call thse HTS_SYSTEM_CONTRACT_ID instead?

Comment on lines +47 to +52
tokenCreateContract = await utils.deployContract(
Constants.Contract.TokenCreateContract
);
tokenTransferContract = await utils.deployContract(
Constants.Contract.TokenTransferContract
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let’s drop these changes and include them in a more focused PR in the future, as they are out of scope for this PR.

Let’s use utils.deployContract only for the contracts being tested in this PR to simplify the review process and clearly define the scope.

const utils = require('../utils');
const Constants = require('../../../constants');

describe('HRC-904 AirdropContract Test Suite', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the CI workflow got merged in couple of days ago, it shows that the test filter is HIP904, right? This suite should have the tag as HIP904 for it to be picked up by CI

expect(nftOwner).to.equal(receiver);
});

it.skip('should airdrop non-fungible tokens (NFT) to multiple accounts', async function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we skip this again? If intended, let's add an explantory comment.

Comment on lines -68 to -201
);

return await ethers.getContractAt(
Constants.Contract.TokenCreateContract,
await tokenCreate.getAddress()
);
}

static async deployTokenCreateCustomContract() {
const tokenCreateCustomFactory = await ethers.getContractFactory(
Constants.Contract.TokenCreateCustomContract
);
const tokenCreateCustom = await tokenCreateCustomFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.TokenCreateCustomContract,
await tokenCreateCustom.getAddress()
);
}

static async deployTokenManagementContract() {
const tokenManagementFactory = await ethers.getContractFactory(
Constants.Contract.TokenManagementContract
);
const tokenManagement = await tokenManagementFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.TokenManagementContract,
await tokenManagement.getAddress()
);
}

static async deployTokenQueryContract() {
const tokenQueryFactory = await ethers.getContractFactory(
Constants.Contract.TokenQueryContract
);
const tokenQuery = await tokenQueryFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.TokenQueryContract,
await tokenQuery.getAddress()
);
}

static async deployTokenTransferContract() {
const tokenTransferFactory = await ethers.getContractFactory(
Constants.Contract.TokenTransferContract
);
const tokenTransfer = await tokenTransferFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.TokenTransferContract,
await tokenTransfer.getAddress()
);
}

static async deployHRC719Contract() {
const hrcContractFactory = await ethers.getContractFactory(
Constants.Contract.HRC719Contract
);
const hrcContract = await hrcContractFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.HRC719Contract,
await hrcContract.getAddress()
);
}

static async deployERC20Contract() {
const erc20ContractFactory = await ethers.getContractFactory(
Constants.Contract.ERC20Contract
);
const erc20Contract = await erc20ContractFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

return await ethers.getContractAt(
Constants.Contract.ERC20Contract,
await erc20Contract.getAddress()
);
}

static async deployERC721Contract() {
const erc721ContractFactory = await ethers.getContractFactory(
Constants.Contract.ERC721Contract
);
const erc721Contract = await erc721ContractFactory.deploy(
Constants.GAS_LIMIT_1_000_000
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I love this! great work 🙌 ! However, to keep the PR focused and within scope, let’s create a ticket and address these changes in a separate PR.

@quiet-node quiet-node added the enhancement New feature or request label Jan 17, 2025
@quiet-node quiet-node added this to the 0.12.0 milestone Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests that verify IHRC904 airdropToken targeted to an EOA are functional when called by a contract
2 participants