Skip to content

Commit ce20221

Browse files
committed
fixup! fix(cli): use estimated gas limit by default
1 parent 77521ae commit ce20221

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

internal/config/auth/auth_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// (c) Cartesi and individual authors (see AUTHORS)
2+
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
3+
4+
package auth
5+
6+
import (
7+
"context"
8+
"math/big"
9+
"testing"
10+
11+
"github.com/cartesi/rollups-node/internal/config"
12+
13+
"github.com/spf13/viper"
14+
"github.com/stretchr/testify/require"
15+
)
16+
17+
const testPrivateKey = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
18+
19+
func TestGetTransactOptsBlockchainGasLimit(t *testing.T) {
20+
setupPrivateKeyAuth := func(t *testing.T) {
21+
t.Helper()
22+
viper.Reset()
23+
config.SetDefaults()
24+
viper.Set(config.AUTH_KIND, "private_key")
25+
viper.Set(config.AUTH_PRIVATE_KEY, testPrivateKey)
26+
}
27+
28+
t.Run("default zero leaves gas limit unset", func(t *testing.T) {
29+
setupPrivateKeyAuth(t)
30+
31+
txOpts, err := GetTransactOpts(context.Background(), big.NewInt(31337))
32+
require.NoError(t, err)
33+
require.Zero(t, txOpts.GasLimit)
34+
})
35+
36+
t.Run("non-zero config sets gas limit", func(t *testing.T) {
37+
setupPrivateKeyAuth(t)
38+
viper.Set(config.BLOCKCHAIN_GAS_LIMIT, "123456")
39+
40+
txOpts, err := GetTransactOpts(context.Background(), big.NewInt(31337))
41+
require.NoError(t, err)
42+
require.Equal(t, uint64(123456), txOpts.GasLimit)
43+
})
44+
}

0 commit comments

Comments
 (0)