mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
9d979de4ed
* implementation using petname and keystore * writing new account to disk along with password * more logic for properly writing accounts * print out mnemonic * save deposit data rlp * write deposit tx and ssz deposit data to account path * wrap up account creation * fix prompt * generate deposit tx * direct account creation test * fix up formatting * lint * match formatting * more sustainable approach towards unmarshaling config file * resolve feedback * fix broken import * comprehensive tests for create account * tests pass * Merge branch 'master' into direct-keys * tidy * Merge branch 'direct-keys' of github.com:prysmaticlabs/prysm into direct-keys * Merge refs/heads/master into direct-keys * gaz * Merge branch 'direct-keys' of github.com:prysmaticlabs/prysm into direct-keys * nondeterministic names * comment * gaz * better error wrap * Merge refs/heads/master into direct-keys * docker deps * Merge branch 'direct-keys' of github.com:prysmaticlabs/prysm into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * Merge refs/heads/master into direct-keys * ivan feedback * Merge refs/heads/master into direct-keys * Update validator/accounts/v2/wallet.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * fixed tests and comments * Merge refs/heads/master into direct-keys
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package depositutil_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-ssz"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/depositutil"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
func TestDepositInput_GeneratesPb(t *testing.T) {
|
|
k1 := bls.RandKey()
|
|
k2 := bls.RandKey()
|
|
|
|
result, _, err := depositutil.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)
|
|
}
|
|
domain, err := helpers.ComputeDomain(
|
|
params.BeaconConfig().DomainDeposit,
|
|
nil, /*forkVersion*/
|
|
nil, /*genesisValidatorsRoot*/
|
|
)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
root, err := ssz.HashTreeRoot(&pb.SigningData{ObjectRoot: sr[:], Domain: domain[:]})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !sig.Verify(k1.PublicKey(), root[:]) {
|
|
t.Error("Invalid proof of deposit input signature")
|
|
}
|
|
}
|