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

@@ -8,7 +8,7 @@ import (
"time"
"github.com/gogo/protobuf/proto"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/internal"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"

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())
}

View File

@@ -318,12 +318,12 @@ func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) {
client.EXPECT().WaitForActivation(
gomock.Any(),
&pb.ValidatorActivationRequest{
PublicKeys: publicKeys(v.keys),
PublicKeys: v.pubkeys,
},
).Return(clientStream, nil)
clientStream.EXPECT().Recv().Return(
&pb.ValidatorActivationResponse{
ActivatedPublicKeys: publicKeys(v.keys),
ActivatedPublicKeys: v.pubkeys,
},
nil,
)