mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Fix validator export failing when validator.db is in nested directory (#15351)
* files changed * added changelog file * added tests and formatting changes * fixed bugs * fixed formatting
This commit is contained in:
@@ -81,7 +81,7 @@ func setup(t *testing.T, isSlashingProtectionMinimal bool) (*validator, *mocks,
|
||||
func setupWithKey(t *testing.T, validatorKey bls.SecretKey, isSlashingProtectionMinimal bool) (*validator, *mocks, bls.SecretKey, func()) {
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
valDB := testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||
valDB := testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||
ctrl := gomock.NewController(t)
|
||||
m := &mocks{
|
||||
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
||||
@@ -1105,7 +1105,7 @@ func TestGetGraffitiOrdered_Ok(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
pubKey := [fieldparams.BLSPubkeyLength]byte{'a'}
|
||||
valDB := testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||
valDB := testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||
ctrl := gomock.NewController(t)
|
||||
m := &mocks{
|
||||
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
||||
@@ -1188,7 +1188,7 @@ func Test_validator_DeleteGraffiti(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v := &validator{
|
||||
db: testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
proposerSettings: tt.proposerSettings,
|
||||
}
|
||||
err := v.DeleteGraffiti(context.Background(), pubKey)
|
||||
@@ -1268,7 +1268,7 @@ func Test_validator_SetGraffiti(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v := &validator{
|
||||
db: testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
proposerSettings: tt.proposerSettings,
|
||||
}
|
||||
err := v.SetGraffiti(context.Background(), pubKey, []byte(tt.graffiti))
|
||||
|
||||
@@ -165,7 +165,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
v := validator{
|
||||
validatorClient: client,
|
||||
db: db,
|
||||
@@ -215,7 +215,7 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
v := validator{
|
||||
validatorClient: client,
|
||||
db: db,
|
||||
@@ -925,7 +925,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
for _, k := range keys {
|
||||
pkey := k
|
||||
@@ -959,7 +959,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||
for i, k := range keys {
|
||||
@@ -1000,7 +1000,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||
for i, k := range keys {
|
||||
@@ -1039,7 +1039,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||
attLimit := 5
|
||||
@@ -1085,7 +1085,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
km := genMockKeymanager(t, 1)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
for _, k := range keys {
|
||||
@@ -1123,7 +1123,7 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
|
||||
k := keys[0]
|
||||
att := createAttestation(10, 14)
|
||||
@@ -1303,7 +1303,7 @@ func TestValidator_WaitForKeymanagerInitialization_web3Signer(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||
@@ -1336,7 +1336,7 @@ func TestValidator_WaitForKeymanagerInitialization_Web(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||
@@ -1370,7 +1370,7 @@ func TestValidator_WaitForKeymanagerInitialization_Interop(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||
@@ -1430,7 +1430,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
ctrl := gomock.NewController(t)
|
||||
ctx := context.Background()
|
||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
defaultFeeHex := "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9"
|
||||
|
||||
Reference in New Issue
Block a user