Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Dec 19, 2024
1 parent 87b971a commit 0506137
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
16 changes: 9 additions & 7 deletions x/accounts/defaults/lockup/continuous_locking_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

const valAddress = "val_address"

func setupContinuousAccount(t *testing.T, ctx context.Context, ss store.KVStoreService) *ContinuousLockingAccount {
t.Helper()
deps := makeMockDependencies(ss)
Expand All @@ -42,7 +44,7 @@ func TestContinuousAccountDelegate(t *testing.T) {
acc := setupContinuousAccount(t, sdkCtx, ss)
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -61,7 +63,7 @@ func TestContinuousAccountDelegate(t *testing.T) {

_, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(5)),
})
require.NoError(t, err)
Expand All @@ -85,7 +87,7 @@ func TestContinuousAccountUndelegate(t *testing.T) {
// Delegate first
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -97,21 +99,21 @@ func TestContinuousAccountUndelegate(t *testing.T) {
// Undelegate
_, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)

entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address")
entries, err := acc.UnbondEntries.Get(sdkCtx, valAddress)
require.NoError(t, err)
require.Len(t, entries.Entries, 1)
require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1)))
require.True(t, entries.Entries[0].ValidatorAddress == "val_address")
require.True(t, entries.Entries[0].ValidatorAddress == valAddress)

err = acc.checkUnbondingEntriesMature(sdkCtx)
require.NoError(t, err)

_, err = acc.UnbondEntries.Get(sdkCtx, "val_address")
_, err = acc.UnbondEntries.Get(sdkCtx, valAddress)
require.Error(t, err)

delLocking, err = acc.DelegatedLocking.Get(ctx, "test")
Expand Down
14 changes: 7 additions & 7 deletions x/accounts/defaults/lockup/delayed_locking_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestDelayedAccountDelegate(t *testing.T) {
acc := setupDelayedAccount(t, sdkCtx, ss)
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -60,7 +60,7 @@ func TestDelayedAccountDelegate(t *testing.T) {

_, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(5)),
})
require.NoError(t, err)
Expand All @@ -84,7 +84,7 @@ func TestDelayedAccountUndelegate(t *testing.T) {
// Delegate first
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -96,21 +96,21 @@ func TestDelayedAccountUndelegate(t *testing.T) {
// Undelegate
_, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)

entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address")
entries, err := acc.UnbondEntries.Get(sdkCtx, valAddress)
require.NoError(t, err)
require.Len(t, entries.Entries, 1)
require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1)))
require.True(t, entries.Entries[0].ValidatorAddress == "val_address")
require.True(t, entries.Entries[0].ValidatorAddress == valAddress)

err = acc.checkUnbondingEntriesMature(sdkCtx)
require.NoError(t, err)

_, err = acc.UnbondEntries.Get(sdkCtx, "val_address")
_, err = acc.UnbondEntries.Get(sdkCtx, valAddress)
require.Error(t, err)

delLocking, err = acc.DelegatedLocking.Get(ctx, "test")
Expand Down
16 changes: 8 additions & 8 deletions x/accounts/defaults/lockup/periodic_locking_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestPeriodicAccountDelegate(t *testing.T) {
acc := setupPeriodicAccount(t, sdkCtx, ss)
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -74,7 +74,7 @@ func TestPeriodicAccountDelegate(t *testing.T) {

_, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(5)),
})
require.NoError(t, err)
Expand All @@ -94,7 +94,7 @@ func TestPeriodicAccountDelegate(t *testing.T) {

_, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(4)),
})
require.NoError(t, err)
Expand All @@ -118,7 +118,7 @@ func TestPeriodicAccountUndelegate(t *testing.T) {
// Delegate first
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -130,22 +130,22 @@ func TestPeriodicAccountUndelegate(t *testing.T) {
// Undelegate
_, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)

// sequence should be the previous one
entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address")
entries, err := acc.UnbondEntries.Get(sdkCtx, valAddress)
require.NoError(t, err)
require.Len(t, entries.Entries, 1)
require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1)))
require.True(t, entries.Entries[0].ValidatorAddress == "val_address")
require.True(t, entries.Entries[0].ValidatorAddress == valAddress)

err = acc.checkUnbondingEntriesMature(sdkCtx)
require.NoError(t, err)

_, err = acc.UnbondEntries.Get(sdkCtx, "val_address")
_, err = acc.UnbondEntries.Get(sdkCtx, valAddress)
require.Error(t, err)

delLocking, err = acc.DelegatedLocking.Get(ctx, "test")
Expand Down
12 changes: 6 additions & 6 deletions x/accounts/defaults/lockup/permanent_locking_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestPermanentAccountDelegate(t *testing.T) {
acc := setupPermanentAccount(t, sdkCtx, ss)
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -60,7 +60,7 @@ func TestPermanentAccountUndelegate(t *testing.T) {
// Delegate first
_, err := acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)
Expand All @@ -72,22 +72,22 @@ func TestPermanentAccountUndelegate(t *testing.T) {
// Undelegate
_, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{
Sender: "owner",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Amount: sdk.NewCoin("test", math.NewInt(1)),
})
require.NoError(t, err)

// sequence should be the previous one
entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address")
entries, err := acc.UnbondEntries.Get(sdkCtx, valAddress)
require.NoError(t, err)
require.Len(t, entries.Entries, 1)
require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1)))
require.True(t, entries.Entries[0].ValidatorAddress == "val_address")
require.True(t, entries.Entries[0].ValidatorAddress == valAddress)

err = acc.checkUnbondingEntriesMature(sdkCtx)
require.NoError(t, err)

_, err = acc.UnbondEntries.Get(sdkCtx, "val_address")
_, err = acc.UnbondEntries.Get(sdkCtx, valAddress)
require.Error(t, err)

delLocking, err = acc.DelegatedLocking.Get(ctx, "test")
Expand Down
2 changes: 1 addition & 1 deletion x/accounts/defaults/lockup/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) {
return &stakingtypes.QueryUnbondingDelegationResponse{
Unbond: stakingtypes.UnbondingDelegation{
DelegatorAddress: "sender",
ValidatorAddress: "val_address",
ValidatorAddress: valAddress,
Entries: []stakingtypes.UnbondingDelegationEntry{
{
CreationHeight: 1,
Expand Down

0 comments on commit 0506137

Please sign in to comment.