forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc_test.go
74 lines (61 loc) · 1.74 KB
/
rpc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package txmgr
import (
"fmt"
"math/big"
"testing"
oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
)
func TestTxmgrRPC(t *testing.T) {
minBaseFeeInit := big.NewInt(1000)
minPriorityFeeInit := big.NewInt(2000)
minBlobFeeInit := big.NewInt(3000)
feeThresholdInit := big.NewInt(4000)
bumpFeeRetryTimeInit := int64(100)
cfg := Config{}
cfg.MinBaseFee.Store(minBaseFeeInit)
cfg.MinTipCap.Store(minPriorityFeeInit)
cfg.MinBlobTxFee.Store(minBlobFeeInit)
cfg.FeeLimitThreshold.Store(feeThresholdInit)
cfg.ResubmissionTimeout.Store(bumpFeeRetryTimeInit)
h := newTestHarnessWithConfig(t, &cfg)
appVersion := "test"
server := oprpc.NewServer(
"127.0.0.1",
0,
appVersion,
oprpc.WithAPIs([]rpc.API{
h.mgr.API(),
}),
)
require.NoError(t, server.Start())
defer func() {
_ = server.Stop()
}()
rpcClient, err := rpc.Dial(fmt.Sprintf("http://%s", server.Endpoint()))
require.NoError(t, err)
type tcase struct {
rpcMethod string
initValue *big.Int
}
cases := []tcase{
{"MinBaseFee", minBaseFeeInit},
{"MinPriorityFee", minPriorityFeeInit},
{"MinBlobFee", minBlobFeeInit},
{"FeeThreshold", feeThresholdInit},
{"BumpFeeRetryTime", big.NewInt(bumpFeeRetryTimeInit)},
}
for _, tc := range cases {
t.Run("Get|Set"+tc.rpcMethod, func(t *testing.T) {
var res *big.Int
require.NoError(t, rpcClient.Call(&res, "txmgr_get"+tc.rpcMethod))
require.Equal(t, tc.initValue, res)
newVal := new(big.Int)
newVal.Add(tc.initValue, big.NewInt(1))
require.NoError(t, rpcClient.Call(&res, "txmgr_set"+tc.rpcMethod, newVal))
require.NoError(t, rpcClient.Call(&res, "txmgr_get"+tc.rpcMethod))
require.Equal(t, newVal, res)
})
}
}