Skip to content

Commit c0a73b2

Browse files
committed
feat(ethclient): add maxUsedGas to simulate call results ethereum#34820
1 parent a68ecb4 commit c0a73b2

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

ethclient/ethclient.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,13 +833,15 @@ type SimulateCallResult struct {
833833
ReturnValue []byte `json:"returnData"`
834834
Logs []*types.Log `json:"logs"`
835835
GasUsed uint64 `json:"gasUsed"`
836+
MaxUsedGas uint64 `json:"maxUsedGas"`
836837
Status uint64 `json:"status"`
837838
Error *CallError `json:"error,omitempty"`
838839
}
839840

840841
type simulateCallResultMarshaling struct {
841842
ReturnValue hexutil.Bytes
842843
GasUsed hexutil.Uint64
844+
MaxUsedGas hexutil.Uint64
843845
Status hexutil.Uint64
844846
}
845847

ethclient/ethclient_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@ func TestSimulateV1(t *testing.T) {
917917
if results[0].Calls[0].Error != nil {
918918
t.Errorf("expected no error, got %v", results[0].Calls[0].Error)
919919
}
920+
if results[0].Calls[0].MaxUsedGas == 0 {
921+
t.Error("expected maxUsedGas to be set")
922+
}
923+
if results[0].Calls[0].MaxUsedGas < results[0].Calls[0].GasUsed {
924+
t.Errorf("expected maxUsedGas >= gasUsed, got %d < %d", results[0].Calls[0].MaxUsedGas, results[0].Calls[0].GasUsed)
925+
}
920926
}
921927

922928
// TestSimulateV1WithBlockOverrides tests simulate v 1 with block overrides.

ethclient/gen_simulate_call_result.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)