mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
0d400faea2
* Remove unused parameters * Remove unused deposit contract config
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package keystore_test
|
|
|
|
import (
|
|
"bytes"
|
|
"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()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
k2, err := keystore.NewKey()
|
|
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")
|
|
}
|
|
}
|