Skip to content

Commit 7f7dc56

Browse files
committed
test: update contract deployment fee assertion to align with hip-1249
Signed-off-by: Logan Nguyen <[email protected]>
1 parent 668cce9 commit 7f7dc56

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/server/tests/acceptance/rpc_batch1.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
14751475
expect(info).to.have.property('access_list');
14761476
});
14771477

1478-
it('@xts should execute "eth_sendRawTransaction" and deploy a contract with more than 2 HBAR transaction fee and less than max transaction fee', async function () {
1478+
it('@xts should execute "eth_sendRawTransaction" and deploy a contract with reasonable transaction fee within expected bounds', async function () {
14791479
const balanceBefore = await relay.getBalance(accounts[2].wallet.address, 'latest');
14801480

14811481
const gasPrice = await relay.gasPrice();
@@ -1498,12 +1498,17 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
14981498
expect(info.contract_id).to.not.be.null;
14991499
expect(info).to.have.property('created_contract_ids');
15001500
expect(info.created_contract_ids.length).to.be.equal(1);
1501-
const diffInHbars =
1502-
BigInt(balanceBefore - balanceAfter) / BigInt(Constants.TINYBAR_TO_WEIBAR_COEF) / BigInt(100_000_000);
1503-
expect(Number(diffInHbars)).to.be.greaterThan(2);
1504-
expect(Number(diffInHbars)).to.be.lessThan(
1505-
(gasPrice * Constants.MAX_TRANSACTION_FEE_THRESHOLD) / Constants.TINYBAR_TO_WEIBAR_COEF / 100_000_000,
1506-
);
1501+
1502+
// Calculate fee in tinybars first to avoid precision loss, then convert to HBAR for comparison
1503+
const diffInTinybars = BigInt(balanceBefore - balanceAfter) / BigInt(Constants.TINYBAR_TO_WEIBAR_COEF);
1504+
const diffInHbars = Number(diffInTinybars) / 100_000_000; // Convert tinybars to HBAR as decimal
1505+
1506+
const maxPossibleFeeInHbars =
1507+
(gasPrice * Constants.MAX_TRANSACTION_FEE_THRESHOLD) / Constants.TINYBAR_TO_WEIBAR_COEF / 100_000_000;
1508+
1509+
// Ensure fee is greater than 0 and reasonable for contract deployment
1510+
expect(diffInHbars).to.be.greaterThan(0);
1511+
expect(diffInHbars).to.be.lessThan(maxPossibleFeeInHbars);
15071512
});
15081513

15091514
describe('Check subsidizing gas fees', async function () {

0 commit comments

Comments
 (0)