mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
1b5b8a57e0
* Update io_kubernetes_build commit hash to 1246899 * Update dependency build_bazel_rules_nodejs to v0.33.1 * Update dependency com_github_hashicorp_golang_lru to v0.5.1 * Update libp2p * Update io_bazel_rules_k8s commit hash to e68d5d7 * Starting to remove old protos * Bazel build proto passes * Fixing pb version * Cleaned up core package * Fixing tests * 6 tests failing * Update proto bugs * Fixed incorrect validator ordering proto * Sync with master * Update go-ssz commit * Removed bad copies from v1alpha1 folder * add json spec json to pb handler * add nested proto example * proto/testing test works * fix refactoring build failures * use merged ssz * push latest changes * used forked json encoding * used forked json encoding * fix warning * fix build issues * fix test and lint * fix build * lint
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package keystore_test
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-ssz"
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/shared/keystore"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
func TestDepositInput_GeneratesPb(t *testing.T) {
|
|
k1, err := keystore.NewKey(rand.Reader)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
k2, err := keystore.NewKey(rand.Reader)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
result, err := keystore.DepositInput(k1, k2, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !bytes.Equal(result.PublicKey, k1.PublicKey.Marshal()) {
|
|
t.Errorf("Mismatched pubkeys in deposit input. Want = %x, got = %x", result.PublicKey, k1.PublicKey.Marshal())
|
|
}
|
|
|
|
sig, err := bls.SignatureFromBytes(result.Signature)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
sr, err := ssz.SigningRoot(result)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
dom := bytesutil.FromBytes4(params.BeaconConfig().DomainDeposit)
|
|
if !sig.Verify(sr[:], k1.PublicKey, dom) {
|
|
t.Error("Invalid proof of deposit input signature")
|
|
}
|
|
}
|