mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-20 16:41:11 +00:00
b7175b3482
* Revert "Revert "Update fastssz" (#7100)" This reverts commit b954db97041094d6f876ac25ca1542a39b33b6e0. * Preston's patch * Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz * Update fssz, add regression test case * more HTR with fssz * fix some tests * only one test left * Make it so that HTR will work * gofmt, imports * gofmt, imports * fix * Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz * fix * Merge branch 'master' into revert-7100-revert-6760-update-fssz * Merge refs/heads/master into revert-7100-revert-6760-update-fssz * gaz * Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz * Merge refs/heads/master into revert-7100-revert-6760-update-fssz * fix test * Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz * Merge refs/heads/master into revert-7100-revert-6760-update-fssz
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package testing
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
)
|
|
|
|
const fileBase = "0-11-0/mainnet/beaconstate"
|
|
const fileBaseENV = "BEACONSTATES_PATH"
|
|
|
|
// GetBeaconFuzzState returns a beacon state by ID using the beacon-fuzz corpora.
|
|
func GetBeaconFuzzState(ID uint64) (*pb.BeaconState, error) {
|
|
base := fileBase
|
|
// Using an environment variable allows a host image to specify the path when only the binary
|
|
// executable was uploaded (without the runfiles). i.e. fuzzit's platform.
|
|
if p, ok := os.LookupEnv(fileBaseENV); ok {
|
|
base = p
|
|
}
|
|
ok, err := testutil.BazelDirectoryNonEmpty(base)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if !ok {
|
|
panic(fmt.Sprintf("Beacon states directory (%s) does not exist or has no files.", base))
|
|
}
|
|
b, err := testutil.BazelFileBytes(base, strconv.Itoa(int(ID)))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
st := &pb.BeaconState{}
|
|
if err := st.UnmarshalSSZ(b); err != nil {
|
|
return nil, err
|
|
}
|
|
return st, nil
|
|
}
|