Skip to content

Commit

Permalink
AT passing nonce to linea_estimateGas
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 committed Jan 31, 2025
1 parent 1ca4e57 commit 695aaa7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void lineaEstimateGasPriorityFeeMinGasPriceLowerBound() {
final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams =
new CallParams(null, sender.getAddress(), null, "", "", "0", null, null, null);
new CallParams(null, sender.getAddress(), null, null, "", "", "0", null, null, null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests()).getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void estimateGasFailsForExceedingModuleLineCountTest() throws Exception {
new EstimateGasTest.CallParams(
null,
sender.getAddress(),
null,
simpleStorage.getContractAddress(),
null,
payload.toHexString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void lineaEstimateGasMatchesEthEstimateGas() {
new CallParams(
null,
sender.getAddress(),
null,
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
Expand All @@ -123,6 +124,7 @@ public void passingGasPriceFieldWorks() {
new CallParams(
null,
sender.getAddress(),
null,
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
Expand All @@ -146,6 +148,7 @@ public void passingChainIdFieldWorks() {
new CallParams(
"0x539",
sender.getAddress(),
null,
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
Expand All @@ -169,6 +172,7 @@ public void passingEIP1559FieldsWorks() {
new CallParams(
null,
sender.getAddress(),
null,
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
Expand All @@ -192,6 +196,7 @@ public void passingChainIdAndEIP1559FieldsWorks() {
new CallParams(
"0x539",
sender.getAddress(),
null,
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
Expand Down Expand Up @@ -219,6 +224,7 @@ public void passingStateOverridesWorks() {
new CallParams(
"0x539",
sender.getAddress(),
null,
sender.getAddress(),
"1",
Bytes.EMPTY.toHexString(),
Expand All @@ -239,6 +245,49 @@ public void passingStateOverridesWorks() {
"transaction up-front cost 0x208cbab601 exceeds transaction sender account balance 0x0");
}

@Test
public void passingNonceWorks() {

final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams =
new CallParams(
null,
sender.getAddress(),
"0",
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
null,
"0x1234",
null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.hasError()).isFalse();
assertThat(respLinea.getResult()).isNotNull();

// try with a future nonce
final CallParams callParamsFuture =
new CallParams(
null,
sender.getAddress(),
"10",
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
null,
"0x1234",
null);

final var reqLineaFuture = new LineaEstimateGasRequest(callParamsFuture);
final var respLineaFuture = reqLineaFuture.execute(minerNode.nodeRequests());
assertThat(respLineaFuture.hasError()).isFalse();
assertThat(respLineaFuture.getResult()).isNotNull();
}

@Test
public void lineaEstimateGasIsProfitable() {

Expand All @@ -259,6 +308,7 @@ public void lineaEstimateGasIsProfitable() {
new CallParams(
null,
sender.getAddress(),
null,
sender.getAddress(),
null,
payload.toHexString(),
Expand Down Expand Up @@ -320,6 +370,7 @@ public void invalidParametersLineaEstimateGasRequestReturnErrorResponse() {
null,
sender.getAddress(),
null,
null,
"",
"",
String.valueOf(Integer.MAX_VALUE),
Expand All @@ -341,6 +392,7 @@ public void revertedTransactionReturnErrorResponse() throws Exception {
new CallParams(
null,
sender.getAddress(),
null,
simpleStorage.getContractAddress(),
"",
"",
Expand All @@ -363,6 +415,7 @@ public void failedTransactionReturnErrorResponse() {
null,
sender.getAddress(),
null,
null,
"",
Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY,
"0",
Expand Down Expand Up @@ -492,6 +545,7 @@ static class RawEstimateGasResponse extends org.web3j.protocol.core.Response<Str
record CallParams(
String chainId,
String from,
String nonce,
String to,
String value,
String data,
Expand Down

0 comments on commit 695aaa7

Please sign in to comment.