From 0506137a3e0e116bef21a73f97ad782b591b08f0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 19 Dec 2024 18:14:50 +0100 Subject: [PATCH] linting --- .../lockup/continuous_locking_account_test.go | 16 +++++++++------- .../lockup/delayed_locking_account_test.go | 14 +++++++------- .../lockup/periodic_locking_account_test.go | 16 ++++++++-------- .../lockup/permanent_locking_account_test.go | 12 ++++++------ x/accounts/defaults/lockup/utils_test.go | 2 +- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/x/accounts/defaults/lockup/continuous_locking_account_test.go b/x/accounts/defaults/lockup/continuous_locking_account_test.go index 097c335db57d..734755a2b7cc 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account_test.go +++ b/x/accounts/defaults/lockup/continuous_locking_account_test.go @@ -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) @@ -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) @@ -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) @@ -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) @@ -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") diff --git a/x/accounts/defaults/lockup/delayed_locking_account_test.go b/x/accounts/defaults/lockup/delayed_locking_account_test.go index dc3235c7a6ba..d94e4d33840a 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account_test.go +++ b/x/accounts/defaults/lockup/delayed_locking_account_test.go @@ -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) @@ -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) @@ -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) @@ -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") diff --git a/x/accounts/defaults/lockup/periodic_locking_account_test.go b/x/accounts/defaults/lockup/periodic_locking_account_test.go index bff11684e7f3..c58fedc4a22e 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account_test.go +++ b/x/accounts/defaults/lockup/periodic_locking_account_test.go @@ -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) @@ -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) @@ -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) @@ -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) @@ -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") diff --git a/x/accounts/defaults/lockup/permanent_locking_account_test.go b/x/accounts/defaults/lockup/permanent_locking_account_test.go index 224bfbb83e0a..b1615f7b321a 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account_test.go +++ b/x/accounts/defaults/lockup/permanent_locking_account_test.go @@ -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) @@ -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) @@ -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") diff --git a/x/accounts/defaults/lockup/utils_test.go b/x/accounts/defaults/lockup/utils_test.go index 18a8672467f5..1059361c80b7 100644 --- a/x/accounts/defaults/lockup/utils_test.go +++ b/x/accounts/defaults/lockup/utils_test.go @@ -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,