-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(x/auth): Fix system test (#20531)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
05ff7a7
commit 021ab6d
Showing
13 changed files
with
154 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package simapp | ||
|
||
import ( | ||
"testing" | ||
|
||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" | ||
"github.com/stretchr/testify/require" | ||
|
||
"cosmossdk.io/collections" | ||
authkeeper "cosmossdk.io/x/auth/keeper" | ||
authtypes "cosmossdk.io/x/auth/types" | ||
) | ||
|
||
// TestSyncAccountNumber tests if accounts module account number is set correctly with the value get from auth. | ||
// Also check if the store entry for auth GlobalAccountNumberKey is successfully deleted. | ||
func TestSyncAccountNumber(t *testing.T) { | ||
app := Setup(t, true) | ||
ctx := app.NewUncachedContext(true, cmtproto.Header{}) | ||
|
||
bytesKey := authtypes.GlobalAccountNumberKey | ||
store := app.AuthKeeper.KVStoreService.OpenKVStore(ctx) | ||
|
||
// initially there is no value set yet | ||
v, err := store.Get(bytesKey) | ||
require.NoError(t, err) | ||
require.Nil(t, v) | ||
|
||
// set value for legacy account number | ||
v, err = collections.Uint64Value.Encode(10) | ||
require.NoError(t, err) | ||
err = store.Set(bytesKey, v) | ||
require.NoError(t, err) | ||
|
||
// make sure value are updated | ||
v, err = store.Get(bytesKey) | ||
require.NoError(t, err) | ||
require.NotEmpty(t, v) | ||
num, err := collections.Uint64Value.Decode(v) | ||
require.NoError(t, err) | ||
require.Equal(t, uint64(10), num) | ||
|
||
err = authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper) | ||
require.NoError(t, err) | ||
|
||
// make sure the DB entry for this key is deleted | ||
v, err = store.Get(bytesKey) | ||
require.NoError(t, err) | ||
require.Nil(t, v) | ||
|
||
// check if accounts's account number is updated | ||
currentNum, err := app.AccountsKeeper.AccountNumber.Peek(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, uint64(10), currentNum) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters