forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#2555: Don't acquire lock on read-only keybase
- Loading branch information
Showing
11 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,39 @@ | ||
package keys | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/crypto/keys" | ||
"github.com/stretchr/testify/require" | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestGetKeyBaseLocks(t *testing.T) { | ||
dir, err := ioutil.TempDir("", "cosmos-sdk-keys") | ||
require.Nil(t, err) | ||
defer os.RemoveAll(dir) | ||
|
||
// Acquire db | ||
kb, err := GetKeyBaseFromDirWithWritePerm(dir) | ||
require.Nil(t, err) | ||
_, _, err = kb.CreateMnemonic("foo", keys.English, "12345678", keys.Secp256k1) | ||
require.Nil(t, err) | ||
// Reset global variable | ||
keybase = nil | ||
// Try to acquire another keybase from the same storage | ||
_, err = GetKeyBaseFromDirWithWritePerm(dir) | ||
require.NotNil(t, err) | ||
_, err = GetKeyBaseFromDirWithWritePerm(dir) | ||
require.NotNil(t, err) | ||
|
||
// Close the db and try to acquire the lock | ||
kb.CloseDB() | ||
kb, err = GetKeyBaseFromDirWithWritePerm(dir) | ||
require.Nil(t, err) | ||
|
||
// Try to acquire another read-only keybase from the same storage | ||
_, err = GetKeyBaseFromDir(dir) | ||
require.Nil(t, err) | ||
|
||
kb.CloseDB() | ||
} |
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