mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Replace context.Background with testing.TB.Context where possible (#15416)
* Replace context.Background with testing.TB.Context where possible * Fix failing tests
This commit is contained in:
@@ -2,7 +2,6 @@ package accounts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
// import keys
|
||||
numAccounts := 5
|
||||
keystores := make([]*keymanager.Keystore, numAccounts)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -46,7 +45,7 @@ func TestImportAccounts_NoPassword(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
importer, ok := km.(keymanager.Importer)
|
||||
require.Equal(t, true, ok)
|
||||
resp, err := ImportAccounts(context.Background(), &ImportAccountsConfig{
|
||||
resp, err := ImportAccounts(t.Context(), &ImportAccountsConfig{
|
||||
Keystores: []*keymanager.Keystore{{}},
|
||||
Importer: importer,
|
||||
AccountPassword: "",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package wallet_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"io"
|
||||
"os"
|
||||
@@ -66,7 +65,7 @@ func TestWallet_InitializeKeymanager_web3Signer_HappyPath(t *testing.T) {
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
set.String(flags.WalletDirFlag.Name, newDir, "")
|
||||
w := wallet.NewWalletForWeb3Signer(cli.NewContext(&app, set, nil))
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
require.NoError(t, err)
|
||||
config := iface.InitKeymanagerConfig{
|
||||
@@ -87,7 +86,7 @@ func TestWallet_InitializeKeymanager_web3Signer_nilConfig(t *testing.T) {
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
set.String(flags.WalletDirFlag.Name, newDir, "")
|
||||
w := wallet.NewWalletForWeb3Signer(cli.NewContext(&app, set, nil))
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
config := iface.InitKeymanagerConfig{
|
||||
ListenForChanges: false,
|
||||
Web3SignerConfig: nil,
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestSubmitAggregateAndProof_GetDutiesRequestFailure(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitAggregateAndProof(context.Background(), 0, pubKey)
|
||||
validator.SubmitAggregateAndProof(t.Context(), 0, pubKey)
|
||||
|
||||
require.LogsContain(t, hook, "Could not fetch validator assignment")
|
||||
})
|
||||
@@ -79,7 +79,7 @@ func TestSubmitAggregateAndProof_SignFails(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: nil}, errors.New("bad domain root"))
|
||||
|
||||
validator.SubmitAggregateAndProof(context.Background(), 0, pubKey)
|
||||
validator.SubmitAggregateAndProof(t.Context(), 0, pubKey)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.SignedAggregateSubmitRequest{}),
|
||||
).Return(ðpb.SignedAggregateSubmitResponse{AttestationDataRoot: make([]byte, 32)}, nil)
|
||||
|
||||
validator.SubmitAggregateAndProof(context.Background(), 0, pubKey)
|
||||
validator.SubmitAggregateAndProof(t.Context(), 0, pubKey)
|
||||
})
|
||||
}
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
@@ -182,7 +182,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.SignedAggregateSubmitElectraRequest{}),
|
||||
).Return(ðpb.SignedAggregateSubmitResponse{AttestationDataRoot: make([]byte, 32)}, nil)
|
||||
|
||||
validator.SubmitAggregateAndProof(context.Background(), params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch), pubKey)
|
||||
validator.SubmitAggregateAndProof(t.Context(), params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch), pubKey)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
|
||||
func TestSubmitAggregateAndProof_Distributed(t *testing.T) {
|
||||
validatorIdx := primitives.ValidatorIndex(123)
|
||||
slot := primitives.Slot(456)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
validator, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
@@ -261,7 +261,7 @@ func TestWaitForSlotTwoThird_WaitCorrectly(t *testing.T) {
|
||||
timeToSleep := oneThird + oneThird
|
||||
|
||||
twoThirdTime := currentTime.Add(timeToSleep)
|
||||
validator.waitToSlotTwoThirds(context.Background(), numOfSlots)
|
||||
validator.waitToSlotTwoThirds(t.Context(), numOfSlots)
|
||||
currentTime = time.Now()
|
||||
assert.Equal(t, twoThirdTime.Unix(), currentTime.Unix())
|
||||
})
|
||||
@@ -278,7 +278,7 @@ func TestWaitForSlotTwoThird_DoneContext_ReturnsImmediately(t *testing.T) {
|
||||
validator.genesisTime = uint64(currentTime.Unix()) - uint64(numOfSlots.Mul(params.BeaconConfig().SecondsPerSlot))
|
||||
|
||||
expectedTime := time.Now()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
cancel()
|
||||
validator.waitToSlotTwoThirds(ctx, numOfSlots)
|
||||
currentTime = time.Now()
|
||||
@@ -307,7 +307,7 @@ func TestAggregateAndProofSignature_CanSignValidSignature(t *testing.T) {
|
||||
}),
|
||||
SelectionProof: make([]byte, 96),
|
||||
}
|
||||
sig, err := validator.aggregateAndProofSig(context.Background(), pubKey, agg, 0 /* slot */)
|
||||
sig, err := validator.aggregateAndProofSig(t.Context(), pubKey, agg, 0 /* slot */)
|
||||
require.NoError(t, err)
|
||||
_, err = bls.SignatureFromBytes(sig)
|
||||
require.NoError(t, err)
|
||||
@@ -338,7 +338,7 @@ func TestAggregateAndProofSignature_CanSignValidSignature(t *testing.T) {
|
||||
}),
|
||||
SelectionProof: make([]byte, 96),
|
||||
}
|
||||
sig, err := validator.aggregateAndProofSig(context.Background(), pubKey, agg, params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch) /* slot */)
|
||||
sig, err := validator.aggregateAndProofSig(t.Context(), pubKey, agg, params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch) /* slot */)
|
||||
require.NoError(t, err)
|
||||
_, err = bls.SignatureFromBytes(sig)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestRequestAttestation_ValidatorDutiesRequestFailure(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsContain(t, hook, "Could not fetch validator assignment")
|
||||
})
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func TestAttestToBlockHead_SubmitAttestation_EmptyCommittee(t *testing.T) {
|
||||
CommitteeIndex: 0,
|
||||
ValidatorIndex: 0,
|
||||
}}}
|
||||
validator.SubmitAttestation(context.Background(), 0, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 0, pubKey)
|
||||
require.LogsContain(t, hook, "Empty committee")
|
||||
})
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func TestAttestToBlockHead_SubmitAttestation_RequestFailure(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsContain(t, hook, "Could not submit attestation to beacon node")
|
||||
})
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
|
||||
generatedAttestation = att
|
||||
}).Return(ðpb.AttestResponse{}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
|
||||
aggregationBitfield := bitfield.NewBitlist(uint64(len(committee)))
|
||||
aggregationBitfield.SetBitAt(4, true)
|
||||
@@ -167,7 +167,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
|
||||
root, err := signing.ComputeSigningRoot(expectedAttestation.Data, make([]byte, 32))
|
||||
require.NoError(t, err)
|
||||
|
||||
sig, err := validator.km.Sign(context.Background(), &validatorpb.SignRequest{
|
||||
sig, err := validator.km.Sign(t.Context(), &validatorpb.SignRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
SigningRoot: root[:],
|
||||
})
|
||||
@@ -230,7 +230,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
|
||||
generatedAttestation = att
|
||||
}).Return(ðpb.AttestResponse{}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch), pubKey)
|
||||
validator.SubmitAttestation(t.Context(), params.BeaconConfig().SlotsPerEpoch.Mul(electraForkEpoch), pubKey)
|
||||
|
||||
aggregationBitfield := bitfield.NewBitlist(uint64(len(committee)))
|
||||
aggregationBitfield.SetBitAt(4, true)
|
||||
@@ -250,7 +250,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
|
||||
root, err := signing.ComputeSigningRoot(expectedAttestation.Data, make([]byte, 32))
|
||||
require.NoError(t, err)
|
||||
|
||||
sig, err := validator.km.Sign(context.Background(), &validatorpb.SignRequest{
|
||||
sig, err := validator.km.Sign(t.Context(), &validatorpb.SignRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
SigningRoot: root[:],
|
||||
})
|
||||
@@ -315,8 +315,8 @@ func TestAttestToBlockHead_BlocksDoubleAtt(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.Attestation{}),
|
||||
).Return(ðpb.AttestResponse{AttestationDataRoot: make([]byte, 32)}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsContain(t, hook, "Failed attestation slashing protection")
|
||||
})
|
||||
}
|
||||
@@ -371,8 +371,8 @@ func TestAttestToBlockHead_BlocksSurroundAtt(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.Attestation{}),
|
||||
).Return(ðpb.AttestResponse{}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsContain(t, hook, "Failed attestation slashing protection")
|
||||
})
|
||||
}
|
||||
@@ -419,7 +419,7 @@ func TestAttestToBlockHead_BlocksSurroundedAtt(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.Attestation{}),
|
||||
).Return(ðpb.AttestResponse{}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsDoNotContain(t, hook, failedAttLocalProtectionErr)
|
||||
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
@@ -431,7 +431,7 @@ func TestAttestToBlockHead_BlocksSurroundedAtt(t *testing.T) {
|
||||
Source: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte("C"), 32), Epoch: 1},
|
||||
}, nil)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
require.LogsContain(t, hook, "Failed attestation slashing protection")
|
||||
})
|
||||
}
|
||||
@@ -462,7 +462,7 @@ func TestAttestToBlockHead_DoesNotAttestBeforeDelay(t *testing.T) {
|
||||
).Return(ðpb.AttestResponse{}, nil /* error */).Times(0)
|
||||
|
||||
timer := time.NewTimer(1 * time.Second)
|
||||
go validator.SubmitAttestation(context.Background(), 0, pubKey)
|
||||
go validator.SubmitAttestation(t.Context(), 0, pubKey)
|
||||
<-timer.C
|
||||
})
|
||||
}
|
||||
@@ -512,7 +512,7 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) {
|
||||
gomock.Any(),
|
||||
).Return(ðpb.AttestResponse{}, nil).Times(1)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 0, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 0, pubKey)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,7 @@ func TestAttestToBlockHead_CorrectBitfieldLength(t *testing.T) {
|
||||
generatedAttestation = att
|
||||
}).Return(ðpb.AttestResponse{}, nil /* error */)
|
||||
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
validator.SubmitAttestation(t.Context(), 30, pubKey)
|
||||
|
||||
assert.Equal(t, 2, len(generatedAttestation.AggregationBits))
|
||||
})
|
||||
@@ -579,7 +579,7 @@ func TestSignAttestation(t *testing.T) {
|
||||
m.validatorClient.EXPECT().
|
||||
DomainData(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.DomainResponse{SignatureDomain: attesterDomain}, nil)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
att := util.NewAttestation()
|
||||
att.Data.Source.Epoch = 100
|
||||
att.Data.Target.Epoch = 200
|
||||
@@ -614,7 +614,7 @@ func TestServer_WaitToSlotOneThird_CanWait(t *testing.T) {
|
||||
|
||||
timeToSleep := params.BeaconConfig().SecondsPerSlot / 3
|
||||
oneThird := currentTime + timeToSleep
|
||||
v.waitOneThirdOrValidBlock(context.Background(), currentSlot)
|
||||
v.waitOneThirdOrValidBlock(t.Context(), currentSlot)
|
||||
|
||||
if oneThird != uint64(time.Now().Unix()) {
|
||||
t.Errorf("Wanted %d time for slot one third but got %d", oneThird, currentTime)
|
||||
@@ -632,7 +632,7 @@ func TestServer_WaitToSlotOneThird_SameReqSlot(t *testing.T) {
|
||||
highestValidSlot: currentSlot,
|
||||
}
|
||||
|
||||
v.waitOneThirdOrValidBlock(context.Background(), currentSlot)
|
||||
v.waitOneThirdOrValidBlock(t.Context(), currentSlot)
|
||||
|
||||
if currentTime != uint64(time.Now().Unix()) {
|
||||
t.Errorf("Wanted %d time for slot one third but got %d", uint64(time.Now().Unix()), currentTime)
|
||||
@@ -660,7 +660,7 @@ func TestServer_WaitToSlotOneThird_ReceiveBlockSlot(t *testing.T) {
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
v.waitOneThirdOrValidBlock(context.Background(), currentSlot)
|
||||
v.waitOneThirdOrValidBlock(t.Context(), currentSlot)
|
||||
|
||||
if currentTime != uint64(time.Now().Unix()) {
|
||||
t.Errorf("Wanted %d time for slot one third but got %d", uint64(time.Now().Unix()), currentTime)
|
||||
@@ -691,7 +691,7 @@ func Test_slashableAttestationCheck(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := validator.db.SlashableAttestationCheck(context.Background(), att, pubKey, [32]byte{1}, false, nil)
|
||||
err := validator.db.SlashableAttestationCheck(t.Context(), att, pubKey, [32]byte{1}, false, nil)
|
||||
require.NoError(t, err, "Expected allowed attestation not to throw error")
|
||||
})
|
||||
}
|
||||
@@ -702,7 +702,7 @@ func Test_slashableAttestationCheck_UpdatesLowestSignedEpochs(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
validator, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
att := ðpb.IndexedAttestation{
|
||||
@@ -729,18 +729,18 @@ func Test_slashableAttestationCheck_UpdatesLowestSignedEpochs(t *testing.T) {
|
||||
_, sr, err := validator.domainAndSigningRoot(ctx, att.Data)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = validator.db.SlashableAttestationCheck(context.Background(), att, pubKey, sr, false, nil)
|
||||
err = validator.db.SlashableAttestationCheck(t.Context(), att, pubKey, sr, false, nil)
|
||||
require.NoError(t, err)
|
||||
differentSigningRoot := [32]byte{2}
|
||||
|
||||
err = validator.db.SlashableAttestationCheck(context.Background(), att, pubKey, differentSigningRoot, false, nil)
|
||||
err = validator.db.SlashableAttestationCheck(t.Context(), att, pubKey, differentSigningRoot, false, nil)
|
||||
require.ErrorContains(t, "could not sign attestation", err)
|
||||
|
||||
e, exists, err := validator.db.LowestSignedSourceEpoch(context.Background(), pubKey)
|
||||
e, exists, err := validator.db.LowestSignedSourceEpoch(t.Context(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, primitives.Epoch(4), e)
|
||||
e, exists, err = validator.db.LowestSignedTargetEpoch(context.Background(), pubKey)
|
||||
e, exists, err = validator.db.LowestSignedTargetEpoch(t.Context(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, primitives.Epoch(10), e)
|
||||
@@ -751,7 +751,7 @@ func Test_slashableAttestationCheck_UpdatesLowestSignedEpochs(t *testing.T) {
|
||||
func Test_slashableAttestationCheck_OK(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validator, _, _, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
att := ðpb.IndexedAttestation{
|
||||
@@ -782,7 +782,7 @@ func Test_slashableAttestationCheck_OK(t *testing.T) {
|
||||
func Test_slashableAttestationCheck_GenesisEpoch(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validator, _, _, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
att := ðpb.IndexedAttestation{
|
||||
@@ -805,11 +805,11 @@ func Test_slashableAttestationCheck_GenesisEpoch(t *testing.T) {
|
||||
fakePubkey := bytesutil.ToBytes48([]byte("test"))
|
||||
err := validator.db.SlashableAttestationCheck(ctx, att, fakePubkey, [32]byte{}, false, nil)
|
||||
require.NoError(t, err, "Expected allowed attestation not to throw error")
|
||||
e, exists, err := validator.db.LowestSignedSourceEpoch(context.Background(), fakePubkey)
|
||||
e, exists, err := validator.db.LowestSignedSourceEpoch(t.Context(), fakePubkey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, primitives.Epoch(0), e)
|
||||
e, exists, err = validator.db.LowestSignedTargetEpoch(context.Background(), fakePubkey)
|
||||
e, exists, err = validator.db.LowestSignedTargetEpoch(t.Context(), fakePubkey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, primitives.Epoch(0), e)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@@ -17,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetAttestationData_ValidAttestation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
expectedSlot := uint64(5)
|
||||
expectedCommitteeIndex := uint64(6)
|
||||
expectedBeaconBlockRoot := "0x0636045df9bdda3ab96592cf5389032c8ec3977f911e2b53509b348dfe164d4d"
|
||||
@@ -76,7 +75,7 @@ func TestGetAttestationData_ValidAttestation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAttestationData_InvalidData(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -204,7 +203,7 @@ func TestGetAttestationData_JsonResponseError(t *testing.T) {
|
||||
const slot = primitives.Slot(1)
|
||||
const committeeIndex = primitives.CommitteeIndex(2)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -26,7 +25,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("invalid token", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
beaconChainClient := beaconApiChainClient{}
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
@@ -38,7 +37,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("query filter epoch overflow", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
beaconChainClient := beaconApiChainClient{}
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
@@ -52,7 +51,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("fails to get validators for epoch filter", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -72,7 +71,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("fails to get validators for genesis filter", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -90,7 +89,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("fails to get validators for nil filter", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -108,7 +107,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run("fails to get latest block header for nil filter", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -181,7 +180,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -322,7 +321,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
@@ -550,7 +549,7 @@ func TestListValidators(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(gomock.Any(), primitives.Slot(0), make([]string, 0), []primitives.ValidatorIndex{}, nil).Return(
|
||||
@@ -738,7 +737,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
finalityCheckpointsResponse := structs.GetFinalityCheckpointsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -836,7 +835,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -866,7 +865,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
t.Run("returns a valid chain head", func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
@@ -31,7 +30,7 @@ func TestGetFork_Nominal(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -59,7 +58,7 @@ func TestGetFork_Invalid(t *testing.T) {
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -98,7 +97,7 @@ func TestGetHeaders_Nominal(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -126,7 +125,7 @@ func TestGetHeaders_Invalid(t *testing.T) {
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -169,7 +168,7 @@ func TestGetLiveness_Nominal(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -196,7 +195,7 @@ func TestGetLiveness_Invalid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -246,7 +245,7 @@ func TestGetIsSyncing_Nominal(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -277,7 +276,7 @@ func TestGetIsSyncing_Invalid(t *testing.T) {
|
||||
syncingResponseJson := structs.SyncStatusResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
@@ -109,7 +108,7 @@ func TestGetGenesis(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().Genesis(
|
||||
@@ -198,7 +197,7 @@ func TestGetSyncStatus(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
syncingResponse := structs.SyncStatusResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -262,7 +261,7 @@ func TestGetVersion(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var versionResponse structs.GetVersionResponse
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
@@ -26,7 +25,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
|
||||
@@ -45,7 +44,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataValid(t *testing.T) {
|
||||
expectedResp, expectedErr := validatorClient.attestationData(ctx, slot, committeeIndex)
|
||||
|
||||
resp, err := validatorClient.AttestationData(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
ðpb.AttestationDataRequest{Slot: slot, CommitteeIndex: committeeIndex},
|
||||
)
|
||||
|
||||
@@ -60,7 +59,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
|
||||
@@ -79,7 +78,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataError(t *testing.T) {
|
||||
expectedResp, expectedErr := validatorClient.attestationData(ctx, slot, committeeIndex)
|
||||
|
||||
resp, err := validatorClient.AttestationData(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
ðpb.AttestationDataRequest{Slot: slot, CommitteeIndex: committeeIndex},
|
||||
)
|
||||
|
||||
@@ -88,7 +87,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBeaconApiValidatorClient_GetFeeRecipientByPubKey(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorClient := beaconApiValidatorClient{}
|
||||
var expected *ethpb.FeeRecipientByPubKeyResponse = nil
|
||||
|
||||
@@ -105,7 +104,7 @@ func TestBeaconApiValidatorClient_DomainDataValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().Genesis(gomock.Any()).Return(
|
||||
@@ -114,7 +113,7 @@ func TestBeaconApiValidatorClient_DomainDataValid(t *testing.T) {
|
||||
).Times(2)
|
||||
|
||||
validatorClient := beaconApiValidatorClient{genesisProvider: genesisProvider}
|
||||
resp, err := validatorClient.DomainData(context.Background(), ðpb.DomainRequest{Epoch: epoch, Domain: domainType})
|
||||
resp, err := validatorClient.DomainData(t.Context(), ðpb.DomainRequest{Epoch: epoch, Domain: domainType})
|
||||
|
||||
domainTypeArray := bytesutil.ToBytes4(domainType)
|
||||
expectedResp, expectedErr := validatorClient.domainData(ctx, epoch, domainTypeArray)
|
||||
@@ -126,7 +125,7 @@ func TestBeaconApiValidatorClient_DomainDataError(t *testing.T) {
|
||||
epoch := params.BeaconConfig().AltairForkEpoch
|
||||
domainType := make([]byte, 3)
|
||||
validatorClient := beaconApiValidatorClient{}
|
||||
_, err := validatorClient.DomainData(context.Background(), ðpb.DomainRequest{Epoch: epoch, Domain: domainType})
|
||||
_, err := validatorClient.DomainData(t.Context(), ðpb.DomainRequest{Epoch: epoch, Domain: domainType})
|
||||
assert.ErrorContains(t, fmt.Sprintf("invalid domain type: %s", hexutil.Encode(domainType)), err)
|
||||
}
|
||||
|
||||
@@ -134,7 +133,7 @@ func TestBeaconApiValidatorClient_ProposeBeaconBlockValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -170,7 +169,7 @@ func TestBeaconApiValidatorClient_ProposeBeaconBlockError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -95,7 +94,7 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
reqBody, err := json.Marshal(test.req)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
gomock.Any(),
|
||||
"/eth/v1/validator/beacon_committee_selections",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
@@ -33,7 +32,7 @@ func TestGetDomainData_ValidDomainData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
@@ -62,7 +61,7 @@ func TestGetDomainData_GenesisError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
@@ -81,7 +80,7 @@ func TestGetDomainData_InvalidGenesisRoot(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -378,7 +377,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
|
||||
}
|
||||
|
||||
doppelGangerActualOutput, err := validatorClient.CheckDoppelGanger(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
testCase.doppelGangerInput,
|
||||
)
|
||||
|
||||
@@ -812,7 +811,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := validatorClient.CheckDoppelGanger(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
ðpb.DoppelGangerRequest{
|
||||
ValidatorRequests: testCase.inputValidatorRequests,
|
||||
},
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -58,7 +57,7 @@ func TestGetAttesterDuties_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
validatorIndices := []primitives.ValidatorIndex{2, 9}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -87,7 +86,7 @@ func TestGetAttesterDuties_HttpError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -111,7 +110,7 @@ func TestGetAttesterDuties_NilAttesterDuty(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -155,7 +154,7 @@ func TestGetProposerDuties_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -181,7 +180,7 @@ func TestGetProposerDuties_HttpError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -203,7 +202,7 @@ func TestGetProposerDuties_NilData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -230,7 +229,7 @@ func TestGetProposerDuties_NilProposerDuty(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -282,7 +281,7 @@ func TestGetSyncDuties_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
validatorIndices := []primitives.ValidatorIndex{2, 6}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -311,7 +310,7 @@ func TestGetSyncDuties_HttpError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -335,7 +334,7 @@ func TestGetSyncDuties_NilData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -364,7 +363,7 @@ func TestGetSyncDuties_NilSyncDuty(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -414,7 +413,7 @@ func TestGetCommittees_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -440,7 +439,7 @@ func TestGetCommittees_HttpError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -462,7 +461,7 @@ func TestGetCommittees_NilData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -489,7 +488,7 @@ func TestGetCommittees_NilCommittee(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -604,7 +603,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var attesterDuties []*structs.AttesterDuty
|
||||
if testCase.generateAttesterDuties == nil {
|
||||
@@ -705,7 +704,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
|
||||
@@ -951,7 +950,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
|
||||
@@ -1183,7 +1182,7 @@ func TestGetDuties_GetStateValidatorsFailed(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
@@ -1212,7 +1211,7 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := []byte{1, 2, 3}
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/api/server/structs"
|
||||
@@ -16,7 +15,7 @@ func TestGetGenesis_ValidGenesis(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -48,7 +47,7 @@ func TestGetGenesis_NilData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -72,7 +71,7 @@ func TestGetGenesis_EndpointCalledOnlyOnce(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -106,7 +105,7 @@ func TestGetGenesis_EndpointCanBeCalledAgainAfterError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -22,7 +21,7 @@ func TestGetBeaconBlock_RequestFailed(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -119,7 +118,7 @@ func TestGetBeaconBlock_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -155,7 +154,7 @@ func TestGetBeaconBlock_Phase0Valid(t *testing.T) {
|
||||
const slot = primitives.Slot(1)
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -198,7 +197,7 @@ func TestGetBeaconBlock_AltairValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -241,7 +240,7 @@ func TestGetBeaconBlock_BellatrixValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -286,7 +285,7 @@ func TestGetBeaconBlock_BlindedBellatrixValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -331,7 +330,7 @@ func TestGetBeaconBlock_CapellaValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -376,7 +375,7 @@ func TestGetBeaconBlock_BlindedCapellaValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -421,7 +420,7 @@ func TestGetBeaconBlock_DenebValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -466,7 +465,7 @@ func TestGetBeaconBlock_BlindedDenebValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -511,7 +510,7 @@ func TestGetBeaconBlock_ElectraValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -556,7 +555,7 @@ func TestGetBeaconBlock_BlindedElectraValid(t *testing.T) {
|
||||
randaoReveal := []byte{2}
|
||||
graffiti := []byte{3}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"testing"
|
||||
@@ -39,7 +38,7 @@ func TestIndex_Nominal(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -89,7 +88,7 @@ func TestIndex_UnexistingValidator(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -131,7 +130,7 @@ func TestIndex_BadIndexError(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -180,7 +179,7 @@ func TestIndex_JsonResponseError(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -19,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
const endpoint = "/example/rest/api/endpoint"
|
||||
genesisJson := &structs.GetGenesisResponse{
|
||||
Data: &structs.Genesis{
|
||||
@@ -50,7 +49,7 @@ func TestGet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPost(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
const endpoint = "/example/rest/api/endpoint"
|
||||
dataBytes := []byte{1, 2, 3, 4, 5}
|
||||
headers := map[string]string{"foo": "bar"}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -26,7 +25,7 @@ func TestPrepareBeaconProposer_Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRecipients := []*structs.FeeRecipient{
|
||||
{
|
||||
@@ -88,7 +87,7 @@ func TestPrepareBeaconProposer_BadRequest(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
@@ -116,7 +115,7 @@ func TestProposeAttestation(t *testing.T) {
|
||||
marshalledAttestations = b
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(test.attestation.Version())}
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -177,7 +176,7 @@ func TestProposeAttestationFallBack(t *testing.T) {
|
||||
marshalledAttestations = b
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(attestation.Version())}
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
gomock.Any(),
|
||||
@@ -304,7 +303,7 @@ func TestProposeAttestationElectra(t *testing.T) {
|
||||
marshalledAttestations = b
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(test.attestation.Version())}
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
gomock.Any(),
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -30,7 +29,7 @@ func TestProposeBeaconBlock_Altair(t *testing.T) {
|
||||
marshalledBlock, err := json.Marshal(jsonAltairBlock)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block
|
||||
headers := map[string]string{"Eth-Consensus-Version": "altair"}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -31,7 +30,7 @@ func TestProposeBeaconBlock_Bellatrix(t *testing.T) {
|
||||
marshalledBlock, err := json.Marshal(jsonBellatrixBlock)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block
|
||||
headers := map[string]string{"Eth-Consensus-Version": "bellatrix"}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -32,7 +31,7 @@ func TestProposeBeaconBlock_BlindedBellatrix(t *testing.T) {
|
||||
marshalledBlock, err := json.Marshal(jsonBlindedBellatrixBlock)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block
|
||||
headers := map[string]string{"Eth-Consensus-Version": "bellatrix"}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -32,7 +31,7 @@ func TestProposeBeaconBlock_BlindedCapella(t *testing.T) {
|
||||
marshalledBlock, err := json.Marshal(jsonBlindedCapellaBlock)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block
|
||||
headers := map[string]string{"Eth-Consensus-Version": "capella"}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_BlindedDeneb(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_BlindedElectra(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_BlindedFulu(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -42,7 +41,7 @@ func TestProposeBeaconBlock_Capella(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_Deneb(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_Electra(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -38,7 +37,7 @@ func TestProposeBeaconBlock_Fulu(t *testing.T) {
|
||||
)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock)
|
||||
proposeResponse, err := validatorClient.proposeBeaconBlock(t.Context(), genericSignedBlock)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, proposeResponse)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -30,7 +29,7 @@ func TestProposeBeaconBlock_Phase0(t *testing.T) {
|
||||
marshalledBlock, err := json.Marshal(jsonPhase0Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block
|
||||
headers := map[string]string{"Eth-Consensus-Version": "phase0"}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -104,7 +103,7 @@ func TestProposeBeaconBlock_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
headers := map[string]string{"Eth-Consensus-Version": testCase.consensusVersion}
|
||||
@@ -128,6 +127,6 @@ func TestProposeBeaconBlock_Error(t *testing.T) {
|
||||
|
||||
func TestProposeBeaconBlock_UnsupportedBlockType(t *testing.T) {
|
||||
validatorClient := &beaconApiValidatorClient{}
|
||||
_, err := validatorClient.proposeBeaconBlock(context.Background(), ðpb.GenericSignedBeaconBlock{})
|
||||
_, err := validatorClient.proposeBeaconBlock(t.Context(), ðpb.GenericSignedBeaconBlock{})
|
||||
assert.ErrorContains(t, "unsupported block type", err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -35,7 +34,7 @@ func TestProposeExit_Valid(t *testing.T) {
|
||||
marshalledVoluntaryExit, err := json.Marshal(jsonSignedVoluntaryExit)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -70,13 +69,13 @@ func TestProposeExit_Valid(t *testing.T) {
|
||||
|
||||
func TestProposeExit_NilSignedVoluntaryExit(t *testing.T) {
|
||||
validatorClient := &beaconApiValidatorClient{}
|
||||
_, err := validatorClient.proposeExit(context.Background(), nil)
|
||||
_, err := validatorClient.proposeExit(t.Context(), nil)
|
||||
assert.ErrorContains(t, "signed voluntary exit is nil", err)
|
||||
}
|
||||
|
||||
func TestProposeExit_NilExit(t *testing.T) {
|
||||
validatorClient := &beaconApiValidatorClient{}
|
||||
_, err := validatorClient.proposeExit(context.Background(), ðpb.SignedVoluntaryExit{})
|
||||
_, err := validatorClient.proposeExit(t.Context(), ðpb.SignedVoluntaryExit{})
|
||||
assert.ErrorContains(t, "exit is nil", err)
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ func TestProposeExit_BadRequest(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
@@ -116,7 +115,7 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
// Expect node version endpoint call.
|
||||
@@ -170,7 +169,7 @@ func Test_beaconApiBeaconChainClient_GetValidatorPerformance(t *testing.T) {
|
||||
bytesutil.ToBytes48([]byte{3}),
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -131,7 +130,7 @@ func TestRegistration_Valid(t *testing.T) {
|
||||
}
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
res, err := validatorClient.SubmitValidatorRegistrations(context.Background(), &protoRegistrations)
|
||||
res, err := validatorClient.SubmitValidatorRegistrations(t.Context(), &protoRegistrations)
|
||||
|
||||
assert.DeepEqual(t, new(empty.Empty), res)
|
||||
require.NoError(t, err)
|
||||
@@ -153,6 +152,6 @@ func TestRegistration_BadRequest(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.SubmitValidatorRegistrations(context.Background(), ðpb.SignedValidatorRegistrationsV1{})
|
||||
_, err := validatorClient.SubmitValidatorRegistrations(t.Context(), ðpb.SignedValidatorRegistrationsV1{})
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"testing"
|
||||
@@ -68,7 +67,7 @@ func TestGetStateValidators_Nominal_POST(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
gomock.Any(),
|
||||
@@ -154,7 +153,7 @@ func TestGetStateValidators_Nominal_GET(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// First return an error from POST call.
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -223,7 +222,7 @@ func TestGetStateValidators_GetRestJsonResponseOnError(t *testing.T) {
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// First call POST.
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -276,7 +275,7 @@ func TestGetStateValidators_DataIsNil_POST(t *testing.T) {
|
||||
reqBytes, err := json.Marshal(req)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -315,7 +314,7 @@ func TestGetStateValidators_DataIsNil_GET(t *testing.T) {
|
||||
reqBytes, err := json.Marshal(req)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
@@ -26,7 +25,7 @@ func TestValidatorStatus_Nominal(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
@@ -91,7 +90,7 @@ func TestValidatorStatus_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
@@ -123,7 +122,7 @@ func TestMultipleValidatorStatus_Nominal(t *testing.T) {
|
||||
"0x8000a6c975761b488bdb0dfba4ed37c0d97d6e6b968562ef5c84aa9a5dfb92d8e309195004e97709077723739bf04463", // existing
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorsPubKey := make([][]byte, len(stringValidatorsPubKey))
|
||||
|
||||
for i, stringValidatorPubKey := range stringValidatorsPubKey {
|
||||
@@ -219,7 +218,7 @@ func TestMultipleValidatorStatus_No_Keys(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
validatorClient := beaconApiValidatorClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
@@ -238,7 +237,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stringValidatorsPubKey := []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // existing
|
||||
"0x8000a6c975761b488bdb0dfba4ed37c0d97d6e6b968562ef5c84aa9a5dfb92d8e309195004e97709077723739bf04463", // existing
|
||||
@@ -442,7 +441,7 @@ func TestGetValidatorsStatusResponse_Nominal_NoActiveValidators(t *testing.T) {
|
||||
validatorPubKey, err := hexutil.Decode(stringValidatorPubKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
@@ -693,7 +692,7 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
gomock.Any(),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
@@ -23,7 +22,7 @@ func TestStreamBlocks_UnsupportedConsensusVersion(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -145,7 +144,7 @@ func TestStreamBlocks_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -195,7 +194,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -356,7 +355,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -517,7 +516,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -678,7 +677,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
@@ -839,7 +838,7 @@ func TestStreamBlocks_DenebValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -96,7 +95,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
// Call node syncing endpoint to check if head is optimistic.
|
||||
@@ -216,7 +215,7 @@ func TestSubmitAggregateSelectionProofFallBack(t *testing.T) {
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
// Call node syncing endpoint to check if head is optimistic.
|
||||
@@ -388,7 +387,7 @@ func TestSubmitAggregateSelectionProofElectra(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
// Call node syncing endpoint to check if head is optimistic.
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -27,7 +26,7 @@ func TestSubmitSignedAggregateSelectionProof_Valid(t *testing.T) {
|
||||
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(signedAggregateAndProof.Message.Version())}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -59,7 +58,7 @@ func TestSubmitSignedAggregateSelectionProof_BadRequest(t *testing.T) {
|
||||
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(signedAggregateAndProof.Message.Version())}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -87,7 +86,7 @@ func TestSubmitSignedAggregateSelectionProof_Fallback(t *testing.T) {
|
||||
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(signedAggregateAndProof.Message.Version())}
|
||||
@@ -131,7 +130,7 @@ func TestSubmitSignedAggregateSelectionProofElectra_Valid(t *testing.T) {
|
||||
marshalledSignedAggregateSignedAndProofElectra, err := json.Marshal([]*structs.SignedAggregateAttestationAndProofElectra{jsonifySignedAggregateAndProofElectra(signedAggregateAndProofElectra)})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(signedAggregateAndProofElectra.Message.Version())}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -163,7 +162,7 @@ func TestSubmitSignedAggregateSelectionProofElectra_BadRequest(t *testing.T) {
|
||||
marshalledSignedAggregateSignedAndProofElectra, err := json.Marshal([]*structs.SignedAggregateAttestationAndProofElectra{jsonifySignedAggregateAndProofElectra(signedAggregateAndProofElectra)})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
headers := map[string]string{"Eth-Consensus-Version": version.String(signedAggregateAndProofElectra.Message.Version())}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
@@ -42,7 +41,7 @@ func TestSubmitSignedContributionAndProof_Valid(t *testing.T) {
|
||||
marshalledContributionAndProofs, err := json.Marshal(jsonContributionAndProofs)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -116,7 +115,7 @@ func TestSubmitSignedContributionAndProof_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
if testCase.httpRequestExpected {
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strconv"
|
||||
@@ -43,7 +42,7 @@ func TestSubscribeCommitteeSubnets_Valid(t *testing.T) {
|
||||
committeeSubscriptionsBytes, err := json.Marshal(jsonCommitteeSubscriptions)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
@@ -204,7 +203,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
if testCase.expectSubscribeRestCall {
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -102,7 +101,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
reqBody, err := json.Marshal(test.req)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler.EXPECT().Post(
|
||||
gomock.Any(),
|
||||
"/eth/v1/validator/sync_committee_selections",
|
||||
|
||||
@@ -2,7 +2,6 @@ package beacon_api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
@@ -64,7 +63,7 @@ func TestSubmitSyncMessage_Valid(t *testing.T) {
|
||||
}
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
res, err := validatorClient.SubmitSyncMessage(context.Background(), &protoSyncCommitteeMessage)
|
||||
res, err := validatorClient.SubmitSyncMessage(t.Context(), &protoSyncCommitteeMessage)
|
||||
|
||||
assert.DeepEqual(t, new(empty.Empty), res)
|
||||
require.NoError(t, err)
|
||||
@@ -86,7 +85,7 @@ func TestSubmitSyncMessage_BadRequest(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.SubmitSyncMessage(context.Background(), ðpb.SyncCommitteeMessage{})
|
||||
_, err := validatorClient.SubmitSyncMessage(t.Context(), ðpb.SyncCommitteeMessage{})
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ func TestGetSyncMessageBlockRoot(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -207,7 +206,7 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
gomock.Any(),
|
||||
@@ -308,7 +307,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
valsReq := &structs.GetValidatorsRequest{
|
||||
Ids: []string{pubkeyStr},
|
||||
Statuses: []string{},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package beacon_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -20,7 +19,7 @@ func TestWaitForChainStart_ValidGenesis(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -87,7 +86,7 @@ func TestWaitForChainStart_BadGenesis(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -115,7 +114,7 @@ func TestWaitForChainStart_JsonResponseError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
@@ -138,7 +137,7 @@ func TestWaitForChainStart_JsonResponseError404(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
genesisResponseJson := structs.GetGenesisResponse{}
|
||||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package grpc_api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/config/params"
|
||||
@@ -318,7 +317,7 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
require.Equal(t, true, ok)
|
||||
statuses = append(statuses, valStatus)
|
||||
}
|
||||
vcCountResp, err := prysmBeaconChainClient.ValidatorCount(context.Background(), "", statuses)
|
||||
vcCountResp, err := prysmBeaconChainClient.ValidatorCount(t.Context(), "", statuses)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, test.expectedResponse, vcCountResp)
|
||||
})
|
||||
|
||||
@@ -134,14 +134,14 @@ func TestWaitForChainStart_StreamSetupFails(t *testing.T) {
|
||||
).Return(nil, errors.New("failed stream"))
|
||||
|
||||
validatorClient := &grpcValidatorClient{beaconNodeValidatorClient, true}
|
||||
_, err := validatorClient.WaitForChainStart(context.Background(), &emptypb.Empty{})
|
||||
_, err := validatorClient.WaitForChainStart(t.Context(), &emptypb.Empty{})
|
||||
want := "could not setup beacon chain ChainStart streaming client"
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
func TestStartEventStream(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -47,7 +46,7 @@ func TestValidator_HandleKeyReload(t *testing.T) {
|
||||
},
|
||||
).Return(resp, nil)
|
||||
|
||||
anyActive, err := v.HandleKeyReload(context.Background(), [][fieldparams.BLSPubkeyLength]byte{inactive.pub, active.pub})
|
||||
anyActive, err := v.HandleKeyReload(t.Context(), [][fieldparams.BLSPubkeyLength]byte{inactive.pub, active.pub})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, anyActive)
|
||||
assert.LogsContain(t, hook, "Waiting for deposit to be observed by beacon node")
|
||||
@@ -79,7 +78,7 @@ func TestValidator_HandleKeyReload(t *testing.T) {
|
||||
},
|
||||
).Return(resp, nil)
|
||||
|
||||
anyActive, err := v.HandleKeyReload(context.Background(), [][fieldparams.BLSPubkeyLength]byte{kp.pub})
|
||||
anyActive, err := v.HandleKeyReload(t.Context(), [][fieldparams.BLSPubkeyLength]byte{kp.pub})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, anyActive)
|
||||
assert.LogsContain(t, hook, "Waiting for deposit to be observed by beacon node")
|
||||
@@ -103,7 +102,7 @@ func TestValidator_HandleKeyReload(t *testing.T) {
|
||||
},
|
||||
).Return(nil, errors.New("error"))
|
||||
|
||||
_, err := v.HandleKeyReload(context.Background(), [][fieldparams.BLSPubkeyLength]byte{kp.pub})
|
||||
_, err := v.HandleKeyReload(t.Context(), [][fieldparams.BLSPubkeyLength]byte{kp.pub})
|
||||
assert.ErrorContains(t, "error", err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func TestProposeBlock_DoesNotProposeGenesisBlock(t *testing.T) {
|
||||
defer finish()
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.ProposeBlock(context.Background(), 0, pubKey)
|
||||
validator.ProposeBlock(t.Context(), 0, pubKey)
|
||||
|
||||
require.LogsContain(t, hook, "Assigned to genesis slot, skipping proposal")
|
||||
})
|
||||
@@ -134,7 +134,7 @@ func TestProposeBlock_DomainDataFailed(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(nil /*response*/, errors.New("uh oh"))
|
||||
|
||||
validator.ProposeBlock(context.Background(), 1, pubKey)
|
||||
validator.ProposeBlock(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Failed to sign randao reveal")
|
||||
})
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func TestProposeBlock_DomainDataIsNil(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(nil /*response*/, nil)
|
||||
|
||||
validator.ProposeBlock(context.Background(), 1, pubKey)
|
||||
validator.ProposeBlock(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, domainDataErr)
|
||||
})
|
||||
}
|
||||
@@ -204,7 +204,7 @@ func TestProposeBlock_RequestBlockFailed(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(nil /*response*/, errors.New("uh oh"))
|
||||
|
||||
validator.ProposeBlock(context.Background(), tt.slot, pubKey)
|
||||
validator.ProposeBlock(t.Context(), tt.slot, pubKey)
|
||||
require.LogsContain(t, hook, "Failed to request block from beacon node")
|
||||
})
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestProposeBlock_ProposeBlockFailed(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.GenericSignedBeaconBlock{}),
|
||||
).Return(nil /*response*/, errors.New("uh oh"))
|
||||
|
||||
validator.ProposeBlock(context.Background(), 1, pubKey)
|
||||
validator.ProposeBlock(t.Context(), 1, pubKey)
|
||||
|
||||
require.LogsContain(t, hook, "Failed to propose block")
|
||||
|
||||
@@ -354,7 +354,7 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
|
||||
var dummyRoot [32]byte
|
||||
// Save a dummy proposal history at slot 1.
|
||||
err := validator.db.SaveProposalHistoryForSlot(context.Background(), pubKey, 1, dummyRoot[:])
|
||||
err := validator.db.SaveProposalHistoryForSlot(t.Context(), pubKey, 1, dummyRoot[:])
|
||||
require.NoError(t, err)
|
||||
|
||||
m.validatorClient.EXPECT().DomainData(
|
||||
@@ -382,10 +382,10 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.GenericSignedBeaconBlock{}),
|
||||
).Return(ðpb.ProposeResponse{BlockRoot: make([]byte, 32)}, nil /*error*/)
|
||||
|
||||
validator.ProposeBlock(context.Background(), slot, pubKey)
|
||||
validator.ProposeBlock(t.Context(), slot, pubKey)
|
||||
require.LogsDoNotContain(t, hook, failedBlockSignLocalErr)
|
||||
|
||||
validator.ProposeBlock(context.Background(), slot, pubKey)
|
||||
validator.ProposeBlock(t.Context(), slot, pubKey)
|
||||
require.LogsContain(t, hook, failedBlockSignLocalErr)
|
||||
})
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func TestProposeBlock_BlocksDoubleProposal_After54KEpochs(t *testing.T) {
|
||||
|
||||
var dummyRoot [32]byte
|
||||
// Save a dummy proposal history at slot 1.
|
||||
err := validator.db.SaveProposalHistoryForSlot(context.Background(), pubKey, 1, dummyRoot[:])
|
||||
err := validator.db.SaveProposalHistoryForSlot(t.Context(), pubKey, 1, dummyRoot[:])
|
||||
require.NoError(t, err)
|
||||
|
||||
m.validatorClient.EXPECT().DomainData(
|
||||
@@ -446,10 +446,10 @@ func TestProposeBlock_BlocksDoubleProposal_After54KEpochs(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.GenericSignedBeaconBlock{}),
|
||||
).Return(ðpb.ProposeResponse{BlockRoot: make([]byte, 32)}, nil /*error*/)
|
||||
|
||||
validator.ProposeBlock(context.Background(), farFuture, pubKey)
|
||||
validator.ProposeBlock(t.Context(), farFuture, pubKey)
|
||||
require.LogsDoNotContain(t, hook, failedBlockSignLocalErr)
|
||||
|
||||
validator.ProposeBlock(context.Background(), farFuture, pubKey)
|
||||
validator.ProposeBlock(t.Context(), farFuture, pubKey)
|
||||
require.LogsContain(t, hook, failedBlockSignLocalErr)
|
||||
})
|
||||
}
|
||||
@@ -481,7 +481,7 @@ func TestProposeBlock_AllowsOrNotPastProposals(t *testing.T) {
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
|
||||
// Save a dummy proposal history at slot 0.
|
||||
err := validator.db.SaveProposalHistoryForSlot(context.Background(), pubKey, 0, []byte{})
|
||||
err := validator.db.SaveProposalHistoryForSlot(t.Context(), pubKey, 0, []byte{})
|
||||
require.NoError(t, err)
|
||||
|
||||
m.validatorClient.EXPECT().DomainData(
|
||||
@@ -515,7 +515,7 @@ func TestProposeBlock_AllowsOrNotPastProposals(t *testing.T) {
|
||||
gomock.AssignableToTypeOf(ðpb.GenericSignedBeaconBlock{}),
|
||||
).Times(proposeBeaconBlockCount).Return(ðpb.ProposeResponse{BlockRoot: make([]byte, 32)}, nil /*error*/)
|
||||
|
||||
validator.ProposeBlock(context.Background(), slot, pubKey)
|
||||
validator.ProposeBlock(t.Context(), slot, pubKey)
|
||||
require.LogsDoNotContain(t, hook, failedBlockSignLocalErr)
|
||||
|
||||
blk2 := util.NewBeaconBlock()
|
||||
@@ -528,7 +528,7 @@ func TestProposeBlock_AllowsOrNotPastProposals(t *testing.T) {
|
||||
Phase0: blk2.Block,
|
||||
},
|
||||
}, nil /*err*/)
|
||||
validator.ProposeBlock(context.Background(), tt.pastSlot, pubKey)
|
||||
validator.ProposeBlock(t.Context(), tt.pastSlot, pubKey)
|
||||
if isSlashingProtectionMinimal {
|
||||
require.LogsContain(t, hook, failedBlockSignLocalErr)
|
||||
} else {
|
||||
@@ -722,7 +722,7 @@ func testProposeBlock(t *testing.T, graffiti []byte) {
|
||||
return ðpb.ProposeResponse{BlockRoot: make([]byte, 32)}, nil
|
||||
})
|
||||
|
||||
validator.ProposeBlock(context.Background(), 1, pubKey)
|
||||
validator.ProposeBlock(t.Context(), 1, pubKey)
|
||||
g := sentBlock.Block().Body().Graffiti()
|
||||
assert.Equal(t, string(validator.graffiti), string(g[:]))
|
||||
require.LogsContain(t, hook, "Submitted new block")
|
||||
@@ -744,7 +744,7 @@ func TestProposeExit_ValidatorIndexFailed(t *testing.T) {
|
||||
).Return(nil, errors.New("uh oh"))
|
||||
|
||||
err := ProposeExit(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
m.validatorClient,
|
||||
m.signfunc,
|
||||
validatorKey.PublicKey().Marshal(),
|
||||
@@ -772,7 +772,7 @@ func TestProposeExit_DomainDataFailed(t *testing.T) {
|
||||
Return(nil, errors.New("uh oh"))
|
||||
|
||||
err := ProposeExit(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
m.validatorClient,
|
||||
m.signfunc,
|
||||
validatorKey.PublicKey().Marshal(),
|
||||
@@ -801,7 +801,7 @@ func TestProposeExit_DomainDataIsNil(t *testing.T) {
|
||||
Return(nil, nil)
|
||||
|
||||
err := ProposeExit(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
m.validatorClient,
|
||||
m.signfunc,
|
||||
validatorKey.PublicKey().Marshal(),
|
||||
@@ -833,7 +833,7 @@ func TestProposeBlock_ProposeExitFailed(t *testing.T) {
|
||||
Return(nil, errors.New("uh oh"))
|
||||
|
||||
err := ProposeExit(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
m.validatorClient,
|
||||
m.signfunc,
|
||||
validatorKey.PublicKey().Marshal(),
|
||||
@@ -865,7 +865,7 @@ func TestProposeExit_BroadcastsBlock(t *testing.T) {
|
||||
Return(ðpb.ProposeExitResponse{}, nil)
|
||||
|
||||
assert.NoError(t, ProposeExit(
|
||||
context.Background(),
|
||||
t.Context(),
|
||||
m.validatorClient,
|
||||
m.signfunc,
|
||||
validatorKey.PublicKey().Marshal(),
|
||||
@@ -885,7 +885,7 @@ func TestSignBlock(t *testing.T) {
|
||||
m.validatorClient.EXPECT().
|
||||
DomainData(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.DomainResponse{SignatureDomain: proposerDomain}, nil)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
blk := util.NewBeaconBlock()
|
||||
blk.Block.Slot = 1
|
||||
blk.Block.ProposerIndex = 100
|
||||
@@ -924,7 +924,7 @@ func TestSignAltairBlock(t *testing.T) {
|
||||
m.validatorClient.EXPECT().
|
||||
DomainData(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.DomainResponse{SignatureDomain: proposerDomain}, nil)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
blk := util.NewBeaconBlockAltair()
|
||||
blk.Block.Slot = 1
|
||||
blk.Block.ProposerIndex = 100
|
||||
@@ -955,7 +955,7 @@ func TestSignBellatrixBlock(t *testing.T) {
|
||||
DomainData(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.DomainResponse{SignatureDomain: proposerDomain}, nil)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
blk := util.NewBeaconBlockBellatrix()
|
||||
blk.Block.Slot = 1
|
||||
blk.Block.ProposerIndex = 100
|
||||
@@ -1094,7 +1094,7 @@ func TestGetGraffiti_Ok(t *testing.T) {
|
||||
ValidatorIndex(gomock.Any(), ðpb.ValidatorIndexRequest{PublicKey: pubKey[:]}).
|
||||
Return(ðpb.ValidatorIndexResponse{Index: 2}, nil)
|
||||
}
|
||||
got, err := tt.v.Graffiti(context.Background(), pubKey)
|
||||
got, err := tt.v.Graffiti(t.Context(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, tt.want, got)
|
||||
})
|
||||
@@ -1124,7 +1124,7 @@ func TestGetGraffitiOrdered_Ok(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, want := range [][]byte{bytesutil.PadTo([]byte{'a'}, 32), bytesutil.PadTo([]byte{'b'}, 32), bytesutil.PadTo([]byte{'c'}, 32), bytesutil.PadTo([]byte{'d'}, 32), bytesutil.PadTo([]byte{'d'}, 32)} {
|
||||
got, err := v.Graffiti(context.Background(), pubKey)
|
||||
got, err := v.Graffiti(t.Context(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, want, got)
|
||||
}
|
||||
@@ -1191,7 +1191,7 @@ func Test_validator_DeleteGraffiti(t *testing.T) {
|
||||
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
proposerSettings: tt.proposerSettings,
|
||||
}
|
||||
err := v.DeleteGraffiti(context.Background(), pubKey)
|
||||
err := v.DeleteGraffiti(t.Context(), pubKey)
|
||||
if tt.wantErr != "" {
|
||||
require.ErrorContains(t, tt.wantErr, err)
|
||||
} else {
|
||||
@@ -1271,7 +1271,7 @@ func Test_validator_SetGraffiti(t *testing.T) {
|
||||
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||
proposerSettings: tt.proposerSettings,
|
||||
}
|
||||
err := v.SetGraffiti(context.Background(), pubKey, []byte(tt.graffiti))
|
||||
err := v.SetGraffiti(t.Context(), pubKey, []byte(tt.graffiti))
|
||||
if tt.wantErr != "" {
|
||||
require.ErrorContains(t, tt.wantErr, err)
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -22,7 +21,7 @@ func TestSubmitValidatorRegistrations(t *testing.T) {
|
||||
_, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorRegsBatchSize := 2
|
||||
require.NoError(t, nil, SubmitValidatorRegistrations(ctx, m.validatorClient, []*ethpb.SignedValidatorRegistrationV1{}, validatorRegsBatchSize))
|
||||
|
||||
@@ -103,7 +102,7 @@ func TestSubmitValidatorRegistration_CantSign(t *testing.T) {
|
||||
_, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorRegsBatchSize := 500
|
||||
reg := ðpb.ValidatorRegistrationV1{
|
||||
FeeRecipient: bytesutil.PadTo([]byte("fee"), 20),
|
||||
@@ -134,7 +133,7 @@ func Test_signValidatorRegistration(t *testing.T) {
|
||||
_, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
reg := ðpb.ValidatorRegistrationV1{
|
||||
FeeRecipient: bytesutil.PadTo([]byte("fee"), 20),
|
||||
GasLimit: 123456,
|
||||
@@ -151,7 +150,7 @@ func TestValidator_SignValidatorRegistrationRequest(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
_, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
|
||||
defer finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
byteval, err := hexutil.Decode("0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766")
|
||||
require.NoError(t, err)
|
||||
tests := []struct {
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestRetry_On_ConnectionError(t *testing.T) {
|
||||
RetryTillSuccess: retry,
|
||||
}
|
||||
backOffPeriod = 10 * time.Millisecond
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
go run(ctx, v)
|
||||
// each step will fail (retry times)=10 this sleep times will wait more then
|
||||
// the time it takes for all steps to succeed before main loop.
|
||||
@@ -114,9 +114,9 @@ func TestUpdateDuties_NextSlot(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -140,9 +140,9 @@ func TestUpdateDuties_HandlesError(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -166,9 +166,9 @@ func TestRoleAt_NextSlot(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -192,10 +192,10 @@ func TestAttests_NextSlot(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
attSubmitted := make(chan interface{})
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, AttSubmitted: attSubmitted}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -219,10 +219,10 @@ func TestProposes_NextSlot(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
blockProposed := make(chan interface{})
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, BlockProposed: blockProposed}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -247,11 +247,11 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
// avoid race condition between the cancellation of the context in the go stream from slot and the setting of IsHealthy
|
||||
_ = tracker.CheckHealth(context.Background())
|
||||
_ = tracker.CheckHealth(t.Context())
|
||||
blockProposed := make(chan interface{})
|
||||
attSubmitted := make(chan interface{})
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, BlockProposed: blockProposed, AttSubmitted: attSubmitted}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
slot := primitives.Slot(55)
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -272,7 +272,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKeyReload_ActiveKey(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
km := &mockKeymanager{}
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
@@ -290,7 +290,7 @@ func TestKeyReload_ActiveKey(t *testing.T) {
|
||||
|
||||
func TestKeyReload_NoActiveKey(t *testing.T) {
|
||||
na := notActive(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
km := &mockKeymanager{}
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
@@ -324,7 +324,7 @@ func TestUpdateProposerSettingsAt_EpochStart(t *testing.T) {
|
||||
tracker := health.NewTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
v := &testutil.FakeValidator{Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker}
|
||||
err := v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err := v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
FeeRecipient: common.HexToAddress("0x046Fb65722E7b2455012BFEBf6177F1D2e9738D9"),
|
||||
@@ -332,7 +332,7 @@ func TestUpdateProposerSettingsAt_EpochStart(t *testing.T) {
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
hook := logTest.NewGlobal()
|
||||
slot := params.BeaconConfig().SlotsPerEpoch
|
||||
ticker := make(chan primitives.Slot)
|
||||
@@ -358,7 +358,7 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) {
|
||||
ProposerSettingWait: time.Duration(params.BeaconConfig().SecondsPerSlot-1) * time.Second,
|
||||
Tracker: tracker,
|
||||
}
|
||||
err := v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err := v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
FeeRecipient: common.HexToAddress("0x046Fb65722E7b2455012BFEBf6177F1D2e9738D9"),
|
||||
@@ -366,7 +366,7 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) {
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
hook := logTest.NewGlobal()
|
||||
slot := params.BeaconConfig().SlotsPerEpoch - 1 //have it set close to the end of epoch
|
||||
ticker := make(chan primitives.Slot)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
var _ runtime.Service = (*ValidatorService)(nil)
|
||||
|
||||
func TestStop_CancelsContext(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
vs := &ValidatorService{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
@@ -33,7 +33,7 @@ func TestStop_CancelsContext(t *testing.T) {
|
||||
|
||||
func TestNew_Insecure(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
_, err := NewValidatorService(context.Background(), &Config{})
|
||||
_, err := NewValidatorService(t.Context(), &Config{})
|
||||
require.NoError(t, err)
|
||||
require.LogsContain(t, hook, "You are using an insecure gRPC connection")
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func TestStatus_NoConnectionError(t *testing.T) {
|
||||
|
||||
func TestStart_GrpcHeaders(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
for input, output := range map[string][]string{
|
||||
"should-break": {},
|
||||
"key=value": {"key", "value"},
|
||||
|
||||
@@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -98,7 +97,7 @@ func TestEIP3076SpecTests(t *testing.T) {
|
||||
for _, step := range tt.Steps {
|
||||
if tt.GenesisValidatorsRoot != "" {
|
||||
r, err := helpers.RootFromHex(tt.GenesisValidatorsRoot)
|
||||
require.NoError(t, validator.db.SaveGenesisValidatorsRoot(context.Background(), r[:]))
|
||||
require.NoError(t, validator.db.SaveGenesisValidatorsRoot(t.Context(), r[:]))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ func TestEIP3076SpecTests(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b := bytes.NewBuffer(interchangeBytes)
|
||||
if err := validator.db.ImportStandardProtectionJSON(context.Background(), b); err != nil {
|
||||
if err := validator.db.ImportStandardProtectionJSON(t.Context(), b); err != nil {
|
||||
if step.ShouldSucceed {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -140,7 +139,7 @@ func TestEIP3076SpecTests(t *testing.T) {
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
err = validator.db.SlashableProposalCheck(context.Background(), pk, wsb, signingRoot, validator.emitAccountMetrics, ValidatorProposeFailVec)
|
||||
err = validator.db.SlashableProposalCheck(t.Context(), pk, wsb, signingRoot, validator.emitAccountMetrics, ValidatorProposeFailVec)
|
||||
if shouldSucceed {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
@@ -177,7 +176,7 @@ func TestEIP3076SpecTests(t *testing.T) {
|
||||
copy(signingRoot[:], signingRootBytes)
|
||||
}
|
||||
|
||||
err = validator.db.SlashableAttestationCheck(context.Background(), ia, pk, signingRoot, false, nil)
|
||||
err = validator.db.SlashableAttestationCheck(t.Context(), ia, pk, signingRoot, false, nil)
|
||||
if shouldSucceed {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestSubmitSyncCommitteeMessage_ValidatorDutiesRequestFailure(t *testing.T)
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitSyncCommitteeMessage(context.Background(), 1, pubKey)
|
||||
validator.SubmitSyncCommitteeMessage(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not fetch validator assignment")
|
||||
})
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestSubmitSyncCommitteeMessage_BadDomainData(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitSyncCommitteeMessage(context.Background(), 1, pubKey)
|
||||
validator.SubmitSyncCommitteeMessage(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not get sync committee domain data")
|
||||
})
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TestSubmitSyncCommitteeMessage_CouldNotSubmit(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitSyncCommitteeMessage(context.Background(), 1, pubKey)
|
||||
validator.SubmitSyncCommitteeMessage(t.Context(), 1, pubKey)
|
||||
|
||||
require.LogsContain(t, hook, "Could not submit sync committee message")
|
||||
})
|
||||
@@ -165,7 +165,7 @@ func TestSubmitSyncCommitteeMessage_OK(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitSyncCommitteeMessage(context.Background(), 1, pubKey)
|
||||
validator.SubmitSyncCommitteeMessage(t.Context(), 1, pubKey)
|
||||
|
||||
require.LogsDoNotContain(t, hook, "Could not")
|
||||
require.Equal(t, primitives.Slot(1), generatedMsg.Slot)
|
||||
@@ -185,7 +185,7 @@ func TestSubmitSignedContributionAndProof_ValidatorDutiesRequestFailure(t *testi
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not fetch validator assignment")
|
||||
})
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func TestSubmitSignedContributionAndProof_SyncSubcommitteeIndexFailure(t *testin
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{}, errors.New("Bad index"))
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not get sync subcommittee index")
|
||||
})
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func TestSubmitSignedContributionAndProof_NothingToDo(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{Indices: []primitives.CommitteeIndex{}}, nil)
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Empty subcommittee index list, do nothing")
|
||||
})
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func TestSubmitSignedContributionAndProof_BadDomain(t *testing.T) {
|
||||
SignatureDomain: make([]byte, 32),
|
||||
}, errors.New("bad domain response"))
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not get selection proofs")
|
||||
require.LogsContain(t, hook, "bad domain response")
|
||||
})
|
||||
@@ -343,7 +343,7 @@ func TestSubmitSignedContributionAndProof_CouldNotGetContribution(t *testing.T)
|
||||
},
|
||||
).Return(nil, errors.New("Bad contribution"))
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not get sync committee contribution")
|
||||
})
|
||||
}
|
||||
@@ -426,7 +426,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing.
|
||||
}),
|
||||
).Return(&emptypb.Empty{}, errors.New("Could not submit contribution"))
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
require.LogsContain(t, hook, "Could not submit signed contribution and proof")
|
||||
})
|
||||
}
|
||||
@@ -508,7 +508,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) {
|
||||
}),
|
||||
).Return(&emptypb.Empty{}, nil)
|
||||
|
||||
validator.SubmitSignedContributionAndProof(context.Background(), 1, pubKey)
|
||||
validator.SubmitSignedContributionAndProof(t.Context(), 1, pubKey)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
// Make sure its clean at the start.
|
||||
savedGenValRoot, err := db.GenesisValidatorsRoot(context.Background())
|
||||
savedGenValRoot, err := db.GenesisValidatorsRoot(t.Context())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, []byte(nil), savedGenValRoot, "Unexpected saved genesis validators root")
|
||||
|
||||
@@ -186,8 +186,8 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
||||
GenesisTime: genesis,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot[:],
|
||||
}, nil)
|
||||
require.NoError(t, v.WaitForChainStart(context.Background()))
|
||||
savedGenValRoot, err = db.GenesisValidatorsRoot(context.Background())
|
||||
require.NoError(t, v.WaitForChainStart(t.Context()))
|
||||
savedGenValRoot, err = db.GenesisValidatorsRoot(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.DeepEqual(t, genesisValidatorsRoot[:], savedGenValRoot, "Unexpected saved genesis validators root")
|
||||
@@ -203,7 +203,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
||||
GenesisTime: genesis,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot[:],
|
||||
}, nil)
|
||||
require.NoError(t, v.WaitForChainStart(context.Background()))
|
||||
require.NoError(t, v.WaitForChainStart(t.Context()))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -230,8 +230,8 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
|
||||
GenesisTime: genesis,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot[:],
|
||||
}, nil)
|
||||
require.NoError(t, v.WaitForChainStart(context.Background()))
|
||||
savedGenValRoot, err := db.GenesisValidatorsRoot(context.Background())
|
||||
require.NoError(t, v.WaitForChainStart(t.Context()))
|
||||
savedGenValRoot, err := db.GenesisValidatorsRoot(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.DeepEqual(t, genesisValidatorsRoot[:], savedGenValRoot, "Unexpected saved genesis validators root")
|
||||
@@ -249,7 +249,7 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
|
||||
GenesisTime: genesis,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot[:],
|
||||
}, nil)
|
||||
err = v.WaitForChainStart(context.Background())
|
||||
err = v.WaitForChainStart(t.Context())
|
||||
require.ErrorContains(t, "does not match root saved", err)
|
||||
})
|
||||
}
|
||||
@@ -274,7 +274,7 @@ func TestWaitForChainStart_ContextCanceled(t *testing.T) {
|
||||
GenesisTime: genesis,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot,
|
||||
}, nil)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
cancel()
|
||||
assert.ErrorContains(t, cancelledCtx, v.WaitForChainStart(ctx))
|
||||
}
|
||||
@@ -291,7 +291,7 @@ func TestWaitForChainStart_ReceiveErrorFromStream(t *testing.T) {
|
||||
gomock.Any(),
|
||||
&emptypb.Empty{},
|
||||
).Return(nil, errors.New("fails"))
|
||||
err := v.WaitForChainStart(context.Background())
|
||||
err := v.WaitForChainStart(t.Context())
|
||||
want := "could not receive ChainStart from stream"
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func TestCanonicalHeadSlot_FailedRPC(t *testing.T) {
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(nil, errors.New("failed"))
|
||||
_, err := v.CanonicalHeadSlot(context.Background())
|
||||
_, err := v.CanonicalHeadSlot(t.Context())
|
||||
assert.ErrorContains(t, "failed", err)
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ func TestCanonicalHeadSlot_OK(t *testing.T) {
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(ðpb.ChainHead{HeadSlot: 0}, nil)
|
||||
headSlot, err := v.CanonicalHeadSlot(context.Background())
|
||||
headSlot, err := v.CanonicalHeadSlot(t.Context())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, primitives.Slot(0), headSlot, "Mismatch slots")
|
||||
}
|
||||
@@ -337,7 +337,7 @@ func TestWaitSync_ContextCanceled(t *testing.T) {
|
||||
nodeClient: n,
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
cancel()
|
||||
|
||||
n.EXPECT().SyncStatus(
|
||||
@@ -362,7 +362,7 @@ func TestWaitSync_NotSyncing(t *testing.T) {
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: false}, nil)
|
||||
|
||||
require.NoError(t, v.WaitForSync(context.Background()))
|
||||
require.NoError(t, v.WaitForSync(t.Context()))
|
||||
}
|
||||
|
||||
func TestWaitSync_Syncing(t *testing.T) {
|
||||
@@ -384,7 +384,7 @@ func TestWaitSync_Syncing(t *testing.T) {
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: false}, nil)
|
||||
|
||||
require.NoError(t, v.WaitForSync(context.Background()))
|
||||
require.NoError(t, v.WaitForSync(t.Context()))
|
||||
}
|
||||
|
||||
func TestUpdateDuties_DoesNothingWhenNotEpochStart_AlreadyExistingAssignments(t *testing.T) {
|
||||
@@ -415,7 +415,7 @@ func TestUpdateDuties_DoesNothingWhenNotEpochStart_AlreadyExistingAssignments(t
|
||||
gomock.Any(),
|
||||
).Times(1)
|
||||
|
||||
assert.NoError(t, v.UpdateDuties(context.Background()), "Could not update assignments")
|
||||
assert.NoError(t, v.UpdateDuties(t.Context()), "Could not update assignments")
|
||||
}
|
||||
|
||||
func TestUpdateDuties_ReturnsError(t *testing.T) {
|
||||
@@ -442,7 +442,7 @@ func TestUpdateDuties_ReturnsError(t *testing.T) {
|
||||
gomock.Any(),
|
||||
).Return(nil, expected)
|
||||
|
||||
assert.ErrorContains(t, expected.Error(), v.UpdateDuties(context.Background()))
|
||||
assert.ErrorContains(t, expected.Error(), v.UpdateDuties(t.Context()))
|
||||
assert.Equal(t, (*ethpb.ValidatorDutiesContainer)(nil), v.duties, "Assignments should have been cleared on failure")
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ func TestUpdateDuties_OK(t *testing.T) {
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
require.NoError(t, v.UpdateDuties(context.Background()), "Could not update assignments")
|
||||
require.NoError(t, v.UpdateDuties(t.Context()), "Could not update assignments")
|
||||
|
||||
util.WaitTimeout(&wg, 2*time.Second)
|
||||
|
||||
@@ -531,7 +531,7 @@ func TestUpdateDuties_OK_FilterBlacklistedPublicKeys(t *testing.T) {
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
require.NoError(t, v.UpdateDuties(context.Background()), "Could not update assignments")
|
||||
require.NoError(t, v.UpdateDuties(t.Context()), "Could not update assignments")
|
||||
|
||||
util.WaitTimeout(&wg, 2*time.Second)
|
||||
|
||||
@@ -576,7 +576,7 @@ func TestUpdateDuties_AllValidatorsExited(t *testing.T) {
|
||||
gomock.Any(),
|
||||
).Return(resp, nil)
|
||||
|
||||
err := v.UpdateDuties(context.Background())
|
||||
err := v.UpdateDuties(t.Context())
|
||||
require.ErrorContains(t, ErrValidatorsAllExited.Error(), err)
|
||||
|
||||
}
|
||||
@@ -662,7 +662,7 @@ func TestUpdateDuties_Distributed(t *testing.T) {
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
require.NoError(t, v.UpdateDuties(context.Background()), "Could not update assignments")
|
||||
require.NoError(t, v.UpdateDuties(t.Context()), "Could not update assignments")
|
||||
util.WaitTimeout(&wg, 2*time.Second)
|
||||
require.Equal(t, 2, len(v.attSelections))
|
||||
}
|
||||
@@ -705,7 +705,7 @@ func TestRolesAt_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{}, nil /*err*/)
|
||||
|
||||
roleMap, err := v.RolesAt(context.Background(), 1)
|
||||
roleMap, err := v.RolesAt(t.Context(), 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, iface.RoleAttester, roleMap[bytesutil.ToBytes48(validatorKey.PublicKey().Marshal())][0])
|
||||
@@ -740,7 +740,7 @@ func TestRolesAt_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{}, nil /*err*/)
|
||||
|
||||
roleMap, err = v.RolesAt(context.Background(), params.BeaconConfig().SlotsPerEpoch-1)
|
||||
roleMap, err = v.RolesAt(t.Context(), params.BeaconConfig().SlotsPerEpoch-1)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, iface.RoleSyncCommittee, roleMap[bytesutil.ToBytes48(validatorKey.PublicKey().Marshal())][0])
|
||||
})
|
||||
@@ -769,7 +769,7 @@ func TestRolesAt_DoesNotAssignProposer_Slot0(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
roleMap, err := v.RolesAt(context.Background(), 0)
|
||||
roleMap, err := v.RolesAt(t.Context(), 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, iface.RoleAttester, roleMap[bytesutil.ToBytes48(validatorKey.PublicKey().Marshal())][0])
|
||||
@@ -923,7 +923,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
validatorSetter: func(t *testing.T) *validator {
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
@@ -932,7 +932,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
att := createAttestation(10, 12)
|
||||
rt, err := att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(context.Background(), pkey, rt, att))
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(t.Context(), pkey, rt, att))
|
||||
signedRoot := rt[:]
|
||||
if isSlashingProtectionMinimal {
|
||||
signedRoot = nil
|
||||
@@ -957,7 +957,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
validatorSetter: func(t *testing.T) *validator {
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
@@ -967,7 +967,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
att := createAttestation(10, 12)
|
||||
rt, err := att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(context.Background(), pkey, rt, att))
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(t.Context(), pkey, rt, att))
|
||||
if i%3 == 0 {
|
||||
resp.Responses = append(resp.Responses, ðpb.DoppelGangerResponse_ValidatorResponse{PublicKey: pkey[:], DuplicateExists: true})
|
||||
}
|
||||
@@ -998,7 +998,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
validatorSetter: func(t *testing.T) *validator {
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
@@ -1008,7 +1008,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
att := createAttestation(10, 12)
|
||||
rt, err := att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(context.Background(), pkey, rt, att))
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(t.Context(), pkey, rt, att))
|
||||
if i%9 == 0 {
|
||||
resp.Responses = append(resp.Responses, ðpb.DoppelGangerResponse_ValidatorResponse{PublicKey: pkey[:], DuplicateExists: true})
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
validatorSetter: func(t *testing.T) *validator {
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||
@@ -1049,7 +1049,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
att := createAttestation(10+primitives.Epoch(j), 12+primitives.Epoch(j))
|
||||
rt, err := att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(context.Background(), pkey, rt, att))
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(t.Context(), pkey, rt, att))
|
||||
|
||||
signedRoot := rt[:]
|
||||
if isSlashingProtectionMinimal {
|
||||
@@ -1083,7 +1083,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
// Use only 1 key for deterministic order.
|
||||
km := genMockKeymanager(t, 1)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||
@@ -1109,7 +1109,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%s/isSlashingProtectionMinimal:%v", tt.name, isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
v := tt.validatorSetter(t)
|
||||
if err := v.CheckDoppelGanger(context.Background()); tt.err != "" {
|
||||
if err := v.CheckDoppelGanger(t.Context()); tt.err != "" {
|
||||
assert.ErrorContains(t, tt.err, err)
|
||||
}
|
||||
})
|
||||
@@ -1121,7 +1121,7 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
km := genMockKeymanager(t, 10)
|
||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||
keys, err := km.FetchValidatingPublicKeys(t.Context())
|
||||
assert.NoError(t, err)
|
||||
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||
|
||||
@@ -1129,13 +1129,13 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
||||
att := createAttestation(10, 14)
|
||||
rt, err := att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(context.Background(), k, rt, att))
|
||||
assert.NoError(t, db.SaveAttestationForPubKey(t.Context(), k, rt, att))
|
||||
|
||||
att = createAttestation(6, 8)
|
||||
rt, err = att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = db.SaveAttestationForPubKey(context.Background(), k, rt, att)
|
||||
err = db.SaveAttestationForPubKey(t.Context(), k, rt, att)
|
||||
if isSlashingProtectionMinimal {
|
||||
assert.ErrorContains(t, "could not sign attestation with source lower than recorded source epoch", err)
|
||||
} else {
|
||||
@@ -1146,7 +1146,7 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
||||
rt, err = att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = db.SaveAttestationForPubKey(context.Background(), k, rt, att)
|
||||
err = db.SaveAttestationForPubKey(t.Context(), k, rt, att)
|
||||
if isSlashingProtectionMinimal {
|
||||
assert.ErrorContains(t, "could not sign attestation with target lower than or equal to recorded target epoch", err)
|
||||
} else {
|
||||
@@ -1157,7 +1157,7 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
||||
rt, err = att.Data.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = db.SaveAttestationForPubKey(context.Background(), k, rt, att)
|
||||
err = db.SaveAttestationForPubKey(t.Context(), k, rt, att)
|
||||
if isSlashingProtectionMinimal {
|
||||
assert.ErrorContains(t, "could not sign attestation with source lower than recorded source epoch", err)
|
||||
} else {
|
||||
@@ -1202,7 +1202,7 @@ func TestIsSyncCommitteeAggregator_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{}, nil /*err*/)
|
||||
|
||||
aggregator, err := v.isSyncCommitteeAggregator(context.Background(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
aggregator, err := v.isSyncCommitteeAggregator(t.Context(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
0: bytesutil.ToBytes48(pubKey),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1225,7 +1225,7 @@ func TestIsSyncCommitteeAggregator_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{Indices: []primitives.CommitteeIndex{0}}, nil /*err*/)
|
||||
|
||||
aggregator, err = v.isSyncCommitteeAggregator(context.Background(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
aggregator, err = v.isSyncCommitteeAggregator(t.Context(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
0: bytesutil.ToBytes48(pubKey),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1253,7 +1253,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{}, nil /*err*/)
|
||||
|
||||
aggregator, err := v.isSyncCommitteeAggregator(context.Background(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
aggregator, err := v.isSyncCommitteeAggregator(t.Context(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
0: bytesutil.ToBytes48(pubKey),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1276,7 +1276,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
},
|
||||
).Return(ðpb.SyncSubcommitteeIndexResponse{Indices: []primitives.CommitteeIndex{0}}, nil /*err*/)
|
||||
|
||||
sig, err := v.signSyncSelectionData(context.Background(), bytesutil.ToBytes48(pubKey), 0, slot)
|
||||
sig, err := v.signSyncSelectionData(t.Context(), bytesutil.ToBytes48(pubKey), 0, slot)
|
||||
require.NoError(t, err)
|
||||
|
||||
selection := iface.SyncCommitteeSelection{
|
||||
@@ -1290,7 +1290,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
[]iface.SyncCommitteeSelection{selection},
|
||||
).Return([]iface.SyncCommitteeSelection{selection}, nil)
|
||||
|
||||
aggregator, err = v.isSyncCommitteeAggregator(context.Background(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
aggregator, err = v.isSyncCommitteeAggregator(t.Context(), slot, map[primitives.ValidatorIndex][fieldparams.BLSPubkeyLength]byte{
|
||||
123: bytesutil.ToBytes48(pubKey),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1302,7 +1302,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
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()
|
||||
ctx := t.Context()
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
@@ -1323,7 +1323,7 @@ func TestValidator_WaitForKeymanagerInitialization_web3Signer(t *testing.T) {
|
||||
ProvidedPublicKeys: []string{"0xa2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820"},
|
||||
},
|
||||
}
|
||||
err = v.WaitForKeymanagerInitialization(context.Background())
|
||||
err = v.WaitForKeymanagerInitialization(t.Context())
|
||||
require.NoError(t, err)
|
||||
km, err := v.Keymanager()
|
||||
require.NoError(t, err)
|
||||
@@ -1335,7 +1335,7 @@ func TestValidator_WaitForKeymanagerInitialization_web3Signer(t *testing.T) {
|
||||
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()
|
||||
ctx := t.Context()
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
@@ -1369,7 +1369,7 @@ func TestValidator_WaitForKeymanagerInitialization_Web(t *testing.T) {
|
||||
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()
|
||||
ctx := t.Context()
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
root := make([]byte, 32)
|
||||
copy(root[2:], "a")
|
||||
@@ -1429,7 +1429,7 @@ func (m *PrepareBeaconProposerRequestMatcher) String() string {
|
||||
func TestValidator_PushSettings(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
ctrl := gomock.NewController(t)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
@@ -1510,7 +1510,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1601,7 +1601,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1683,7 +1683,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9"),
|
||||
},
|
||||
}
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1726,7 +1726,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
keys, err := km.FetchValidatingPublicKeys(ctx)
|
||||
require.NoError(t, err)
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: nil,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1792,7 +1792,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
}
|
||||
err := v.WaitForKeymanagerInitialization(ctx)
|
||||
require.NoError(t, err)
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: nil,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1889,7 +1889,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
FeeRecipient: common.Address{},
|
||||
},
|
||||
}
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1936,7 +1936,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
PublicKeys: [][]byte{keys[0][:]},
|
||||
Indices: []primitives.ValidatorIndex{unknownIndex},
|
||||
}, nil)
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -1993,7 +1993,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
err = v.SetProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = v.SetProposerSettings(t.Context(), &proposer.Settings{
|
||||
ProposeConfig: config,
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@@ -2112,7 +2112,7 @@ func TestValidator_buildPrepProposerReqs_WithoutDefaultConfig(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
client.EXPECT().MultipleValidatorStatus(
|
||||
@@ -2201,7 +2201,7 @@ func TestValidator_filterAndCacheActiveKeys(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
client.EXPECT().MultipleValidatorStatus(
|
||||
@@ -2225,7 +2225,7 @@ func TestValidator_filterAndCacheActiveKeys(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
client.EXPECT().MultipleValidatorStatus(
|
||||
@@ -2267,7 +2267,7 @@ func TestValidator_filterAndCacheActiveKeys(t *testing.T) {
|
||||
require.Equal(t, 3, len(keys))
|
||||
})
|
||||
t.Run("cache used mid epoch, no new keys added", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
v := validator{
|
||||
pubkeyToStatus: map[[48]byte]*validatorStatus{
|
||||
pubkey1: {
|
||||
@@ -2354,7 +2354,7 @@ func TestValidator_buildPrepProposerReqs_WithDefaultConfig(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
client.EXPECT().MultipleValidatorStatus(
|
||||
@@ -2511,7 +2511,7 @@ func TestValidator_buildSignedRegReqs_DefaultConfigDisabled(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
signature := blsmock.NewMockSignature(ctrl)
|
||||
@@ -2611,7 +2611,7 @@ func TestValidator_buildSignedRegReqs_DefaultConfigEnabled(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
signature := blsmock.NewMockSignature(ctrl)
|
||||
@@ -2723,7 +2723,7 @@ func TestValidator_buildSignedRegReqs_SignerOnError(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
v := validator{
|
||||
@@ -2764,7 +2764,7 @@ func TestValidator_buildSignedRegReqs_TimestampBeforeGenesis(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
signature := blsmock.NewMockSignature(ctrl)
|
||||
@@ -2845,7 +2845,7 @@ func TestValidator_ChangeHost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateValidatorStatusCache(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
pubkeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
@@ -2913,7 +2913,7 @@ func TestValidator_CheckDependentRoots(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
v := &validator{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -37,7 +36,7 @@ func TestWaitActivation_Exiting_OK(t *testing.T) {
|
||||
prysmChainClient: prysmChainClient,
|
||||
accountsChangedChannel: make(chan [][fieldparams.BLSPubkeyLength]byte, 1),
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
resp := testutil.GenerateMultipleValidatorStatusResponse([][]byte{kp.pub[:]})
|
||||
resp.Statuses[0].Status = ethpb.ValidatorStatus_EXITING
|
||||
validatorClient.EXPECT().MultipleValidatorStatus(
|
||||
@@ -97,7 +96,7 @@ func TestWaitForActivation_RefetchKeys(t *testing.T) {
|
||||
require.NoError(t, km.add(kp))
|
||||
km.SimulateAccountChanges([][48]byte{kp.pub})
|
||||
}()
|
||||
assert.NoError(t, v.WaitForActivation(context.Background()), "Could not wait for activation")
|
||||
assert.NoError(t, v.WaitForActivation(t.Context()), "Could not wait for activation")
|
||||
assert.LogsContain(t, hook, msgNoKeysFetched)
|
||||
assert.LogsContain(t, hook, "Validator activated")
|
||||
}
|
||||
@@ -159,7 +158,7 @@ func TestWaitForActivation_AccountsChanged(t *testing.T) {
|
||||
ðpb.ChainHead{HeadEpoch: 0},
|
||||
nil,
|
||||
).AnyTimes()
|
||||
assert.NoError(t, v.WaitForActivation(context.Background()))
|
||||
assert.NoError(t, v.WaitForActivation(t.Context()))
|
||||
assert.LogsContain(t, hook, "Waiting for deposit to be observed by beacon node")
|
||||
assert.LogsContain(t, hook, "Validator activated")
|
||||
})
|
||||
@@ -181,7 +180,7 @@ func TestWaitForActivation_AccountsChanged(t *testing.T) {
|
||||
AccountPasswords: make(map[string]string),
|
||||
WalletPassword: "secretPassw0rd$1999",
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
km, err := derived.NewKeymanager(ctx, &derived.SetupConfig{
|
||||
Wallet: wallet,
|
||||
ListenForChanges: true,
|
||||
@@ -238,7 +237,7 @@ func TestWaitForActivation_AccountsChanged(t *testing.T) {
|
||||
ðpb.ChainHead{HeadEpoch: 0},
|
||||
nil,
|
||||
).AnyTimes()
|
||||
assert.NoError(t, v.WaitForActivation(context.Background()))
|
||||
assert.NoError(t, v.WaitForActivation(t.Context()))
|
||||
assert.LogsContain(t, hook, "Waiting for deposit to be observed by beacon node")
|
||||
assert.LogsContain(t, hook, "Validator activated")
|
||||
})
|
||||
@@ -283,5 +282,5 @@ func TestWaitForActivation_AttemptsReconnectionOnFailure(t *testing.T) {
|
||||
ðpb.ChainHead{HeadEpoch: 0},
|
||||
nil,
|
||||
).AnyTimes()
|
||||
assert.NoError(t, v.WaitForActivation(context.Background()))
|
||||
assert.NoError(t, v.WaitForActivation(t.Context()))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -36,7 +35,7 @@ func getFeeRecipientFromString(t *testing.T, feeRecipientString string) [fieldpa
|
||||
}
|
||||
|
||||
func TestDB_ConvertDatabase(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
pubKeyString1 := "0x80000060606fa05c7339dd7bcd0d3e4d8b573fa30dea2fdb4997031a703e3300326e3c054be682f92d9c367cd647bbea"
|
||||
pubKeyString2 := "0x81000060606fa05c7339dd7bcd0d3e4d8b573fa30dea2fdb4997031a703e3300326e3c054be682f92d9c367cd647bbea"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -19,7 +18,7 @@ func TestStore_EIPImportBlacklistedPublicKeys(t *testing.T) {
|
||||
require.NoError(t, err, "could not create store")
|
||||
|
||||
var expected = [][fieldparams.BLSPubkeyLength]byte{}
|
||||
actual, err := store.EIPImportBlacklistedPublicKeys(context.Background())
|
||||
actual, err := store.EIPImportBlacklistedPublicKeys(t.Context())
|
||||
require.NoError(t, err, "could not get blacklisted public keys")
|
||||
require.DeepSSZEqual(t, expected, actual, "blacklisted public keys do not match")
|
||||
}
|
||||
@@ -30,7 +29,7 @@ func TestStore_SaveEIPImportBlacklistedPublicKeys(t *testing.T) {
|
||||
require.NoError(t, err, "could not create store")
|
||||
|
||||
// Save blacklisted public keys.
|
||||
err = store.SaveEIPImportBlacklistedPublicKeys(context.Background(), [][fieldparams.BLSPubkeyLength]byte{})
|
||||
err = store.SaveEIPImportBlacklistedPublicKeys(t.Context(), [][fieldparams.BLSPubkeyLength]byte{})
|
||||
require.NoError(t, err, "could not save blacklisted public keys")
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ func TestStore_LowestSignedTargetEpoch(t *testing.T) {
|
||||
require.NoError(t, err, "could not create store")
|
||||
|
||||
// Get the lowest signed target epoch.
|
||||
_, exists, err := store.LowestSignedTargetEpoch(context.Background(), [fieldparams.BLSPubkeyLength]byte{})
|
||||
_, exists, err := store.LowestSignedTargetEpoch(t.Context(), [fieldparams.BLSPubkeyLength]byte{})
|
||||
require.NoError(t, err, "could not get lowest signed target epoch")
|
||||
require.Equal(t, false, exists, "lowest signed target epoch should not exist")
|
||||
|
||||
@@ -59,12 +58,12 @@ func TestStore_LowestSignedTargetEpoch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Save the attestation.
|
||||
err = store.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, attestation)
|
||||
err = store.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, attestation)
|
||||
require.NoError(t, err, "SaveAttestationForPubKey should not return an error")
|
||||
|
||||
// Get the lowest signed target epoch.
|
||||
expected := primitives.Epoch(savedTargetEpoch)
|
||||
actual, exists, err := store.LowestSignedTargetEpoch(context.Background(), pubkey)
|
||||
actual, exists, err := store.LowestSignedTargetEpoch(t.Context(), pubkey)
|
||||
require.NoError(t, err, "could not get lowest signed target epoch")
|
||||
require.Equal(t, true, exists, "lowest signed target epoch should not exist")
|
||||
require.Equal(t, expected, actual, "lowest signed target epoch should match")
|
||||
@@ -79,7 +78,7 @@ func TestStore_LowestSignedSourceEpoch(t *testing.T) {
|
||||
require.NoError(t, err, "could not create store")
|
||||
|
||||
// Get the lowest signed target epoch.
|
||||
_, exists, err := store.LowestSignedSourceEpoch(context.Background(), [fieldparams.BLSPubkeyLength]byte{})
|
||||
_, exists, err := store.LowestSignedSourceEpoch(t.Context(), [fieldparams.BLSPubkeyLength]byte{})
|
||||
require.NoError(t, err, "could not get lowest signed source epoch")
|
||||
require.Equal(t, false, exists, "lowest signed source epoch should not exist")
|
||||
|
||||
@@ -93,12 +92,12 @@ func TestStore_LowestSignedSourceEpoch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Save the attestation.
|
||||
err = store.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, attestation)
|
||||
err = store.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, attestation)
|
||||
require.NoError(t, err, "SaveAttestationForPubKey should not return an error")
|
||||
|
||||
// Get the lowest signed target epoch.
|
||||
expected := primitives.Epoch(savedSourceEpoch)
|
||||
actual, exists, err := store.LowestSignedSourceEpoch(context.Background(), pubkey)
|
||||
actual, exists, err := store.LowestSignedSourceEpoch(t.Context(), pubkey)
|
||||
require.NoError(t, err, "could not get lowest signed target epoch")
|
||||
require.Equal(t, true, exists, "lowest signed target epoch should exist")
|
||||
require.Equal(t, expected, actual, "lowest signed target epoch should match")
|
||||
@@ -118,7 +117,7 @@ func TestStore_AttestedPublicKeys(t *testing.T) {
|
||||
// Attest for some pubkeys.
|
||||
attestedPubkeys := pubkeys[1:3]
|
||||
for _, pubkey := range attestedPubkeys {
|
||||
err = s.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, ðpb.IndexedAttestation{
|
||||
err = s.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 42},
|
||||
Target: ðpb.Checkpoint{Epoch: 43},
|
||||
@@ -128,7 +127,7 @@ func TestStore_AttestedPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
// Check the public keys.
|
||||
actual, err := s.AttestedPublicKeys(context.Background())
|
||||
actual, err := s.AttestedPublicKeys(t.Context())
|
||||
require.NoError(t, err, "publicKeys should not return an error")
|
||||
|
||||
// We cannot compare the slices directly because the order is not guaranteed,
|
||||
@@ -276,13 +275,13 @@ func TestStore_SaveAttestationForPubKey(t *testing.T) {
|
||||
|
||||
if tt.existingAttInDB != nil {
|
||||
// Simulate an already existing slashing protection.
|
||||
err = store.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, tt.existingAttInDB)
|
||||
err = store.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, tt.existingAttInDB)
|
||||
require.NoError(t, err, "failed to save attestation when simulating an already existing slashing protection")
|
||||
}
|
||||
|
||||
if tt.incomingAtt != nil {
|
||||
// Attempt to save a new attestation.
|
||||
err = store.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, tt.incomingAtt)
|
||||
err = store.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, tt.incomingAtt)
|
||||
if len(tt.expectedErr) > 0 {
|
||||
require.ErrorContains(t, tt.expectedErr, err)
|
||||
} else {
|
||||
@@ -299,7 +298,7 @@ func pointerFromInt(i uint64) *uint64 {
|
||||
|
||||
func TestStore_SaveAttestationsForPubKey2(t *testing.T) {
|
||||
// Get the context.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Create a public key.
|
||||
pubkey := getPubKeys(t, 1)[0]
|
||||
@@ -430,7 +429,7 @@ func TestStore_AttestationHistoryForPubKey(t *testing.T) {
|
||||
require.NoError(t, err, "NewStore should not return an error")
|
||||
|
||||
// Get the attestation history.
|
||||
actual, err := store.AttestationHistoryForPubKey(context.Background(), pubkey)
|
||||
actual, err := store.AttestationHistoryForPubKey(t.Context(), pubkey)
|
||||
require.NoError(t, err, "AttestationHistoryForPubKey should not return an error")
|
||||
require.DeepEqual(t, []*common.AttestationRecord{}, actual)
|
||||
|
||||
@@ -444,7 +443,7 @@ func TestStore_AttestationHistoryForPubKey(t *testing.T) {
|
||||
}
|
||||
|
||||
// Save the attestation.
|
||||
err = store.SaveAttestationForPubKey(context.Background(), pubkey, [32]byte{}, attestation)
|
||||
err = store.SaveAttestationForPubKey(t.Context(), pubkey, [32]byte{}, attestation)
|
||||
require.NoError(t, err, "SaveAttestationForPubKey should not return an error")
|
||||
|
||||
// Get the attestation history.
|
||||
@@ -456,14 +455,14 @@ func TestStore_AttestationHistoryForPubKey(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
actual, err = store.AttestationHistoryForPubKey(context.Background(), pubkey)
|
||||
actual, err = store.AttestationHistoryForPubKey(t.Context(), pubkey)
|
||||
require.NoError(t, err, "AttestationHistoryForPubKey should not return an error")
|
||||
require.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func BenchmarkStore_SaveAttestationForPubKey(b *testing.B) {
|
||||
var wg sync.WaitGroup
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
// Create pubkeys
|
||||
pubkeys := make([][fieldparams.BLSPubkeyLength]byte, 2000)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -106,7 +105,7 @@ func TestStore_Backup(t *testing.T) {
|
||||
require.NoError(t, err, "NewStore should not return an error")
|
||||
|
||||
// Update the proposer settings.
|
||||
err = s.SaveProposerSettings(context.Background(), &proposer.Settings{
|
||||
err = s.SaveProposerSettings(t.Context(), &proposer.Settings{
|
||||
DefaultConfig: &proposer.Option{
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
FeeRecipient: common.Address{},
|
||||
@@ -116,7 +115,7 @@ func TestStore_Backup(t *testing.T) {
|
||||
require.NoError(t, err, "SaveProposerSettings should not return an error")
|
||||
|
||||
// Backup the DB.
|
||||
require.NoError(t, s.Backup(context.Background(), backupsPath, true), "Backup should not return an error")
|
||||
require.NoError(t, s.Backup(t.Context(), backupsPath, true), "Backup should not return an error")
|
||||
|
||||
// Get the directory path of the backup.
|
||||
files, err := os.ReadDir(path.Join(backupsPath, backupsDirectoryName))
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
)
|
||||
|
||||
func TestStore_GenesisValidatorsRoot(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
genesisValidatorRootString := "0x0100"
|
||||
genesisValidatorRootBytes := []byte{1, 0}
|
||||
@@ -52,7 +51,7 @@ func TestStore_GenesisValidatorsRoot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_SaveGenesisValidatorsRoot(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
genesisValidatorRootString := "0x0100"
|
||||
|
||||
for _, tt := range []struct {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -29,7 +28,7 @@ func TestStore_SaveGraffitiOrderedIndex(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Save graffiti ordered index.
|
||||
err = store.SaveGraffitiOrderedIndex(context.Background(), graffitiOrderedIndex)
|
||||
err = store.SaveGraffitiOrderedIndex(t.Context(), graffitiOrderedIndex)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
@@ -87,7 +86,7 @@ func TestStore_GraffitiOrderedIndex(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Get graffiti ordered index.
|
||||
actualGraffitiOrderedIndex, err := store.GraffitiOrderedIndex(context.Background(), tt.fileHash)
|
||||
actualGraffitiOrderedIndex, err := store.GraffitiOrderedIndex(t.Context(), tt.fileHash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tt.expectedGraffitiOrderedIndex, actualGraffitiOrderedIndex)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,6 @@ package filesystem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -24,7 +23,7 @@ func TestStore_ImportInterchangeData_BadJSON(t *testing.T) {
|
||||
require.NoError(t, err, "NewStore should not return an error")
|
||||
|
||||
buf := bytes.NewBuffer([]byte("helloworld"))
|
||||
err = s.ImportStandardProtectionJSON(context.Background(), buf)
|
||||
err = s.ImportStandardProtectionJSON(t.Context(), buf)
|
||||
require.ErrorContains(t, "could not unmarshal slashing protection JSON file", err)
|
||||
}
|
||||
|
||||
@@ -41,12 +40,12 @@ func TestStore_ImportInterchangeData_NilData_FailsSilently(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
buf := bytes.NewBuffer(encoded)
|
||||
err = s.ImportStandardProtectionJSON(context.Background(), buf)
|
||||
err = s.ImportStandardProtectionJSON(t.Context(), buf)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestStore_ImportInterchangeData_BadFormat_PreventsDBWrites(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 10
|
||||
publicKeys, err := valtest.CreateRandomPubKeys(numValidators)
|
||||
require.NoError(t, err)
|
||||
@@ -94,7 +93,7 @@ func TestStore_ImportInterchangeData_BadFormat_PreventsDBWrites(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_ImportInterchangeData_OK(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 10
|
||||
publicKeys, err := valtest.CreateRandomPubKeys(numValidators)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
@@ -13,7 +12,7 @@ func TestStore_RunUpMigrations(t *testing.T) {
|
||||
require.NoError(t, err, "NewStore should not return an error")
|
||||
|
||||
// Just check `RunUpMigrations` does not return an error.
|
||||
err = store.RunUpMigrations(context.Background())
|
||||
err = store.RunUpMigrations(t.Context())
|
||||
require.NoError(t, err, "RunUpMigrations should not return an error")
|
||||
}
|
||||
|
||||
@@ -23,6 +22,6 @@ func TestStore_RunDownMigrations(t *testing.T) {
|
||||
require.NoError(t, err, "NewStore should not return an error")
|
||||
|
||||
// Just check `RunDownMigrations` does not return an error.
|
||||
err = store.RunDownMigrations(context.Background())
|
||||
err = store.RunDownMigrations(t.Context())
|
||||
require.NoError(t, err, "RunUpMigrations should not return an error")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
|
||||
func TestStore_ProposalHistoryForPubKey(t *testing.T) {
|
||||
var slot uint64 = 42
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
@@ -73,7 +72,7 @@ func TestStore_SaveProposalHistoryForSlot(t *testing.T) {
|
||||
slot43 uint64 = 43
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
@@ -164,7 +163,7 @@ func TestStore_ProposedPublicKeys(t *testing.T) {
|
||||
|
||||
// We check the public keys
|
||||
expected := pubkeys
|
||||
actual, err := s.ProposedPublicKeys(context.Background())
|
||||
actual, err := s.ProposedPublicKeys(t.Context())
|
||||
require.NoError(t, err, "publicKeys should not return an error")
|
||||
|
||||
// We cannot compare the slices directly because the order is not guaranteed,
|
||||
@@ -183,7 +182,7 @@ func TestStore_ProposedPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We get a database path
|
||||
databasePath := t.TempDir()
|
||||
@@ -214,7 +213,7 @@ func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
}
|
||||
wsb, err := blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// We expect the same block with a slot equal to the lowest
|
||||
@@ -229,14 +228,14 @@ func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
}
|
||||
wsb, err = blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, wsb, [32]byte{1}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, wsb, [32]byte{1}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// We expect the same block with a slot equal to the lowest
|
||||
// signed slot to fail validation if signing roots are different.
|
||||
wsb, err = blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// We expect the same block with a slot > than the lowest
|
||||
@@ -252,12 +251,12 @@ func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
|
||||
wsb, err = blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, wsb, [32]byte{3}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, wsb, [32]byte{3}, false, nil)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_slashableProposalCheck(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We get a database path
|
||||
databasePath := t.TempDir()
|
||||
@@ -291,11 +290,11 @@ func Test_slashableProposalCheck(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// We expect the same block sent out should be slasahble.
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, sBlock, dummySigningRoot, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, sBlock, dummySigningRoot, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// We expect the same block sent out with a different signing root should be slashable.
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// We save a proposal at slot 11 with a nil signing root.
|
||||
@@ -307,7 +306,7 @@ func Test_slashableProposalCheck(t *testing.T) {
|
||||
|
||||
// We expect the same block sent out should return slashable error even
|
||||
// if we had a nil signing root stored in the database.
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
|
||||
// A block with a different slot for which we do not have a proposing history
|
||||
@@ -315,7 +314,7 @@ func Test_slashableProposalCheck(t *testing.T) {
|
||||
blk.Block.Slot = 9
|
||||
sBlock, err = blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, sBlock, [32]byte{3}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, sBlock, [32]byte{3}, false, nil)
|
||||
require.ErrorContains(t, common.FailedBlockSignLocalErr, err)
|
||||
}
|
||||
|
||||
@@ -336,6 +335,6 @@ func Test_slashableProposalCheck_RemoteProtection(t *testing.T) {
|
||||
sBlock, err := blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = s.SlashableProposalCheck(context.Background(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
err = s.SlashableProposalCheck(t.Context(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
require.NoError(t, err, "Expected allowed block not to throw error")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -28,7 +27,7 @@ func getFeeRecipientFromString(t *testing.T, feeRecipientString string) [fieldpa
|
||||
}
|
||||
|
||||
func TestStore_ProposerSettings(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
pubkeyString := "0xb3533c600c6c22aa5177f295667deacffde243980d3c04da4057ab0941dcca1dff83ae8e6534bedd2d23d83446e604d6"
|
||||
customFeeRecipientString := "0xd4E96eF8eee8678dBFf4d535E033Ed1a4F7605b7"
|
||||
@@ -110,7 +109,7 @@ func TestStore_ProposerSettings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_ProposerSettingsExists(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
@@ -151,7 +150,7 @@ func TestStore_ProposerSettingsExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_SaveProposerSettings(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
preExistingFeeRecipientString := "0xD871172AE08B5FC37B3AC3D445225928DE883876"
|
||||
incomingFeeRecipientString := "0xC771172AE08B5FC37B3AC3D445225928DE883876"
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestPendingAttestationRecords_Len(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_CheckSlashableAttestation_DoubleVote(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 1
|
||||
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
validatorDB := setupDB(t, pubKeys)
|
||||
@@ -116,7 +116,7 @@ func TestStore_CheckSlashableAttestation_DoubleVote(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_CheckSlashableAttestation_SurroundVote_MultipleTargetsPerSource(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 1
|
||||
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
validatorDB := setupDB(t, pubKeys)
|
||||
@@ -141,7 +141,7 @@ func TestStore_CheckSlashableAttestation_SurroundVote_MultipleTargetsPerSource(t
|
||||
}
|
||||
|
||||
func TestStore_CheckSlashableAttestation_SurroundVote_54kEpochs(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 1
|
||||
numEpochs := primitives.Epoch(54000)
|
||||
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
@@ -214,7 +214,7 @@ func TestStore_CheckSlashableAttestation_SurroundVote_54kEpochs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLowestSignedSourceEpoch_SaveRetrieve(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB, err := NewKVStore(ctx, t.TempDir(), &Config{})
|
||||
require.NoError(t, err, "Failed to instantiate DB")
|
||||
t.Cleanup(func() {
|
||||
@@ -273,7 +273,7 @@ func TestLowestSignedSourceEpoch_SaveRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLowestSignedTargetEpoch_SaveRetrieveReplace(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB, err := NewKVStore(ctx, t.TempDir(), &Config{})
|
||||
require.NoError(t, err, "Failed to instantiate DB")
|
||||
t.Cleanup(func() {
|
||||
@@ -332,7 +332,7 @@ func TestLowestSignedTargetEpoch_SaveRetrieveReplace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_SaveAttestationsForPubKey(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 1
|
||||
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
validatorDB := setupDB(t, pubKeys)
|
||||
@@ -373,7 +373,7 @@ func TestStore_SaveAttestationsForPubKey(t *testing.T) {
|
||||
|
||||
func TestSaveAttestationForPubKey_BatchWrites_FullCapacity(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
numValidators := attestationBatchCapacity
|
||||
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
@@ -426,7 +426,7 @@ func TestSaveAttestationForPubKey_BatchWrites_FullCapacity(t *testing.T) {
|
||||
|
||||
func TestSaveAttestationForPubKey_BatchWrites_LowCapacity_TimerReached(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
// Number of validators equal to half the total capacity
|
||||
// of batch attestation processing. This will allow us to
|
||||
@@ -501,7 +501,7 @@ func benchCheckSurroundVote(
|
||||
numEpochs primitives.Epoch,
|
||||
shouldSurround bool,
|
||||
) {
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
validatorDB, err := NewKVStore(ctx, filepath.Join(b.TempDir(), "benchsurroundvote"), &Config{
|
||||
PubKeys: pubKeys,
|
||||
})
|
||||
@@ -562,13 +562,13 @@ func TestStore_flushAttestationRecords_InProgress(t *testing.T) {
|
||||
s.batchedAttestationsFlushInProgress.Set()
|
||||
|
||||
hook := logTest.NewGlobal()
|
||||
s.flushAttestationRecords(context.Background(), nil)
|
||||
s.flushAttestationRecords(t.Context(), nil)
|
||||
assert.LogsContain(t, hook, "Attempted to flush attestation records when already in progress")
|
||||
}
|
||||
|
||||
func BenchmarkStore_SaveAttestationForPubKey(b *testing.B) {
|
||||
var wg sync.WaitGroup
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
// Create pubkeys
|
||||
pubkeys := make([][fieldparams.BLSPubkeyLength]byte, 10)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -14,7 +13,7 @@ import (
|
||||
|
||||
func TestStore_Backup(t *testing.T) {
|
||||
db := setupDB(t, nil)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root := [32]byte{1}
|
||||
require.NoError(t, db.SaveGenesisValidatorsRoot(ctx, root[:]))
|
||||
require.NoError(t, db.Backup(ctx, "", true))
|
||||
@@ -44,7 +43,7 @@ func TestStore_Backup(t *testing.T) {
|
||||
func TestStore_NestedBackup(t *testing.T) {
|
||||
keys := [][fieldparams.BLSPubkeyLength]byte{{'A'}, {'B'}}
|
||||
db := setupDB(t, keys)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root := [32]byte{1}
|
||||
idxAtt := ðpb.IndexedAttestation{
|
||||
AttestingIndices: nil,
|
||||
@@ -64,8 +63,8 @@ func TestStore_NestedBackup(t *testing.T) {
|
||||
Signature: make([]byte, 96),
|
||||
}
|
||||
require.NoError(t, db.SaveGenesisValidatorsRoot(ctx, root[:]))
|
||||
require.NoError(t, db.SaveAttestationForPubKey(context.Background(), keys[0], [32]byte{'C'}, idxAtt))
|
||||
require.NoError(t, db.SaveAttestationForPubKey(context.Background(), keys[1], [32]byte{'C'}, idxAtt))
|
||||
require.NoError(t, db.SaveAttestationForPubKey(t.Context(), keys[0], [32]byte{'C'}, idxAtt))
|
||||
require.NoError(t, db.SaveAttestationForPubKey(t.Context(), keys[1], [32]byte{'C'}, idxAtt))
|
||||
require.NoError(t, db.Backup(ctx, "", true))
|
||||
|
||||
backupsPath := filepath.Join(db.databasePath, backupsDirectoryName)
|
||||
@@ -91,7 +90,7 @@ func TestStore_NestedBackup(t *testing.T) {
|
||||
|
||||
signingRoot32 := [32]byte{'C'}
|
||||
|
||||
hist, err := backedDB.AttestationHistoryForPubKey(context.Background(), keys[0])
|
||||
hist, err := backedDB.AttestationHistoryForPubKey(t.Context(), keys[0])
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, &common.AttestationRecord{
|
||||
PubKey: keys[0],
|
||||
@@ -100,7 +99,7 @@ func TestStore_NestedBackup(t *testing.T) {
|
||||
SigningRoot: signingRoot32[:],
|
||||
}, hist[0])
|
||||
|
||||
hist, err = backedDB.AttestationHistoryForPubKey(context.Background(), keys[1])
|
||||
hist, err = backedDB.AttestationHistoryForPubKey(t.Context(), keys[1])
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, &common.AttestationRecord{
|
||||
PubKey: keys[1],
|
||||
@@ -109,12 +108,12 @@ func TestStore_NestedBackup(t *testing.T) {
|
||||
SigningRoot: signingRoot32[:],
|
||||
}, hist[0])
|
||||
|
||||
ep, exists, err := backedDB.LowestSignedSourceEpoch(context.Background(), keys[0])
|
||||
ep, exists, err := backedDB.LowestSignedSourceEpoch(t.Context(), keys[0])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, 10, int(ep))
|
||||
|
||||
ep, exists, err = backedDB.LowestSignedSourceEpoch(context.Background(), keys[1])
|
||||
ep, exists, err = backedDB.LowestSignedSourceEpoch(t.Context(), keys[1])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, exists)
|
||||
require.Equal(t, 10, int(ep))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -11,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStore_EIPBlacklistedPublicKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 100
|
||||
publicKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
|
||||
for i := 0; i < numValidators; i++ {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStore_GenesisValidatorsRoot_ReadAndWrite(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStore_GraffitiOrderedIndex_ReadAndWrite(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -60,7 +59,7 @@ func TestStore_GraffitiOrderedIndex_ReadAndWrite(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_GraffitiFileHash(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Creates database
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
|
||||
@@ -2,7 +2,6 @@ package kv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
@@ -20,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStore_ImportInterchangeData_BadJSON(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB := setupDB(t, nil)
|
||||
|
||||
buf := bytes.NewBuffer([]byte("helloworld"))
|
||||
@@ -30,7 +29,7 @@ func TestStore_ImportInterchangeData_BadJSON(t *testing.T) {
|
||||
|
||||
func TestStore_ImportInterchangeData_NilData_FailsSilently(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB := setupDB(t, nil)
|
||||
|
||||
interchangeJSON := &format.EIPSlashingProtectionFormat{}
|
||||
@@ -44,7 +43,7 @@ func TestStore_ImportInterchangeData_NilData_FailsSilently(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_ImportInterchangeData_BadFormat_PreventsDBWrites(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 10
|
||||
publicKeys, err := valtest.CreateRandomPubKeys(numValidators)
|
||||
require.NoError(t, err)
|
||||
@@ -104,7 +103,7 @@ func TestStore_ImportInterchangeData_BadFormat_PreventsDBWrites(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_ImportInterchangeData_OK(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numValidators := 10
|
||||
publicKeys, err := valtest.CreateRandomPubKeys(numValidators)
|
||||
require.NoError(t, err)
|
||||
@@ -775,14 +774,14 @@ func Test_filterSlashablePubKeysFromBlocks(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
historyByPubKey := make(map[[fieldparams.BLSPubkeyLength]byte]common.ProposalHistoryForPubkey)
|
||||
for pubKey, signedBlocks := range tt.given {
|
||||
proposalHistory, err := transformSignedBlocks(ctx, signedBlocks)
|
||||
require.NoError(t, err)
|
||||
historyByPubKey[pubKey] = *proposalHistory
|
||||
}
|
||||
slashablePubKeys := filterSlashablePubKeysFromBlocks(context.Background(), historyByPubKey)
|
||||
slashablePubKeys := filterSlashablePubKeysFromBlocks(t.Context(), historyByPubKey)
|
||||
wantedPubKeys := make(map[[fieldparams.BLSPubkeyLength]byte]bool)
|
||||
for _, pk := range tt.expected {
|
||||
wantedPubKeys[pk] = true
|
||||
@@ -798,7 +797,7 @@ func Test_filterSlashablePubKeysFromBlocks(t *testing.T) {
|
||||
|
||||
func Test_filterSlashablePubKeysFromAttestations(t *testing.T) {
|
||||
// filterSlashablePubKeysFromAttestations is used only for complete slashing protection.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
tests := []struct {
|
||||
name string
|
||||
previousAttsByPubKey map[[fieldparams.BLSPubkeyLength]byte][]*format.SignedAttestation
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -20,7 +19,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
// setupDB instantiates and returns a DB instance for the validator client.
|
||||
func setupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte) *Store {
|
||||
db, err := NewKVStore(context.Background(), t.TempDir(), &Config{
|
||||
db, err := NewKVStore(t.Context(), t.TempDir(), &Config{
|
||||
PubKeys: pubkeys,
|
||||
})
|
||||
require.NoError(t, err, "Failed to instantiate DB")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -96,7 +95,7 @@ func Test_migrateOptimalAttesterProtectionUp(t *testing.T) {
|
||||
{
|
||||
name: "partial data saved for both types still completes the migration successfully",
|
||||
setup: func(t *testing.T, validatorDB *Store) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubKey := [fieldparams.BLSPubkeyLength]byte{1}
|
||||
history := newDeprecatedAttestingHistory(0)
|
||||
// Attest all epochs from genesis to 50.
|
||||
@@ -184,7 +183,7 @@ func Test_migrateOptimalAttesterProtectionUp(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
validatorDB := setupDB(t, nil)
|
||||
tt.setup(t, validatorDB)
|
||||
require.NoError(t, validatorDB.migrateOptimalAttesterProtectionUp(context.Background()))
|
||||
require.NoError(t, validatorDB.migrateOptimalAttesterProtectionUp(t.Context()))
|
||||
tt.eval(t, validatorDB)
|
||||
})
|
||||
}
|
||||
@@ -293,7 +292,7 @@ func Test_migrateOptimalAttesterProtectionDown(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
validatorDB := setupDB(t, nil)
|
||||
tt.setup(t, validatorDB)
|
||||
require.NoError(t, validatorDB.migrateOptimalAttesterProtectionDown(context.Background()))
|
||||
require.NoError(t, validatorDB.migrateOptimalAttesterProtectionDown(t.Context()))
|
||||
tt.eval(t, validatorDB)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
@@ -109,7 +108,7 @@ func TestStore_migrateSourceTargetEpochsBucketUp(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
validatorDB := setupDB(t, pubKeys)
|
||||
tt.setup(t, validatorDB)
|
||||
require.NoError(t, validatorDB.migrateSourceTargetEpochsBucketUp(context.Background()))
|
||||
require.NoError(t, validatorDB.migrateSourceTargetEpochsBucketUp(t.Context()))
|
||||
tt.eval(t, validatorDB)
|
||||
})
|
||||
}
|
||||
@@ -204,7 +203,7 @@ func TestStore_migrateSourceTargetEpochsBucketDown(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
validatorDB := setupDB(t, nil)
|
||||
tt.setup(t, validatorDB)
|
||||
require.NoError(t, validatorDB.migrateSourceTargetEpochsBucketDown(context.Background()))
|
||||
require.NoError(t, validatorDB.migrateSourceTargetEpochsBucketDown(t.Context()))
|
||||
tt.eval(t, validatorDB)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -21,7 +20,7 @@ func TestNewProposalHistoryForSlot_ReturnsNilIfNoHistory(t *testing.T) {
|
||||
valPubkey := [fieldparams.BLSPubkeyLength]byte{1, 2, 3}
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), valPubkey, 0)
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(t.Context(), valPubkey, 0)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, proposalExists)
|
||||
assert.Equal(t, false, signingRootExists)
|
||||
@@ -32,7 +31,7 @@ func TestProposalHistoryForSlot_InitializesNewPubKeys(t *testing.T) {
|
||||
db := setupDB(t, pubkeys)
|
||||
|
||||
for _, pub := range pubkeys {
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pub, 0)
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(t.Context(), pub, 0)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, proposalExists)
|
||||
assert.Equal(t, false, signingRootExists)
|
||||
@@ -45,10 +44,10 @@ func TestNewProposalHistoryForSlot_SigningRootNil(t *testing.T) {
|
||||
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
|
||||
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, slot, nil)
|
||||
err := db.SaveProposalHistoryForSlot(t.Context(), pubkey, slot, nil)
|
||||
require.NoError(t, err, "Saving proposal history failed: %v")
|
||||
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pubkey, slot)
|
||||
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(t.Context(), pubkey, slot)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, proposalExists)
|
||||
assert.Equal(t, false, signingRootExists)
|
||||
@@ -60,9 +59,9 @@ func TestSaveProposalHistoryForSlot_OK(t *testing.T) {
|
||||
|
||||
slot := primitives.Slot(2)
|
||||
|
||||
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, slot, []byte{1})
|
||||
err := db.SaveProposalHistoryForSlot(t.Context(), pubkey, slot, []byte{1})
|
||||
require.NoError(t, err, "Saving proposal history failed: %v")
|
||||
signingRoot, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pubkey, slot)
|
||||
signingRoot, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(t.Context(), pubkey, slot)
|
||||
require.NoError(t, err, "Failed to get proposal history")
|
||||
assert.Equal(t, true, proposalExists)
|
||||
assert.Equal(t, true, signingRootExists)
|
||||
@@ -75,7 +74,7 @@ func TestNewProposalHistoryForPubKey_ReturnsEmptyIfNoHistory(t *testing.T) {
|
||||
valPubkey := [fieldparams.BLSPubkeyLength]byte{1, 2, 3}
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(context.Background(), valPubkey)
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(t.Context(), valPubkey)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, make([]*common.Proposal, 0), proposalHistory)
|
||||
}
|
||||
@@ -87,9 +86,9 @@ func TestSaveProposalHistoryForPubKey_OK(t *testing.T) {
|
||||
slot := primitives.Slot(2)
|
||||
|
||||
root := [32]byte{1}
|
||||
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, slot, root[:])
|
||||
err := db.SaveProposalHistoryForSlot(t.Context(), pubkey, slot, root[:])
|
||||
require.NoError(t, err, "Saving proposal history failed: %v")
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(context.Background(), pubkey)
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(t.Context(), pubkey)
|
||||
require.NoError(t, err, "Failed to get proposal history")
|
||||
|
||||
require.NotNil(t, proposalHistory)
|
||||
@@ -120,9 +119,9 @@ func TestSaveProposalHistoryForSlot_Overwrites(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubkey})
|
||||
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, 0, tt.signingRoot)
|
||||
err := db.SaveProposalHistoryForSlot(t.Context(), pubkey, 0, tt.signingRoot)
|
||||
require.NoError(t, err, "Saving proposal history failed")
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(context.Background(), pubkey)
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(t.Context(), pubkey)
|
||||
require.NoError(t, err, "Failed to get proposal history")
|
||||
|
||||
require.NotNil(t, proposalHistory)
|
||||
@@ -176,12 +175,12 @@ func TestPruneProposalHistoryBySlot_OK(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey})
|
||||
for _, slot := range tt.slots {
|
||||
err := db.SaveProposalHistoryForSlot(context.Background(), pubKey, slot, signedRoot)
|
||||
err := db.SaveProposalHistoryForSlot(t.Context(), pubKey, slot, signedRoot)
|
||||
require.NoError(t, err, "Saving proposal history failed")
|
||||
}
|
||||
|
||||
signingRootsBySlot := make(map[primitives.Slot][]byte)
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(context.Background(), pubKey)
|
||||
proposalHistory, err := db.ProposalHistoryForPubKey(t.Context(), pubKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, hist := range proposalHistory {
|
||||
@@ -202,7 +201,7 @@ func TestPruneProposalHistoryBySlot_OK(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_ProposedPublicKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB, err := NewKVStore(ctx, t.TempDir(), &Config{})
|
||||
require.NoError(t, err, "Failed to instantiate DB")
|
||||
t.Cleanup(func() {
|
||||
@@ -225,7 +224,7 @@ func TestStore_ProposedPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_LowestSignedProposal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := [fieldparams.BLSPubkeyLength]byte{3}
|
||||
var dummySigningRoot [32]byte
|
||||
validatorDB := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubkey})
|
||||
@@ -266,7 +265,7 @@ func TestStore_LowestSignedProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_HighestSignedProposal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := [fieldparams.BLSPubkeyLength]byte{3}
|
||||
var dummySigningRoot [32]byte
|
||||
validatorDB := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubkey})
|
||||
@@ -307,7 +306,7 @@ func TestStore_HighestSignedProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
lowestSignedSlot := primitives.Slot(10)
|
||||
|
||||
var pubkey [fieldparams.BLSPubkeyLength]byte
|
||||
@@ -334,7 +333,7 @@ func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
}
|
||||
wsb, err := blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
err = db.SlashableProposalCheck(context.Background(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
err = db.SlashableProposalCheck(t.Context(), pubkey, wsb, [32]byte{4}, false, nil)
|
||||
require.ErrorContains(t, "could not sign block with slot < lowest signed", err)
|
||||
|
||||
// We expect the same block with a slot equal to the lowest
|
||||
@@ -377,7 +376,7 @@ func Test_slashableProposalCheck_PreventsLowerThanMinProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_slashableProposalCheck(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var pubkey [fieldparams.BLSPubkeyLength]byte
|
||||
pubkeyBytes, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
|
||||
@@ -450,6 +449,6 @@ func Test_slashableProposalCheck_RemoteProtection(t *testing.T) {
|
||||
sBlock, err := blocks.NewSignedBeaconBlock(blk)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = db.SlashableProposalCheck(context.Background(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
err = db.SlashableProposalCheck(t.Context(), pubkey, sBlock, [32]byte{2}, false, nil)
|
||||
require.NoError(t, err, "Expected allowed block not to throw error")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
|
||||
func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
t.Run("save to db in full", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
|
||||
require.NoError(t, err)
|
||||
@@ -50,7 +49,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
require.DeepEqual(t, settings, dbSettings)
|
||||
})
|
||||
t.Run("update default settings then update at specific key", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
|
||||
key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -24,7 +23,7 @@ func TestPruneAttestations_NoPruning(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Next, attempt to prune and realize that we still have all epochs intact
|
||||
err = validatorDB.PruneAttestations(context.Background())
|
||||
err = validatorDB.PruneAttestations(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
startEpoch := primitives.Epoch(0)
|
||||
@@ -54,7 +53,7 @@ func TestPruneAttestations_OK(t *testing.T) {
|
||||
require.NoError(t, setupAttestationsForEveryEpoch(validatorDB, pk, numEpochs))
|
||||
}
|
||||
|
||||
require.NoError(t, validatorDB.PruneAttestations(context.Background()))
|
||||
require.NoError(t, validatorDB.PruneAttestations(t.Context()))
|
||||
|
||||
// Next, verify that we pruned every epoch
|
||||
// from genesis to SLASHING_PROTECTION_PRUNING_EPOCHS - 1.
|
||||
@@ -108,7 +107,7 @@ func BenchmarkPruneAttestations(b *testing.B) {
|
||||
}
|
||||
b.StartTimer()
|
||||
|
||||
require.NoError(b, validatorDB.PruneAttestations(context.Background()))
|
||||
require.NoError(b, validatorDB.PruneAttestations(b.Context()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"os"
|
||||
"path"
|
||||
@@ -18,7 +17,7 @@ import (
|
||||
|
||||
func TestRestore(t *testing.T) {
|
||||
logHook := logTest.NewGlobal()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
backupDb, err := kv.NewKVStore(ctx, t.TempDir(), &kv.Config{})
|
||||
defer func() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -27,7 +26,7 @@ func TestClearDB(t *testing.T) {
|
||||
PubKeys: nil,
|
||||
})
|
||||
} else {
|
||||
testDB, err = kv.NewKVStore(context.Background(), t.TempDir(), &kv.Config{
|
||||
testDB, err = kv.NewKVStore(t.Context(), t.TempDir(), &kv.Config{
|
||||
PubKeys: nil,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ func Test_validateMetadata(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := ValidateMetadata(context.Background(), NewValidatorDBMock(), tt.interchangeJSON); (err != nil) != tt.wantErr {
|
||||
if err := ValidateMetadata(t.Context(), NewValidatorDBMock(), tt.interchangeJSON); (err != nil) != tt.wantErr {
|
||||
t.Errorf("validateMetadata() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
@@ -267,7 +267,7 @@ func Test_validateMetadataGenesisValidatorsRoot(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB := NewValidatorDBMock()
|
||||
require.NoError(t, validatorDB.SaveGenesisValidatorsRoot(ctx, tt.dbGenesisValidatorsRoot))
|
||||
err := ValidateMetadata(ctx, validatorDB, tt.interchangeJSON)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package derived
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -24,7 +23,7 @@ const (
|
||||
// We test that using a '25th word' mnemonic passphrase leads to different
|
||||
// public keys derived than not specifying the passphrase.
|
||||
func TestDerivedKeymanager_MnemonicPassphrase_DifferentResults(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
wallet := &mock.Wallet{
|
||||
Files: make(map[string]map[string][]byte),
|
||||
AccountPasswords: make(map[string]string),
|
||||
@@ -84,7 +83,7 @@ func TestDerivedKeymanager_FetchValidatingPublicKeys(t *testing.T) {
|
||||
AccountPasswords: make(map[string]string),
|
||||
WalletPassword: password,
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
dr, err := NewKeymanager(ctx, &SetupConfig{
|
||||
Wallet: wallet,
|
||||
ListenForChanges: false,
|
||||
@@ -123,7 +122,7 @@ func TestDerivedKeymanager_FetchValidatingPrivateKeys(t *testing.T) {
|
||||
AccountPasswords: make(map[string]string),
|
||||
WalletPassword: password,
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
dr, err := NewKeymanager(ctx, &SetupConfig{
|
||||
Wallet: wallet,
|
||||
ListenForChanges: false,
|
||||
@@ -160,7 +159,7 @@ func TestDerivedKeymanager_Sign(t *testing.T) {
|
||||
AccountPasswords: make(map[string]string),
|
||||
WalletPassword: password,
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
dr, err := NewKeymanager(ctx, &SetupConfig{
|
||||
Wallet: wallet,
|
||||
ListenForChanges: false,
|
||||
@@ -196,7 +195,7 @@ func TestDerivedKeymanager_Sign_NoPublicKeySpecified(t *testing.T) {
|
||||
PublicKey: nil,
|
||||
}
|
||||
dr := &Keymanager{}
|
||||
_, err := dr.Sign(context.Background(), req)
|
||||
_, err := dr.Sign(t.Context(), req)
|
||||
assert.ErrorContains(t, "nil public key", err)
|
||||
}
|
||||
|
||||
@@ -205,6 +204,6 @@ func TestDerivedKeymanager_Sign_NoPublicKeyInCache(t *testing.T) {
|
||||
PublicKey: []byte("hello world"),
|
||||
}
|
||||
dr := &Keymanager{}
|
||||
_, err := dr.Sign(context.Background(), req)
|
||||
_, err := dr.Sign(t.Context(), req)
|
||||
assert.ErrorContains(t, "no signing key found", err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
@@ -22,7 +21,7 @@ func TestLocalKeymanager_ExtractKeystores(t *testing.T) {
|
||||
validatingKeys[i] = secretKey
|
||||
secretKeysCache[bytesutil.ToBytes48(secretKey.PublicKey().Marshal())] = secretKey
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
password := "password"
|
||||
|
||||
// Extracting 0 public keys should return 0 keystores.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
@@ -27,7 +26,7 @@ func TestLocalKeymanager_DeleteKeystores(t *testing.T) {
|
||||
accountsStore: &accountStore{},
|
||||
}
|
||||
numAccounts := 5
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
keystores := make([]*keymanager.Keystore, numAccounts)
|
||||
passwords := make([]string, numAccounts)
|
||||
for i := 0; i < numAccounts; i++ {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
@@ -54,7 +53,7 @@ func TestLocalKeymanager_NoDuplicates(t *testing.T) {
|
||||
dr := &Keymanager{
|
||||
wallet: wallet,
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
_, err := dr.CreateAccountsKeystore(ctx, privKeys, pubKeys)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -97,7 +96,7 @@ func TestLocalKeymanager_NoDuplicates(t *testing.T) {
|
||||
|
||||
func TestLocalKeymanager_ImportKeystores(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
// Setup the keymanager.
|
||||
wallet := &mock.Wallet{
|
||||
Files: make(map[string]map[string][]byte),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -27,7 +26,7 @@ func TestLocalKeymanager_FetchValidatingPublicKeys(t *testing.T) {
|
||||
accountsStore: &accountStore{},
|
||||
}
|
||||
// First, generate accounts and their keystore.json files.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numAccounts := 10
|
||||
wantedPubKeys := make([][fieldparams.BLSPubkeyLength]byte, 0)
|
||||
for i := 0; i < numAccounts; i++ {
|
||||
@@ -59,7 +58,7 @@ func TestLocalKeymanager_FetchValidatingPrivateKeys(t *testing.T) {
|
||||
accountsStore: &accountStore{},
|
||||
}
|
||||
// First, generate accounts and their keystore.json files.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numAccounts := 10
|
||||
wantedPrivateKeys := make([][32]byte, numAccounts)
|
||||
for i := 0; i < numAccounts; i++ {
|
||||
@@ -94,7 +93,7 @@ func TestLocalKeymanager_Sign(t *testing.T) {
|
||||
}
|
||||
|
||||
// First, generate accounts and their keystore.json files.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
numAccounts := 10
|
||||
keystores := make([]*keymanager.Keystore, numAccounts)
|
||||
passwords := make([]string, numAccounts)
|
||||
@@ -155,7 +154,7 @@ func TestLocalKeymanager_Sign_NoPublicKeySpecified(t *testing.T) {
|
||||
PublicKey: nil,
|
||||
}
|
||||
dr := &Keymanager{}
|
||||
_, err := dr.Sign(context.Background(), req)
|
||||
_, err := dr.Sign(t.Context(), req)
|
||||
assert.ErrorContains(t, "nil public key", err)
|
||||
}
|
||||
|
||||
@@ -165,6 +164,6 @@ func TestLocalKeymanager_Sign_NoPublicKeyInCache(t *testing.T) {
|
||||
}
|
||||
secretKeysCache = make(map[[fieldparams.BLSPubkeyLength]byte]bls.SecretKey)
|
||||
dr := &Keymanager{}
|
||||
_, err := dr.Sign(context.Background(), req)
|
||||
_, err := dr.Sign(t.Context(), req)
|
||||
assert.ErrorContains(t, "no signing key found in keys cache", err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -68,7 +67,7 @@ func TestLocalKeymanager_reloadAccountsFromKeystore(t *testing.T) {
|
||||
pubKeys[i] = privKey.PublicKey().Marshal()
|
||||
}
|
||||
|
||||
accountsStore, err := dr.CreateAccountsKeystore(context.Background(), privKeys, pubKeys)
|
||||
accountsStore, err := dr.CreateAccountsKeystore(t.Context(), privKeys, pubKeys)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, dr.reloadAccountsFromKeystore(accountsStore))
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package internal_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -45,7 +44,7 @@ func TestClient_Sign_HappyPath(t *testing.T) {
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
jsonRequest, err := json.Marshal(`{message: "hello"}`)
|
||||
assert.NoError(t, err)
|
||||
resp, err := cl.Sign(context.Background(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
resp, err := cl.Sign(t.Context(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, "0xb3baa751d0a9132cfe93e4e3d5ff9075111100e3789dca219ade5a24d27e19d16b3353149da1833e9b691bb38634e8dc04469be7032132906c927d7e1a49b414730612877bc6b2810c8f202daf793d1ab0d6b5cb21d52f9e52e883859887a5d9", fmt.Sprintf("%#x", resp.Marshal()))
|
||||
@@ -74,7 +73,7 @@ func TestClient_Sign_HappyPath_Jsontype(t *testing.T) {
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
jsonRequest, err := json.Marshal(`{message: "hello"}`)
|
||||
assert.NoError(t, err)
|
||||
resp, err := cl.Sign(context.Background(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
resp, err := cl.Sign(t.Context(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, "0xb3baa751d0a9132cfe93e4e3d5ff9075111100e3789dca219ade5a24d27e19d16b3353149da1833e9b691bb38634e8dc04469be7032132906c927d7e1a49b414730612877bc6b2810c8f202daf793d1ab0d6b5cb21d52f9e52e883859887a5d9", fmt.Sprintf("%#x", resp.Marshal()))
|
||||
@@ -93,7 +92,7 @@ func TestClient_Sign_500(t *testing.T) {
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
jsonRequest, err := json.Marshal(`{message: "hello"}`)
|
||||
assert.NoError(t, err)
|
||||
resp, err := cl.Sign(context.Background(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
resp, err := cl.Sign(t.Context(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, resp)
|
||||
|
||||
@@ -112,7 +111,7 @@ func TestClient_Sign_412(t *testing.T) {
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
jsonRequest, err := json.Marshal(`{message: "hello"}`)
|
||||
assert.NoError(t, err)
|
||||
resp, err := cl.Sign(context.Background(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
resp, err := cl.Sign(t.Context(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, resp)
|
||||
|
||||
@@ -131,7 +130,7 @@ func TestClient_Sign_400(t *testing.T) {
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
jsonRequest, err := json.Marshal(`{message: "hello"}`)
|
||||
assert.NoError(t, err)
|
||||
resp, err := cl.Sign(context.Background(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
resp, err := cl.Sign(t.Context(), "a2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820", jsonRequest)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, resp)
|
||||
|
||||
@@ -149,7 +148,7 @@ func TestClient_GetPublicKeys_HappyPath(t *testing.T) {
|
||||
u, err := url.Parse("example.com")
|
||||
assert.NoError(t, err)
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
resp, err := cl.GetPublicKeys(context.Background(), "example.com/api/publickeys")
|
||||
resp, err := cl.GetPublicKeys(t.Context(), "example.com/api/publickeys")
|
||||
assert.NotNil(t, resp)
|
||||
assert.Nil(t, err)
|
||||
// we would like them as 48byte base64 without 0x
|
||||
@@ -165,7 +164,7 @@ func TestClient_ReloadSignerKeys_HappyPath(t *testing.T) {
|
||||
u, err := url.Parse("example.com")
|
||||
assert.NoError(t, err)
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
err = cl.ReloadSignerKeys(context.Background())
|
||||
err = cl.ReloadSignerKeys(t.Context())
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ func TestClient_GetServerStatus_HappyPath(t *testing.T) {
|
||||
u, err := url.Parse("example.com")
|
||||
assert.NoError(t, err)
|
||||
cl := internal.ApiClient{BaseURL: u, RestClient: &http.Client{Transport: mock}}
|
||||
resp, err := cl.GetServerStatus(context.Background())
|
||||
resp, err := cl.GetServerStatus(t.Context())
|
||||
assert.NotNil(t, resp)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func TestNewKeymanager(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
logHook := logTest.NewGlobal()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
if tt.args.KeyFilePath != "" && len(tt.fileContents) != 0 {
|
||||
bytesBuf := new(bytes.Buffer)
|
||||
@@ -187,7 +187,7 @@ func TestNewKeyManager_fileMissing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewKeyManager_ChangingFileCreated(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
|
||||
keyFilePath := filepath.Join(t.TempDir(), "keyfile.txt")
|
||||
@@ -242,7 +242,7 @@ func TestNewKeyManager_ChangingFileCreated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewKeyManager_FileAndFlagsWithDifferentKeys(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
logHook := logTest.NewGlobal()
|
||||
keyFilePath := filepath.Join(t.TempDir(), "keyfile.txt")
|
||||
@@ -288,7 +288,7 @@ func TestNewKeyManager_FileAndFlagsWithDifferentKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRefreshRemoteKeysFromFileChangesWithRetry(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
logHook := logTest.NewGlobal()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
require.NoError(t, err)
|
||||
@@ -338,7 +338,7 @@ func TestReadKeyFile_PathMissing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRefreshRemoteKeysFromFileChangesWithRetry_maxRetryReached(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
require.NoError(t, err)
|
||||
keyFilePath := filepath.Join(t.TempDir(), "keyfile.txt")
|
||||
@@ -359,7 +359,7 @@ func TestKeymanager_Sign(t *testing.T) {
|
||||
client := &MockClient{
|
||||
Signature: "0xb3baa751d0a9132cfe93e4e3d5ff9075111100e3789dca219ade5a24d27e19d16b3353149da1833e9b691bb38634e8dc04469be7032132906c927d7e1a49b414730612877bc6b2810c8f202daf793d1ab0d6b5cb21d52f9e52e883859887a5d9",
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v", err)
|
||||
@@ -502,7 +502,7 @@ func TestKeymanager_Sign(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKeymanager_FetchValidatingPublicKeys_HappyPath_WithKeyList(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
decodedKey, err := hexutil.Decode("0xa2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820")
|
||||
require.NoError(t, err)
|
||||
keys := [][48]byte{
|
||||
@@ -529,7 +529,7 @@ func TestKeymanager_FetchValidatingPublicKeys_HappyPath_WithKeyList(t *testing.T
|
||||
}
|
||||
|
||||
func TestKeymanager_FetchValidatingPublicKeys_HappyPath_WithExternalURL(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
decodedKey, err := hexutil.Decode("0xa2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820")
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v", err)
|
||||
@@ -564,7 +564,7 @@ func TestKeymanager_FetchValidatingPublicKeys_HappyPath_WithExternalURL(t *testi
|
||||
}
|
||||
|
||||
func TestKeymanager_FetchValidatingPublicKeys_WithExternalURL_ThrowsError(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -587,7 +587,7 @@ func TestKeymanager_FetchValidatingPublicKeys_WithExternalURL_ThrowsError(t *tes
|
||||
}
|
||||
|
||||
func TestKeymanager_AddPublicKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v", err)
|
||||
@@ -614,7 +614,7 @@ func TestKeymanager_AddPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKeymanager_AddPublicKeys_WithFile(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
dir := t.TempDir()
|
||||
stdOutFile, err := os.Create(filepath.Clean(path.Join(dir, "keyfile.txt")))
|
||||
@@ -652,7 +652,7 @@ func TestKeymanager_AddPublicKeys_WithFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKeymanager_DeletePublicKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
root, err := hexutil.Decode("0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69")
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v", err)
|
||||
@@ -686,7 +686,7 @@ func TestKeymanager_DeletePublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKeymanager_DeletePublicKeys_WithFile(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
dir := t.TempDir()
|
||||
stdOutFile, err := os.Create(filepath.Clean(path.Join(dir, "keyfile.txt")))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -201,7 +200,7 @@ func TestClearDB(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("isMinimalDatabase=%v", isMinimalDatabase), func(t *testing.T) {
|
||||
hook := logtest.NewGlobal()
|
||||
tmp := filepath.Join(t.TempDir(), "datadirtest")
|
||||
require.NoError(t, clearDB(context.Background(), tmp, true, isMinimalDatabase))
|
||||
require.NoError(t, clearDB(t.Context(), tmp, true, isMinimalDatabase))
|
||||
require.LogsContain(t, hook, "Removing database")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestServer_AuthenticateUsingExistingToken(t *testing.T) {
|
||||
ctxMD := map[string][]string{
|
||||
"authorization": {"Bearer " + srv.authToken},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
ctx = metadata.NewIncomingContext(ctx, ctxMD)
|
||||
_, err = srv.AuthTokenInterceptor()(ctx, "xyz", unaryInfo, unaryHandler)
|
||||
require.NoError(t, err)
|
||||
@@ -77,7 +77,7 @@ func TestServer_RefreshAuthTokenOnFileChange(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
currentToken := srv.authToken
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
go srv.refreshAuthTokenFromFileChanges(ctx, srv.authTokenPath)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/testing/assert"
|
||||
@@ -11,7 +10,7 @@ import (
|
||||
|
||||
func TestGrpcHeaders(t *testing.T) {
|
||||
s := &Server{
|
||||
ctx: context.Background(),
|
||||
ctx: t.Context(),
|
||||
grpcHeaders: []string{"first=value1", "second=value2"},
|
||||
}
|
||||
err := s.registerBeaconClient()
|
||||
|
||||
@@ -2,7 +2,6 @@ package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -31,7 +30,7 @@ import (
|
||||
const strongPass = "29384283xasjasd32%%&*@*#*"
|
||||
|
||||
func TestServer_CreateWallet_Local(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
opts := []accounts.Option{
|
||||
@@ -424,7 +423,7 @@ func TestServer_WalletConfig_NoWalletFound(t *testing.T) {
|
||||
func TestServer_WalletConfig(t *testing.T) {
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
s := &Server{
|
||||
walletInitializedFeed: new(event.Feed),
|
||||
walletDir: defaultWalletPath,
|
||||
|
||||
@@ -3,7 +3,6 @@ package rpc
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -37,7 +36,7 @@ var (
|
||||
)
|
||||
|
||||
func TestServer_ListAccounts(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
// We attempt to create the wallet.
|
||||
@@ -142,7 +141,7 @@ func TestServer_ListAccounts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_BackupAccounts(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
// We attempt to create the wallet.
|
||||
@@ -235,7 +234,7 @@ func TestServer_BackupAccounts(t *testing.T) {
|
||||
func TestServer_VoluntaryExit(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
mockValidatorClient := validatormock.NewMockValidatorClient(ctrl)
|
||||
mockNodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -33,7 +32,7 @@ func TestInitialize(t *testing.T) {
|
||||
}
|
||||
acc, err := accounts.NewCLIManager(opts...)
|
||||
require.NoError(t, err)
|
||||
_, err = acc.WalletCreate(context.Background())
|
||||
_, err = acc.WalletCreate(t.Context())
|
||||
require.NoError(t, err)
|
||||
server := &Server{walletDir: localWalletDir, authTokenPath: authTokenPath}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestStreamBeaconLogs(t *testing.T) {
|
||||
|
||||
// Setting up the mock in the server struct
|
||||
s := Server{
|
||||
ctx: context.Background(),
|
||||
ctx: t.Context(),
|
||||
healthClient: mockClient,
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ func TestStreamBeaconLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStreamValidatorLogs(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
mockLogs := [][]byte{
|
||||
[]byte("[2023-10-31 10:00:00] INFO: Starting server..."),
|
||||
[]byte("[2023-10-31 10:01:23] DEBUG: Database connection established."),
|
||||
@@ -166,7 +166,7 @@ func TestStreamValidatorLogs(t *testing.T) {
|
||||
func TestServer_GetVersion(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
mockNodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
s := Server{
|
||||
ctx: ctx,
|
||||
|
||||
@@ -2,7 +2,6 @@ package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -49,7 +48,7 @@ import (
|
||||
)
|
||||
|
||||
func TestServer_ListKeystores(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
t.Run("wallet not ready", func(t *testing.T) {
|
||||
m := &testutil.FakeValidator{}
|
||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||
@@ -132,7 +131,7 @@ func TestServer_ListKeystores(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ImportKeystores(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
opts := []accounts.Option{
|
||||
@@ -353,7 +352,7 @@ func TestServer_ImportKeystores(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ImportKeystores_WrongKeymanagerKind(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
@@ -404,7 +403,7 @@ func TestServer_ImportKeystores_WrongKeymanagerKind(t *testing.T) {
|
||||
|
||||
func TestServer_DeleteKeystores(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range []bool{false, true} {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
srv := setupServerWithWallet(t)
|
||||
|
||||
// We recover 3 accounts from a test mnemonic.
|
||||
@@ -577,7 +576,7 @@ func TestServer_DeleteKeystores(t *testing.T) {
|
||||
func TestServer_DeleteKeystores_FailedSlashingProtectionExport(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("minimalSlashingProtection:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
srv := setupServerWithWallet(t)
|
||||
|
||||
// We recover 3 accounts from a test mnemonic.
|
||||
@@ -636,7 +635,7 @@ func TestServer_DeleteKeystores_FailedSlashingProtectionExport(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_DeleteKeystores_WrongKeymanagerKind(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
@@ -680,7 +679,7 @@ func TestServer_DeleteKeystores_WrongKeymanagerKind(t *testing.T) {
|
||||
}
|
||||
|
||||
func setupServerWithWallet(t testing.TB) *Server {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
opts := []accounts.Option{
|
||||
@@ -714,7 +713,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
defaultWalletPath = setupWalletDir(t)
|
||||
opts := []accounts.Option{
|
||||
accounts.WithWalletDir(defaultWalletPath),
|
||||
@@ -898,7 +897,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_GetGasLimit(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
byteval, err := hexutil.Decode("0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
byteval2, err2 := hexutil.Decode("0x1234567878903438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
require.NoError(t, err)
|
||||
@@ -977,7 +976,7 @@ func TestServer_SetGasLimit(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
beaconClient := validatormock.NewMockValidatorClient(ctrl)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
pubkey1, err := hexutil.Decode("0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
pubkey2, err2 := hexutil.Decode("0xbedefeaa94e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2cdddddddddddddddddddddddd")
|
||||
@@ -1185,7 +1184,7 @@ func TestServer_SetGasLimit_InvalidPubKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey1, err := hexutil.Decode("0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
pubkey2, err2 := hexutil.Decode("0xbedefeaa94e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2cdddddddddddddddddddddddd")
|
||||
require.NoError(t, err)
|
||||
@@ -1333,7 +1332,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ListRemoteKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
@@ -1389,7 +1388,7 @@ func TestServer_ListRemoteKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ImportRemoteKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
@@ -1450,7 +1449,7 @@ func TestServer_ImportRemoteKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_DeleteRemoteKeys(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
newDir := filepath.Join(t.TempDir(), "new")
|
||||
@@ -1511,7 +1510,7 @@ func TestServer_DeleteRemoteKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ListFeeRecipientByPubkey(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := "0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493"
|
||||
byteval, err := hexutil.Decode(pubkey)
|
||||
require.NoError(t, err)
|
||||
@@ -1589,7 +1588,7 @@ func TestServer_ListFeeRecipientByPubkey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ListFeeRecipientByPubKey_NoFeeRecipientSet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||
Validator: &testutil.FakeValidator{},
|
||||
@@ -1638,7 +1637,7 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
beaconClient := validatormock.NewMockValidatorClient(ctrl)
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := "0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493"
|
||||
byteval, err := hexutil.Decode(pubkey)
|
||||
require.NoError(t, err)
|
||||
@@ -1848,7 +1847,7 @@ func TestServer_SetFeeRecipientByPubkey_InvalidFeeRecipient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubkey := "0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493"
|
||||
byteval, err := hexutil.Decode(pubkey)
|
||||
require.NoError(t, err)
|
||||
@@ -1940,7 +1939,7 @@ func TestServer_DeleteFeeRecipientByPubkey_InvalidPubKey(t *testing.T) {
|
||||
func TestServer_Graffiti(t *testing.T) {
|
||||
graffiti := "graffiti"
|
||||
m := &testutil.FakeValidator{}
|
||||
vs, err := client.NewValidatorService(context.Background(), &client.Config{
|
||||
vs, err := client.NewValidatorService(t.Context(), &client.Config{
|
||||
Validator: m,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -2,7 +2,6 @@ package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -23,7 +22,7 @@ import (
|
||||
func TestImportSlashingProtection_Preconditions(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("slashing protection minimal: %v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
|
||||
@@ -119,7 +118,7 @@ func TestImportSlashingProtection_Preconditions(t *testing.T) {
|
||||
func TestExportSlashingProtection_Preconditions(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("slashing protection minimal: %v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
|
||||
@@ -146,7 +145,7 @@ func TestExportSlashingProtection_Preconditions(t *testing.T) {
|
||||
PubKeys: pubKeys,
|
||||
})
|
||||
} else {
|
||||
validatorDB, err = kv.NewKVStore(context.Background(), t.TempDir(), &kv.Config{
|
||||
validatorDB, err = kv.NewKVStore(t.Context(), t.TempDir(), &kv.Config{
|
||||
PubKeys: pubKeys,
|
||||
})
|
||||
}
|
||||
@@ -171,7 +170,7 @@ func TestExportSlashingProtection_Preconditions(t *testing.T) {
|
||||
func TestImportExportSlashingProtection_RoundTrip(t *testing.T) {
|
||||
// Round trip is only suitable with complete slashing protection, since
|
||||
// minimal slashing protections only keep latest attestation and proposal.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestServer_AuthTokenInterceptor_Verify(t *testing.T) {
|
||||
ctxMD := map[string][]string{
|
||||
"authorization": {"Bearer " + token},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
ctx = metadata.NewIncomingContext(ctx, ctxMD)
|
||||
_, err := interceptor(ctx, "xyz", unaryInfo, unaryHandler)
|
||||
require.NoError(t, err)
|
||||
@@ -52,7 +52,7 @@ func TestServer_AuthTokenInterceptor_BadToken(t *testing.T) {
|
||||
ctxMD := map[string][]string{
|
||||
"authorization": {"Bearer bad-token"},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
ctx = metadata.NewIncomingContext(ctx, ctxMD)
|
||||
_, err := interceptor(ctx, "xyz", unaryInfo, unaryHandler)
|
||||
require.ErrorContains(t, "token value is invalid", err)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package history
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -17,7 +16,7 @@ import (
|
||||
func TestExportStandardProtectionJSON_EmptyGenesisRoot(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("isSlashingProtectionMinimal=%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
{1},
|
||||
}
|
||||
@@ -39,7 +38,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
{1},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||
|
||||
// No attestation history stored should return empty.
|
||||
@@ -95,7 +94,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
{1},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
isSlashingProtectionMinimal := false
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||
@@ -142,7 +141,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
{1},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
isSlashingProtectionMinimal := false
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||
@@ -195,7 +194,7 @@ func Test_getSignedBlocksByPubKey(t *testing.T) {
|
||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||
{1},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||
|
||||
// No highest and/or lowest signed blocks will return empty.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user