Skip to content

Commit

Permalink
Testutil: Can generate attestation at epoch boundary (#8265)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Jan 14, 2021
1 parent a2d4e33 commit 40155c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shared/testutil/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewAttestation() *ethpb.Attestation {
//
// If you request 4 attestations, but there are 8 committees, you will get 4 fully aggregated attestations.
func GenerateAttestations(bState *stateTrie.BeaconState, privs []bls.SecretKey, numToGen, slot uint64, randomRoot bool) ([]*ethpb.Attestation, error) {
currentEpoch := helpers.SlotToEpoch(slot)
var attestations []*ethpb.Attestation
generateHeadState := false
bState = bState.Copy()
Expand All @@ -50,6 +49,7 @@ func GenerateAttestations(bState *stateTrie.BeaconState, privs []bls.SecretKey,
slot--
generateHeadState = true
}
currentEpoch := helpers.SlotToEpoch(slot)

targetRoot := make([]byte, 32)
var headRoot []byte
Expand Down
6 changes: 6 additions & 0 deletions shared/testutil/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ func TestHydrateIndexedAttestation(t *testing.T) {
_, err = a.Data.HashTreeRoot()
require.NoError(t, err)
}

func TestGenerateAttestations_EpochBoundary(t *testing.T) {
gs, pk := DeterministicGenesisState(t, 32)
_, err := GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false)
require.NoError(t, err)
}

0 comments on commit 40155c9

Please sign in to comment.