-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(simapp): Audit simapp #21311
Merged
Merged
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4aac90e
update comments
hieuvubk 30d72a3
consensustypes
hieuvubk 45d4e67
handle err
hieuvubk c907e8a
add epochs for v2
hieuvubk 06ea466
clean up
hieuvubk f250a18
go mod & tests
hieuvubk 42d7553
merge main
hieuvubk fe63167
Merge branch 'main' into hieu/simapp-audit
hieuvubk 819afd2
Merge branch 'main' into hieu/simapp-audit
hieuvubk 98f70e9
revert WithdrawDelegationRewards err handle
hieuvubk 08ebc82
Merge branch 'hieu/simapp-audit' of https://github.com/cosmos/cosmos-…
hieuvubk ab373f2
read app toml config from viper
hieuvubk 23c480e
update simapp-v2-smoke-test
hieuvubk acb8140
Merge branch 'main' into hieu/simapp-audit
hieuvubk adcda83
Merge branch 'main' into hieu/simapp-audit
hieuvubk 18f424e
Merge branch 'main' into hieu/simapp-audit
hieuvubk f201230
reverted
hieuvubk 24d83ba
comet queries not relay on CometBFTServer
hieuvubk 3bd4f72
Merge branch 'hieu/simapp-audit' of https://github.com/cosmos/cosmos-…
hieuvubk e3a98f3
no need app.toml config read
hieuvubk 55701f6
Merge branch 'main' into hieu/simapp-audit
hieuvubk 404241b
Merge branch 'main' into hieu/simapp-audit
hieuvubk f76c488
Merge branch 'main' into hieu/simapp-audit
hieuvubk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,89 @@ | ||
package simapp_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/cometbft/cometbft/crypto" | ||
"github.com/stretchr/testify/require" | ||
|
||
"cosmossdk.io/simapp/v2" | ||
authtypes "cosmossdk.io/x/auth/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func TestSimGenesisAccountValidate(t *testing.T) { | ||
pubkey := secp256k1.GenPrivKey().PubKey() | ||
addr := sdk.AccAddress(pubkey.Address()) | ||
|
||
vestingStart := time.Now().UTC() | ||
|
||
coins := sdk.NewCoins(sdk.NewInt64Coin("test", 1000)) | ||
baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) | ||
|
||
testCases := []struct { | ||
name string | ||
sga simapp.SimGenesisAccount | ||
wantErr bool | ||
}{ | ||
{ | ||
"valid basic account", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: baseAcc, | ||
}, | ||
false, | ||
}, | ||
{ | ||
"invalid basic account with mismatching address/pubkey", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), | ||
}, | ||
true, | ||
}, | ||
{ | ||
"valid basic account with module name", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0, 0), | ||
ModuleName: "testmod", | ||
}, | ||
false, | ||
}, | ||
{ | ||
"valid basic account with invalid module name/pubkey pair", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: baseAcc, | ||
ModuleName: "testmod", | ||
}, | ||
true, | ||
}, | ||
{ | ||
"valid basic account with valid vesting attributes", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: baseAcc, | ||
OriginalVesting: coins, | ||
StartTime: vestingStart.Unix(), | ||
EndTime: vestingStart.Add(1 * time.Hour).Unix(), | ||
}, | ||
false, | ||
}, | ||
{ | ||
"valid basic account with invalid vesting end time", | ||
simapp.SimGenesisAccount{ | ||
BaseAccount: baseAcc, | ||
OriginalVesting: coins, | ||
StartTime: vestingStart.Add(2 * time.Hour).Unix(), | ||
EndTime: vestingStart.Add(1 * time.Hour).Unix(), | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
t.Run(tc.name, func(t *testing.T) { | ||
require.Equal(t, tc.wantErr, tc.sga.Validate() != nil) | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should check the error, it fails tests when a validator has no commission.
Could you revert?