-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve composite key Bytes/FromBytes and make tools (#335)
* bls * composite * abci * fix TestBroadcastEvidence_DuplicateVoteEvidence, see tendermint/tendermint#6678 * (fix) Add comments * (fix) Use `os.UserHomeDir` and `filepath.Join`
- Loading branch information
Showing
16 changed files
with
637 additions
and
264 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package kvstore | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/line/ostracon/privval" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLoadPrivValidatorKeyFile(t *testing.T) { | ||
tempKeyFile, err := ioutil.TempFile("", "priv_validator_key_") | ||
require.Nil(t, err) | ||
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_") | ||
require.Nil(t, err) | ||
|
||
{ | ||
// does not exist | ||
_, err := LoadPrivValidatorKeyFile("DOES_NOT_EXIST") | ||
require.NotNil(t, err) | ||
require.Contains(t, err.Error(), "does not exist") | ||
} | ||
|
||
{ | ||
// error reading since empty | ||
_, err := LoadPrivValidatorKeyFile(tempKeyFile.Name()) | ||
require.NotNil(t, err) | ||
require.Contains(t, err.Error(), "error reading") | ||
} | ||
|
||
expected, err := privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), privval.PrivKeyTypeEd25519) | ||
require.Nil(t, err) | ||
|
||
expected.Save() | ||
|
||
// success | ||
actual, err := LoadPrivValidatorKeyFile(tempKeyFile.Name()) | ||
require.Nil(t, err) | ||
assert.Equal(t, expected.Key.Address, actual.Address) | ||
assert.Equal(t, expected.Key.PrivKey, actual.PrivKey) | ||
assert.Equal(t, expected.Key.PubKey, actual.PubKey) | ||
} |
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.