Skip to content

Commit

Permalink
move deposit data file to testutils
Browse files Browse the repository at this point in the history
  • Loading branch information
GalRogozinski committed Jul 4, 2024
1 parent 610d136 commit 31b0064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion types/spectest/tests/beacon/deposit_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package beacon
import (
"encoding/hex"
"github.com/ssvlabs/ssv-spec/types"
"github.com/ssvlabs/ssv-spec/types/testingutils"
comparable2 "github.com/ssvlabs/ssv-spec/types/testingutils/comparable"
"github.com/stretchr/testify/require"
"reflect"
Expand All @@ -25,7 +26,7 @@ func (test *DepositDataSpecTest) Run(t *testing.T) {
validatorPK, _ := hex.DecodeString(test.ValidatorPK)
withdrawalCredentials, _ := hex.DecodeString(test.WithdrawalCredentials)

r, _, err := types.GenerateETHDepositData(
r, _, err := testingutils.GenerateETHDepositData(
validatorPK,
withdrawalCredentials,
test.ForkVersion,
Expand Down
11 changes: 6 additions & 5 deletions types/eth1_deposit.go → types/testingutils/eth1_deposit.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package types
package testingutils

import (
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/ssvlabs/ssv-spec/types"
)

// GenerateETHDepositData returns un-signed deposit data and deposit data root for signature
Expand All @@ -16,20 +17,20 @@ func GenerateETHDepositData(
ret := &phase0.DepositMessage{
PublicKey: pk,
WithdrawalCredentials: withdrawalCredentials,
Amount: phase0.Gwei(MaxEffectiveBalanceInGwei),
Amount: phase0.Gwei(types.MaxEffectiveBalanceInGwei),
}

domainR, err := ComputeETHDomain(domain, fork, GenesisValidatorsRoot)
domainR, err := types.ComputeETHDomain(domain, fork, types.GenesisValidatorsRoot)
if err != nil {
return nil, nil, errors.Wrap(err, "could not compute deposit domain")
}
signingRoot, err := ComputeETHSigningRoot(ret, domainR)
signingRoot, err := types.ComputeETHSigningRoot(ret, domainR)
if err != nil {
return nil, nil, errors.Wrap(err, "could not compute deposit signing root")
}
return signingRoot[:], &phase0.DepositData{
PublicKey: pk,
WithdrawalCredentials: withdrawalCredentials,
Amount: phase0.Gwei(MaxEffectiveBalanceInGwei),
Amount: phase0.Gwei(types.MaxEffectiveBalanceInGwei),
}, nil
}

0 comments on commit 31b0064

Please sign in to comment.