Skip to content

Commit

Permalink
chore: add e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: nikolay <n.atanasow94@gmail.com>
  • Loading branch information
natanasow committed Jan 28, 2025
1 parent fa9f894 commit e3d5067
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
33 changes: 32 additions & 1 deletion packages/server/tests/acceptance/rpc_batch1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
// External resources
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
// Other imports
import { numberTo0x, prepend0x } from '@hashgraph/json-rpc-relay/dist/formatters';
import { formatTransactionId, numberTo0x, prepend0x } from '@hashgraph/json-rpc-relay/dist/formatters';
import Constants from '@hashgraph/json-rpc-relay/dist/lib/constants';
// Errors and constants from local resources
import { predefined } from '@hashgraph/json-rpc-relay/dist/lib/errors/JsonRpcError';
import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types';
import {
AccountCreateTransaction,
ContractFunctionParameters,
FileInfo,
FileInfoQuery,
Hbar,
Expand Down Expand Up @@ -581,6 +582,36 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
Assertions.block(blockResult, mirrorBlock, mirrorTransactions, expectedGasPrice, false);
});

it('should execute "eth_getBlockByNumber", hydrated transactions = true for a block that contains a call with CONTRACT_NEGATIVE_VALUE status', async function() {
let transactionId;
let hasContractNegativeValueError = false;
try {
await servicesNode.executeContractCallWithAmount(
mirrorContractDetails.contract_id,
'',
new ContractFunctionParameters(),
500_000,
-100
);
} catch (e: any) {
// regarding the docs and HederaResponseCodes.sol the CONTRACT_NEGATIVE_VALUE code equals 96;
expect(e.status._code).to.equal(96);
hasContractNegativeValueError = true;
transactionId = e.transactionId;
}
expect(hasContractNegativeValueError).to.be.true;

const mirrorResult = await mirrorNode.get(`/contracts/results/${formatTransactionId(transactionId.toString())}`, requestId);
const txHash = mirrorResult.hash;
const blockResult = await relay.call(
RelayCalls.ETH_ENDPOINTS.ETH_GET_BLOCK_BY_NUMBER,
[numberTo0x(mirrorResult.block_number), true],
requestIdPrefix
);
expect(blockResult.transactions).to.not.be.empty;
expect(blockResult.transactions).to.contain(txHash);
});

it('should not cache "latest" block in "eth_getBlockByNumber" ', async function () {
const blockResult = await relay.call(
RelayCalls.ETH_ENDPOINTS.ETH_GET_BLOCK_BY_NUMBER,
Expand Down
4 changes: 1 addition & 3 deletions packages/server/tests/clients/servicesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@ export default class ServicesClient {
.setFunction(functionName, params)
.setTransactionMemo('Relay test contract execution');

if (amount > 0) {
tx.setPayableAmount(Hbar.fromTinybars(amount));
}
tx.setPayableAmount(Hbar.fromTinybars(amount));
let contractExecTransactionResponse: TransactionResponse;

try {
Expand Down

0 comments on commit e3d5067

Please sign in to comment.