-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed panic in NewUser when public key is nil
- Loading branch information
1 parent
bf681d4
commit a9b6dd4
Showing
2 changed files
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package users | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/tendermint/tendermint/crypto/ed25519" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_NewUserEmptyPublicKey(t *testing.T) { | ||
// Check that NewUser don't panick by checking that recover() result is nil | ||
defer func() { | ||
assert.Nil(t, recover()) | ||
}() | ||
key := ed25519.GenPrivKey() | ||
pub := key.PubKey() | ||
addr := sdk.AccAddress(pub.Address()) | ||
acc := auth.ProtoBaseAccount() | ||
acc.SetAddress(addr) | ||
user := NewUser(acc) | ||
assert.Nil(t, user.Pubkey) | ||
} |