-
Notifications
You must be signed in to change notification settings - Fork 136
/
fvm_test.go
36 lines (29 loc) · 891 Bytes
/
fvm_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
package ffi
import (
"math"
"testing"
"github.com/filecoin-project/go-state-types/big"
"github.com/stretchr/testify/require"
)
func checkSplitBigInt(t *testing.T, i big.Int, hi, lo uint64) {
hiA, loA, err := splitBigInt(i)
require.NoError(t, err)
require.Equal(t, hi, hiA, "hi not equal")
require.Equal(t, lo, loA, "lo not equal")
}
func TestSplitBigIntZero(t *testing.T) {
checkSplitBigInt(t, big.Zero(), 0, 0)
}
func TestSplitBigIntOne(t *testing.T) {
checkSplitBigInt(t, big.NewInt(1), 0, 1)
}
func TestSplitBigIntMax64(t *testing.T) {
checkSplitBigInt(t, big.NewIntUnsigned(math.MaxUint64), 0, math.MaxUint64)
}
func TestSplitBigIntLarge(t *testing.T) {
checkSplitBigInt(t, big.Mul(big.NewIntUnsigned(math.MaxUint64), big.NewInt(8)), 0x7, math.MaxUint64^0x7)
}
func TestSplitBigIntNeg(t *testing.T) {
_, _, err := splitBigInt(big.NewInt(-1))
require.Error(t, err)
}