2024-02-29 11:54:35 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"cosmossdk.io/math"
|
|
|
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
|
|
|
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
|
|
|
types "git.vdb.to/cerc-io/laconicd/x/registry"
|
2024-02-29 11:54:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type KeeperTestSuite struct {
|
|
|
|
suite.Suite
|
|
|
|
integrationTest.TestFixture
|
|
|
|
|
|
|
|
queryClient types.QueryClient
|
|
|
|
|
|
|
|
accounts []sdk.AccAddress
|
|
|
|
bond bondTypes.Bond
|
|
|
|
}
|
|
|
|
|
|
|
|
func (kts *KeeperTestSuite) SetupTest() {
|
2024-03-07 09:11:53 +00:00
|
|
|
err := kts.TestFixture.Setup()
|
|
|
|
assert.Nil(kts.T(), err)
|
2024-02-29 11:54:35 +00:00
|
|
|
|
|
|
|
// set default params
|
2024-03-07 09:11:53 +00:00
|
|
|
err = kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
|
2024-02-29 11:54:35 +00:00
|
|
|
assert.Nil(kts.T(), err)
|
|
|
|
|
|
|
|
qr := kts.App.QueryHelper()
|
|
|
|
kts.queryClient = types.NewQueryClient(qr)
|
|
|
|
|
|
|
|
// Create a bond
|
|
|
|
bond, err := kts.createBond()
|
|
|
|
assert.Nil(kts.T(), err)
|
|
|
|
kts.bond = *bond
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRegistryKeeperTestSuite(t *testing.T) {
|
|
|
|
suite.Run(t, new(KeeperTestSuite))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) {
|
|
|
|
ctx := kts.SdkCtx
|
|
|
|
|
|
|
|
// Create a funded account
|
2024-07-30 11:05:58 +00:00
|
|
|
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000))
|
2024-02-29 11:54:35 +00:00
|
|
|
|
|
|
|
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000))))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return bond, nil
|
|
|
|
}
|