forked from akash-network/provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resourcetypes_test.go
52 lines (37 loc) · 1.04 KB
/
resourcetypes_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
package cluster
import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
types "github.com/akash-network/akash-api/go/node/types/v1beta3"
)
func TestResourcePairAvailable(t *testing.T) {
rp := &resourcePair{
allocatable: sdk.NewInt(100),
allocated: sdk.NewInt(0),
}
avail := rp.available()
require.Equal(t, int64(100), avail.Int64())
rp = &resourcePair{
allocatable: sdk.NewInt(100),
allocated: sdk.NewInt(100),
}
avail = rp.available()
require.Equal(t, int64(0), avail.Int64())
}
func TestResourcePairSubNLZ(t *testing.T) {
rp := &resourcePair{
allocatable: sdk.NewInt(100),
allocated: sdk.NewInt(0),
}
adjusted := rp.subNLZ(types.NewResourceValue(0))
require.True(t, adjusted)
avail := rp.available()
require.Equal(t, int64(100), avail.Int64())
adjusted = rp.subNLZ(types.NewResourceValue(9))
require.True(t, adjusted)
avail = rp.available()
require.Equal(t, int64(91), avail.Int64())
adjusted = rp.subNLZ(types.NewResourceValue(92))
require.False(t, adjusted)
}