forked from flashbots/mev-boost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
37 lines (30 loc) · 847 Bytes
/
main_test.go
File metadata and controls
37 lines (30 loc) · 847 Bytes
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
package cli
import (
"math/big"
"testing"
"github.com/flashbots/go-boost-utils/types"
"github.com/flashbots/mev-boost/common"
"github.com/stretchr/testify/require"
)
func TestFloatEthTo256Wei(t *testing.T) {
// test with small input
i := 0.000000000000012345
weiU256, err := common.FloatEthTo256Wei(i)
require.NoError(t, err)
require.Equal(t, types.IntToU256(12345), *weiU256)
// test with zero
i = 0
weiU256, err = common.FloatEthTo256Wei(i)
require.NoError(t, err)
require.Equal(t, types.IntToU256(0), *weiU256)
// test with large input
i = 987654.3
weiU256, err = common.FloatEthTo256Wei(i)
require.NoError(t, err)
r := big.NewInt(9876543)
r.Mul(r, big.NewInt(1e17))
referenceWeiU256 := new(types.U256Str)
err = referenceWeiU256.FromBig(r)
require.NoError(t, err)
require.Equal(t, *referenceWeiU256, *weiU256)
}