mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 19:51:20 +00:00
211d9bc0b9
* fix build from source * clean up * update again * change everything * workaround for now * fix versioning * all passing now * fix build issues * clean up * revert use of MulVerify * gaz * stub * Apply suggestions from code review Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * fix all * fix test * todo * fix stub * revert back * make deep source happy * Update shared/bls/herumi/public_key.go * Update shared/bls/blst/signature.go * Update shared/bls/blst/signature_test.go * imports * move iface to common, export errors * rm iface build Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package imported
|
|
|
|
import (
|
|
"context"
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestImportedKeymanager_ExtractKeystores(t *testing.T) {
|
|
secretKeysCache = make(map[[48]byte]bls.SecretKey)
|
|
lock.Lock()
|
|
dr := &Keymanager{}
|
|
validatingKeys := make([]bls.SecretKey, 10)
|
|
for i := 0; i < len(validatingKeys); i++ {
|
|
secretKey, err := bls.RandKey()
|
|
require.NoError(t, err)
|
|
validatingKeys[i] = secretKey
|
|
secretKeysCache[bytesutil.ToBytes48(secretKey.PublicKey().Marshal())] = secretKey
|
|
}
|
|
lock.Unlock()
|
|
ctx := context.Background()
|
|
password := "password"
|
|
|
|
// Extracting 0 public keys should return 0 keystores.
|
|
keystores, err := dr.ExtractKeystores(ctx, nil, password)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 0, len(keystores))
|
|
|
|
// We attempt to extract a few indices.
|
|
keystores, err = dr.ExtractKeystores(
|
|
ctx,
|
|
[]bls.PublicKey{
|
|
validatingKeys[3].PublicKey(),
|
|
validatingKeys[5].PublicKey(),
|
|
validatingKeys[7].PublicKey(),
|
|
},
|
|
password,
|
|
)
|
|
require.NoError(t, err)
|
|
receivedPubKeys := make([][]byte, len(keystores))
|
|
for i, k := range keystores {
|
|
pubKeyBytes, err := hex.DecodeString(k.Pubkey)
|
|
require.NoError(t, err)
|
|
receivedPubKeys[i] = pubKeyBytes
|
|
}
|
|
assert.DeepEqual(t, receivedPubKeys, [][]byte{
|
|
validatingKeys[3].PublicKey().Marshal(),
|
|
validatingKeys[5].PublicKey().Marshal(),
|
|
validatingKeys[7].PublicKey().Marshal(),
|
|
})
|
|
}
|