Skip to content

Pectra Hiero tests#71

Draft
0x-ds wants to merge 42 commits intorun-pectra-tests-with-hhfrom
denys/run-pectra-tests-with-hh
Draft

Pectra Hiero tests#71
0x-ds wants to merge 42 commits intorun-pectra-tests-with-hhfrom
denys/run-pectra-tests-with-hh

Conversation

@0x-ds
Copy link

@0x-ds 0x-ds commented Feb 20, 2026

Description:

This PR add several Pectra test case related to Hiero functionality.

Related issue(s):

Fixes #

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@0x-ds 0x-ds force-pushed the denys/run-pectra-tests-with-hh branch 2 times, most recently from 7d43d86 to 13c68e4 Compare February 20, 2026 00:56
…n an HTS token is created' test

Signed-off-by: Denys Sinyakov <[email protected]>
…to the same Smart Wallet and send self-sponsored transactions

Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
@0x-ds 0x-ds force-pushed the denys/run-pectra-tests-with-hh branch from 13c68e4 to 1098d26 Compare February 20, 2026 01:18
Copy link
Contributor

@acuarica acuarica left a comment

Choose a reason for hiding this comment

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

Good start, left some comments we can discuss

.gitignore Outdated
# Local environment
.env No newline at end of file
.env
node_modules
Copy link
Contributor

Choose a reason for hiding this comment

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

there shouldn't be node_modules in the repo root, we can revert this

"dev": true,
"license": "(Apache-2.0 WITH LLVM-exception)"
},
"node_modules/@cspotcode/source-map-support": {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have these changes? I don't see any change in package.json

Copy link
Author

Choose a reason for hiding this comment

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

will revert this

* @param {number} [gasLimit=1_500_000] - Gas limit
* @returns {Promise<ethers.TransactionReceipt | null>}
*/
async function associateHtsToken(eoa, tokenAddress, nonce, gasLimit = 1_500_000) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe HTS specific functions should be placed under its own module, e.g., utils/hts.js, to avoid polluting this web3.js module

Copy link
Contributor

Choose a reason for hiding this comment

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

we could rename this to hts.test.js given at the moment contains HTS related tests.

Additional Hiero specific tests could be placed in their own file.

Copy link
Author

Choose a reason for hiding this comment

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

sure, will rename

@@ -0,0 +1,138 @@
const assert = require('node:assert').strict;
const log = require('node:util').debuglog('hip-1340');
Copy link
Contributor

Choose a reason for hiding this comment

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

each module should have its own logger section, e.g.,

Suggested change
const log = require('node:util').debuglog('hip-1340');
const log = require('node:util').debuglog('hip-1340:hts');

await waitFor(tokenCreateContract.grantTokenKycPublic(tokenAddress, receiver.address));

// Transfer HTS tokens from treasury to both EOAs
await waitFor(tokenCreateContract.transferTokenPublic(tokenAddress, eoa1.address, 5_000));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: all amounts, either HBAR or token's should be bigints for consistency

Suggested change
await waitFor(tokenCreateContract.transferTokenPublic(tokenAddress, eoa1.address, 5_000));
await waitFor(tokenCreateContract.transferTokenPublic(tokenAddress, eoa1.address, 5_000n));

provider = (await ethers.getSigners())[0].provider;
network = await provider.getNetwork();

return { provider, network, log };
Copy link
Contributor

Choose a reason for hiding this comment

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

if log is not used, we can remove it

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, I used to use it, but no longer the case

// Deploy Simple7702Account (the Smart Wallet both EOAs will delegate to)
const smartWallet = await deploy(SIMPLE_7702_ACCOUNT);

const [eoa1Nonce, eoa2Nonce, receiverNonce] = [new Nonce(), new Nonce(), new Nonce()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that eoa1Nonce, et. all refers to the same nonce (no aliases) we could use Number instead, right?

Copy link
Author

Choose a reason for hiding this comment

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

const anotherAddressBalance = await tokenContract.balanceOf(anotherAddress.address);
expect(anotherAddressBalance).to.be.equal(1000);

// Verify the HTS token address has a delegation designator pointing to 0x167
Copy link
Contributor

Choose a reason for hiding this comment

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

At the moment it can be verified by checking both ContractByteCodeQuery and AccountInfo.delegationAddress from CN, something like

const [code, contractBytecode, delegationAddress] = await web3.getCodes(eoa.address);
// TODO(pectra): Reenable check once MN and Relay include support for EIP-7702
// expect(code).to.be.equal(designatorFor(delegateAddress));
expect(contractBytecode).to.be.equal(designatorFor(delegateToAddress));
expect(delegationAddress).to.be.equal(delegateToAddress);

Copy link
Author

Choose a reason for hiding this comment

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

const [code, contractBytecode, delegationAddress] = await web3.getCodes(eoa.address);

Does not seem to work. In my case that won't be eoa, but contract address. And we call mirror node accounts endpoint underneath. I tried using contracts endpoint instead, but mirror node did not return any info. Will look further, to see how that code can be adapted for this case.


it('should return delegation designation to 0x167 when an HTS token is created', async function () {
// Deploy TokenCreateContract and create HTS fungible token
const tokenCreateContract = await Utils.deployTokenCreateContract();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to deploy a token contract here?

Copy link
Author

Choose a reason for hiding this comment

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

One way to create HTS is to use the SDK. Another way to do it is via this helper contract that is used in other test. This way we are doing it via EVM only (no native/SDK).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, so then maybe we can parameterize this test by using both EVM and SDK HTS tokens.

Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
@0x-ds
Copy link
Author

0x-ds commented Feb 21, 2026

@acuarica addressed most comments. Looking further into why below suggestion did not work as expected

const [code, contractBytecode, delegationAddress] = await web3.getCodes(eoa.address);
// TODO(pectra): Reenable check once MN and Relay include support for EIP-7702
// expect(code).to.be.equal(designatorFor(delegateAddress));
expect(contractBytecode).to.be.equal(designatorFor(delegateToAddress));
expect(delegationAddress).to.be.equal(delegateToAddress);

@0x-ds
Copy link
Author

0x-ds commented Feb 23, 2026

@acuarica addressed most comments. Looking further into why below suggestion did not work as expected

const [code, contractBytecode, delegationAddress] = await web3.getCodes(eoa.address);
// TODO(pectra): Reenable check once MN and Relay include support for EIP-7702
// expect(code).to.be.equal(designatorFor(delegateAddress));
expect(contractBytecode).to.be.equal(designatorFor(delegateToAddress));
expect(delegationAddress).to.be.equal(delegateToAddress);

Fixed this, by querying the token endpoint instead.

Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
@0x-ds 0x-ds force-pushed the denys/run-pectra-tests-with-hh branch from fe7fb24 to 82518b6 Compare February 24, 2026 00:09
Signed-off-by: Denys Sinyakov <[email protected]>
…a-evm-testing into denys/run-pectra-tests-with-hh
Copy link
Contributor

@stoyanov-st stoyanov-st left a comment

Choose a reason for hiding this comment

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

The test build is failing due to the targeted CN branch being deleted after a PR was merged.
Please change it to feature/hedera-evm-pectra-support

Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
0x-ds added 22 commits February 27, 2026 15:33
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
…/hedera-evm-testing into denys/run-pectra-tests-with-hh
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
Signed-off-by: Denys Sinyakov <[email protected]>
…a-evm-testing into denys/run-pectra-tests-with-hh
Signed-off-by: Denys Sinyakov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants