Skip to content

Commit

Permalink
draft: fixed test
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
  • Loading branch information
quiet-node committed Nov 12, 2024
1 parent 2f1afc2 commit 99af572
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = {
// private keys are configured in the genesis file https://github.com/hyperledger/besu/blob/main/config/src/main/resources/dev.json#L20
'0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f',
'0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',
'0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63'
'0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63',
],
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { expect } = require('chai');
const { Contract } = require('ethers');
const { ethers } = require('hardhat');
const utils = require('../utils');
const Constants = require('../../../constants');
Expand All @@ -12,6 +13,8 @@ describe.only('HRC904Contract Test Suite', function () {
let tokenCreateContract;
let tokenAddress;
let signers;
let IHRC904;
let hrc904AccountInterface;

before(async function () {
signers = await ethers.getSigners();
Expand All @@ -25,6 +28,7 @@ describe.only('HRC904Contract Test Suite', function () {
await tokenCreateContract.getAddress(),
await hrc904Contract.getAddress(),
]);

tokenAddress = await utils.createFungibleTokenWithSECP256K1AdminKey(
tokenCreateContract,
signers[0].address,
Expand All @@ -35,48 +39,80 @@ describe.only('HRC904Contract Test Suite', function () {
await tokenCreateContract.getAddress(),
await hrc904Contract.getAddress(),
]);
await utils.associateToken(
tokenCreateContract,
tokenAddress,
Constants.Contract.TokenCreateContract
);
await utils.grantTokenKyc(tokenCreateContract, tokenAddress);

IHRC904 = new ethers.Interface(
(await hre.artifacts.readArtifact('IHRC904')).abi
);
hrc904AccountInterface = new Contract(
signers[1].address,
IHRC904,
signers[1]
);
});

it('should be able to create an HTS fungible token', async function () {
expect(tokenAddress).to.exist;
});

it('should be able to associate receiver with a token', async function () {
const tx = await hrc904Contract.associate(tokenAddress, Constants.GAS_LIMIT_1_000_000);
const tx = await hrc904Contract.associate(
tokenAddress,
Constants.GAS_LIMIT_1_000_000
);
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});

it('should be able to set the auto associate setting to true', async function () {
const tx = await hrc904Contract.setUnlimitedAssociations(signers[1].address, true, {
gasLimit: 1_000_000,
});
const tx = await hrc904AccountInterface.setUnlimitedAutomaticAssociations(
true,
{
gasLimit: 1_000_000,
}
);
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});

it('should be able to airdrop any token in its balance based on token address', async function () {
const tx = await airdropContract.tokenAirdrop(tokenAddress, signers[0].address, signers[1].address, 1, {
gasLimit: 2_000_000,
value: 100_000,
});
const tx = await airdropContract.tokenAirdrop(
tokenAddress,
signers[0].address,
signers[1].address,
1,
{
gasLimit: 2_000_000,
value: 100_000,
}
);
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});

it('should be able to claim any token airdropped to it based on token address', async function () {
const data = hrc904Interface.encodeFunctionData('claimAirdropFT', [signers[0].address]);
const data = hrc904Interface.encodeFunctionData('claimAirdropFT', [
signers[0].address,
]);
const tx = await signers[1].sendTransaction({
to: tokenAddress,
data: data,
gasLimit: 1_000_000
gasLimit: 1_000_000,
});
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});

it('should be able to cancel a token it airdropped', async function () {
const tx = await hrc904Contract.cancelAirdropFT(tokenAddress, hrc904Address);
const tx = await hrc904Contract.cancelAirdropFT(
tokenAddress,
hrc904Address
);
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});
Expand All @@ -88,9 +124,12 @@ describe.only('HRC904Contract Test Suite', function () {
});

it('should be able to set the auto associate setting back to false', async function () {
const tx = await hrc904Contract.setUnlimitedAssociations(signers[1].address, false, {
gasLimit: 1_000_000
});
const tx = await hrc904AccountInterface.setUnlimitedAutomaticAssociations(
false,
{
gasLimit: 1_000_000,
}
);
const receipt = await tx.wait();
expect(receipt.status).to.eq(1);
});
Expand Down

0 comments on commit 99af572

Please sign in to comment.