Skip to content

Commit

Permalink
chore: add test to check if tx is successful using estimated gas
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy committed Feb 5, 2024
1 parent 3734c9c commit 557e219
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/RpcCompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ describe('RpcCompatibility', () => {
expect(gas).to.be.lt(30000); // report if gas estimation does not matches Ethereum's behavior to adjust core configuration if necessary.
});

it('should send tx with estimated gas', async () => {
const newValue = 300;
const txParams = {
to: rpcCompatibilityContract.address,
data: rpcCompatibilityContract.interface.encodeFunctionData('updateValue', [newValue]),
};

const estimatedGas = await provider.estimateGas(txParams);
const receipt = await rpcCompatibilityContract.updateValue(newValue, { gasLimit: estimatedGas }).then((tx) => tx.wait());
await checkReceipt(receipt, newValue);
});

it('should support RPC method eth_gasPrice', async () => {
const gasPrice = await provider.send('eth_gasPrice', []);

Expand Down

0 comments on commit 557e219

Please sign in to comment.