Skip to content

Commit

Permalink
simple casting
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapka committed Apr 30, 2024
1 parent 7573624 commit f80a5c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
4 changes: 1 addition & 3 deletions beacon-chain/operations/slashings/service_attester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ func TestPool_InsertAttesterSlashing_SigFailsVerify_ClearPool(t *testing.T) {
// We mess up the signature of the second slashing.
badSig := make([]byte, 96)
copy(badSig, "muahaha")
pending, ok := pendingSlashings[1].attesterSlashing.(*ethpb.AttesterSlashing)
require.Equal(t, true, ok, "unexpected type of attester slashing")
pending.Attestation_1.Signature = badSig
pendingSlashings[1].attesterSlashing.(*ethpb.AttesterSlashing).Attestation_1.Signature = badSig
slashings[1].Attestation_1.Signature = badSig
p := &Pool{
pendingAttesterSlashing: make([]*PendingAttesterSlashing, 0),
Expand Down
6 changes: 2 additions & 4 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2447,17 +2447,15 @@ func TestProposer_FilterAttestation(t *testing.T) {
require.NoError(t, err)
sigs := make([]bls.Signature, len(attestingIndices))
var zeroSig [96]byte
att, ok := atts[i].(*ethpb.Attestation)
require.Equal(t, true, ok, "unexpected type of attestation")
att.Signature = zeroSig[:]
atts[i].(*ethpb.Attestation).Signature = zeroSig[:]

for i, indice := range attestingIndices {
hashTreeRoot, err := signing.ComputeSigningRoot(atts[i].GetData(), domain)
require.NoError(t, err)
sig := privKeys[indice].Sign(hashTreeRoot[:])
sigs[i] = sig
}
att.Signature = bls.AggregateSignatures(sigs).Marshal()
atts[i].(*ethpb.Attestation).Signature = bls.AggregateSignatures(sigs).Marshal()
}
return atts
},
Expand Down
16 changes: 4 additions & 12 deletions beacon-chain/slasher/detect_attestations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,9 @@ func Test_processAttestations(t *testing.T) {
)

// Create the attester slashing.
att_1, ok := wrapper_1.IndexedAttestation.(*ethpb.IndexedAttestation)
require.Equal(t, true, ok, "unexpected type of first attestation")
att_2, ok := wrapper_2.IndexedAttestation.(*ethpb.IndexedAttestation)
require.Equal(t, true, ok, "unexpected type of second attestation")
expectedSlashing := &ethpb.AttesterSlashing{
Attestation_1: att_1,
Attestation_2: att_2,
Attestation_1: wrapper_1.IndexedAttestation.(*ethpb.IndexedAttestation),
Attestation_2: wrapper_2.IndexedAttestation.(*ethpb.IndexedAttestation),
}

root, err := expectedSlashing.HashTreeRoot()
Expand Down Expand Up @@ -1168,9 +1164,7 @@ func Test_applyAttestationForValidator_MinSpanChunk(t *testing.T) {
)
require.NoError(t, err)
require.IsNil(t, slashing)
indexedAtt, ok := att.IndexedAttestation.(*ethpb.IndexedAttestation)
require.Equal(t, true, ok, "unexpected type of indexed attestation")
indexedAtt.AttestingIndices = []uint64{uint64(validatorIdx)}
att.IndexedAttestation.(*ethpb.IndexedAttestation).AttestingIndices = []uint64{uint64(validatorIdx)}
err = slasherDB.SaveAttestationRecordsForValidators(
ctx,
[]*slashertypes.IndexedAttestationWrapper{att},
Expand Down Expand Up @@ -1227,9 +1221,7 @@ func Test_applyAttestationForValidator_MaxSpanChunk(t *testing.T) {
)
require.NoError(t, err)
require.Equal(t, true, slashing == nil)
indexedAtt, ok := att.IndexedAttestation.(*ethpb.IndexedAttestation)
require.Equal(t, true, ok, "unexpected type of indexed attestation")
indexedAtt.AttestingIndices = []uint64{uint64(validatorIdx)}
att.IndexedAttestation.(*ethpb.IndexedAttestation).AttestingIndices = []uint64{uint64(validatorIdx)}
err = slasherDB.SaveAttestationRecordsForValidators(
ctx,
[]*slashertypes.IndexedAttestationWrapper{att},
Expand Down

0 comments on commit f80a5c2

Please sign in to comment.