Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Feb 13, 2025
1 parent 56afde4 commit bdce8ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions state/core_access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ func TestDelegate(t *testing.T) {
require.NoError(t, err)
require.EqualValues(t, 0, resp.Code)

opts = NewTxConfig(
WithGas(tc.gasLim),
WithGasPrice(tc.gasPrice),
WithKeyName(accounts[2]),
)

resp, err = ca.Undelegate(ctx, ValAddress(valAddr), sdktypes.NewInt(100_000), opts)
require.NoError(t, err)
require.EqualValues(t, 0, resp.Code)
Expand Down
8 changes: 3 additions & 5 deletions state/estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ func (e *estimator) estimateGas(
return gasPrice, uint64(float64(gas) * gasMultiplier), nil
}

// NOTE: final result of the estimation will be multiplied by the `gasMultiplier`(1.1) to cover
// additional costs.
// set fee as 1utia helps to simulate the tx more reliably.
gas, err = client.EstimateGas(ctx, []sdktypes.Msg{msg}, user.SetFee(1))
// Tx client will multiple estimated gas by 1.1 to cover additional costs
gas, err = client.EstimateGas(ctx, []sdktypes.Msg{msg})
if err != nil {
return 0, 0, fmt.Errorf("state: failed to estimate gas: %w", err)
}
return DefaultGasPrice, uint64(float64(gas) * gasMultiplier), nil
return DefaultGasPrice, gas, nil
}

func (e *estimator) queryGasUsedAndPrice(
Expand Down

0 comments on commit bdce8ae

Please sign in to comment.