2018-06-26 19:00:12 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-07-03 21:21:36 -07:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-12-10 06:27:25 -08:00
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2018-06-26 19:00:12 -07:00
|
|
|
)
|
|
|
|
|
2018-07-03 21:21:36 -07:00
|
|
|
func TestPoolEqual(t *testing.T) {
|
|
|
|
p1 := InitialPool()
|
|
|
|
p2 := InitialPool()
|
2018-07-13 13:46:14 -07:00
|
|
|
require.True(t, p1.Equal(p2))
|
2019-01-02 12:29:47 -08:00
|
|
|
p2.BondedTokens = sdk.NewInt(3)
|
2018-07-13 13:46:14 -07:00
|
|
|
require.False(t, p1.Equal(p2))
|
2018-07-03 21:21:36 -07:00
|
|
|
}
|
|
|
|
|
2018-07-13 13:46:14 -07:00
|
|
|
func TestAddBondedTokens(t *testing.T) {
|
2018-06-26 19:00:12 -07:00
|
|
|
pool := InitialPool()
|
2019-01-21 16:52:03 -08:00
|
|
|
pool.NotBondedTokens = sdk.NewInt(10)
|
2019-01-02 12:29:47 -08:00
|
|
|
pool.BondedTokens = sdk.NewInt(10)
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-01-21 16:52:03 -08:00
|
|
|
pool = pool.notBondedTokensToBonded(sdk.NewInt(10))
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-01-02 12:29:47 -08:00
|
|
|
require.True(sdk.IntEq(t, sdk.NewInt(20), pool.BondedTokens))
|
2019-01-21 16:52:03 -08:00
|
|
|
require.True(sdk.IntEq(t, sdk.NewInt(0), pool.NotBondedTokens))
|
2018-06-26 19:00:12 -07:00
|
|
|
}
|
|
|
|
|
2018-07-13 13:46:14 -07:00
|
|
|
func TestRemoveBondedTokens(t *testing.T) {
|
2018-06-26 19:00:12 -07:00
|
|
|
pool := InitialPool()
|
2019-01-21 16:52:03 -08:00
|
|
|
pool.NotBondedTokens = sdk.NewInt(10)
|
2019-01-02 12:29:47 -08:00
|
|
|
pool.BondedTokens = sdk.NewInt(10)
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-01-21 16:52:03 -08:00
|
|
|
pool = pool.bondedTokensToNotBonded(sdk.NewInt(5))
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-01-02 12:29:47 -08:00
|
|
|
require.True(sdk.IntEq(t, sdk.NewInt(5), pool.BondedTokens))
|
2019-01-21 16:52:03 -08:00
|
|
|
require.True(sdk.IntEq(t, sdk.NewInt(15), pool.NotBondedTokens))
|
2018-06-26 19:00:12 -07:00
|
|
|
}
|