clean up test (#2309)

This commit is contained in:
Nishant Das
2019-04-20 19:24:40 +08:00
committed by GitHub
parent 1602c5d0c5
commit 1f4890adde
3 changed files with 16 additions and 11 deletions

View File

@@ -21,19 +21,24 @@ var validatorKey *keystore.Key
var keyMap map[string]*keystore.Key
var keyMapThreeValidators map[string]*keystore.Key
func TestMain(m *testing.M) {
func keySetup() {
keyMap = make(map[string]*keystore.Key)
keyMapThreeValidators = make(map[string]*keystore.Key)
validatorKey, _ = keystore.NewKey(rand.Reader)
keyMap[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey
for i := 0; i < 3; i++ {
vKey, _ := keystore.NewKey(rand.Reader)
keyMapThreeValidators[hex.EncodeToString(vKey.PublicKey.Marshal())] = vKey
}
}
func TestMain(m *testing.M) {
dir := testutil.TempDir() + "/keystore1"
defer os.RemoveAll(dir)
accounts.NewValidatorAccount(dir, "1234")
validatorKey, _ = keystore.NewKey(rand.Reader)
keyMap[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey
keyMapThreeValidators[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey
validatorKey2, _ := keystore.NewKey(rand.Reader)
keyMapThreeValidators[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey2
validatorKey3, _ := keystore.NewKey(rand.Reader)
keyMapThreeValidators[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey3
keySetup()
os.Exit(m.Run())
}