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

Additional equivalence tests for CALL, STATICCALL and DELEGATECALL #2515

Merged
merged 15 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
876 changes: 876 additions & 0 deletions packages/server/tests/acceptance/equivalence.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('EstimatePrecompileContract tests', function () {
accounts[0].wallet,
);
const tx = await estimateContract.createFungibleTokenPublic(accounts[0].wallet.address, {
value: BigInt('10000000000000000000'),
value: BigInt('50000000000000000000'),
emilevgenievgeorgiev marked this conversation as resolved.
Show resolved Hide resolved
gasLimit: 10_000_000,
});

Expand Down
52 changes: 44 additions & 8 deletions packages/server/tests/clients/servicesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default class ServicesClient {
return resp;
} catch (e) {
this.logger.error(e, `${requestIdPrefix} Error executing ${transaction.constructor.name} transaction`);
throw e;
}
}

Expand Down Expand Up @@ -278,14 +279,49 @@ export default class ServicesClient {
const requestIdPrefix = Utils.formatRequestIdMessage(requestId);
// Call a method on a contract exists on Hedera, but is allowed to mutate the contract state
this.logger.info(`${requestIdPrefix} Execute contracts ${contractId}'s createChild method`);
const contractExecTransactionResponse = await this.executeTransaction(
new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(gasLimit)
.setFunction(functionName, params)
.setTransactionMemo('Relay test contract execution'),
requestId,
);
const tx = new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(gasLimit)
.setFunction(functionName, params)
.setTransactionMemo('Relay test contract execution');

const contractExecTransactionResponse = await this.executeTransaction(tx, requestId);

// @ts-ignore
const resp = await this.getRecordResponseDetails(contractExecTransactionResponse, requestId);
const contractExecuteTimestamp = resp.executedTimestamp;
const contractExecutedTransactionId = resp.executedTransactionId;

return { contractExecuteTimestamp, contractExecutedTransactionId };
}

async executeContractCallWithAmount(
contractId,
functionName: string,
params: ContractFunctionParameters,
gasLimit = 500_000,
amount = 0,
requestId?: string,
) {
const requestIdPrefix = Utils.formatRequestIdMessage(requestId);
// Call a method on a contract exists on Hedera, but is allowed to mutate the contract state
this.logger.info(`${requestIdPrefix} Execute contracts ${contractId}'s createChild method`);
const tx = new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(gasLimit)
.setFunction(functionName, params)
.setTransactionMemo('Relay test contract execution');

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

try {
contractExecTransactionResponse = await this.executeTransaction(tx, requestId);
} catch (e) {
throw e;
}

// @ts-ignore
const resp = await this.getRecordResponseDetails(contractExecTransactionResponse, requestId);
Expand Down
Loading
Loading