Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 committed Apr 23, 2024
1 parent 11fb606 commit d72d1fd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/relay/tests/lib/eth/eth_estimateGas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,26 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {

it('should eth_estimateGas for contract create with input field and absent data field', async () => {
const gasEstimation = 1357410;

const mockedCallData = {
from: '0x81cb089c285e5ee3a7353704fb114955037443af',
to: null,
value: 0,
data: '0x81cb089c285e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af',
};

const callData = {
input:
'0x81cb089c285e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af85e5ee3a7353704fb114955037443af',
from: '0x81cb089c285e5ee3a7353704fb114955037443af',
to: null,
value: '0x0',
};
web3Mock.onPost('contracts/call', { ...callData, estimate: true }).reply(200, { result: `0x14b662` });

const gas = await ethImpl.estimateGas({ ...callData }, null);
mockContractCall(mockedCallData, true, 200, { result: `0x14b662` });

const gas = await ethImpl.estimateGas(callData, null);

expect((gas as string).toLowerCase()).to.equal(numberTo0x(gasEstimation).toLowerCase());
});

Expand Down Expand Up @@ -452,7 +462,8 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
try {
ethImpl.contractCallFormat(transaction);
} catch (error) {
expect(error).to.equal(predefined.INVALID_ARGUMENTS('Cannot accept both input and data fields. Use only one.'));
expect(error.code).to.equal(-32000);
expect(error.message).to.equal('Invalid arguments: Cannot accept both input and data fields. Use only one.');
}
});
});

0 comments on commit d72d1fd

Please sign in to comment.