Skip to content

Commit 94cf299

Browse files
Fix e2e
1 parent 4fd0d3d commit 94cf299

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

rpc/estimate_fee_pkg_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package rpc
2+
3+
import (
4+
"testing"
5+
6+
"github.com/NethermindEth/juno/core/felt"
7+
"github.com/NethermindEth/juno/utils"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestEstimateFeeMarshalJson(t *testing.T) {
12+
tests := []struct {
13+
name string
14+
f FeeEstimate
15+
want []byte
16+
}{
17+
{ //nolint:dupl
18+
name: "V0_7",
19+
f: FeeEstimate{
20+
L1GasConsumed: new(felt.Felt).SetUint64(1),
21+
L1GasPrice: new(felt.Felt).SetUint64(2),
22+
L2GasConsumed: new(felt.Felt).SetUint64(3),
23+
L2GasPrice: new(felt.Felt).SetUint64(4),
24+
L1DataGasConsumed: new(felt.Felt).SetUint64(5),
25+
L1DataGasPrice: new(felt.Felt).SetUint64(6),
26+
OverallFee: new(felt.Felt).SetUint64(7),
27+
Unit: utils.Ptr(WEI),
28+
rpcVersion: V0_7,
29+
},
30+
want: []byte(`{"gas_consumed":"0x1","gas_price":"0x2","data_gas_consumed":"0x5","data_gas_price":"0x6","overall_fee":"0x7","unit":"WEI"}`),
31+
},
32+
{ //nolint:dupl
33+
name: "V0_8",
34+
f: FeeEstimate{
35+
L1GasConsumed: new(felt.Felt).SetUint64(8),
36+
L1GasPrice: new(felt.Felt).SetUint64(9),
37+
L2GasConsumed: new(felt.Felt).SetUint64(10),
38+
L2GasPrice: new(felt.Felt).SetUint64(11),
39+
L1DataGasConsumed: new(felt.Felt).SetUint64(12),
40+
L1DataGasPrice: new(felt.Felt).SetUint64(13),
41+
OverallFee: new(felt.Felt).SetUint64(14),
42+
Unit: utils.Ptr(WEI),
43+
rpcVersion: V0_8,
44+
},
45+
want: []byte(`{"l1_gas_consumed":"0x8","l1_gas_price":"0x9","l2_gas_consumed":"0xa","l2_gas_price":"0xb","l1_data_gas_consumed":"0xc","l1_data_gas_price":"0xd","overall_fee":"0xe","unit":"WEI"}`),
46+
},
47+
}
48+
for _, tt := range tests {
49+
t.Run(tt.name, func(t *testing.T) {
50+
got, err := tt.f.MarshalJSON()
51+
require.NoError(t, err)
52+
require.Equal(t, tt.want, got)
53+
})
54+
}
55+
}

0 commit comments

Comments
 (0)