prysm-pulse/shared/keystore/deposit_input_test.go
Ivan Martinez 0d400faea2 Remove unused parameters and unused code (#4452)
* Remove unused parameters
* Remove unused deposit contract config
2020-01-07 23:45:29 +00:00

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