prysm-pulse/fuzz/common.go
Shay Zluf 1a27c21d9c
Load chain config from file (#5694)
* load chain config from file

* revert flag name change

* add dependencies to image

* Update shared/cmd/flags.go

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>

* Update beacon-chain/main.go

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>

* added test to load config file

* Merge branch 'yaml_chain_config' of github.com:prysmaticlabs/prysm into yaml_chain_config

# Conflicts:
#	beacon-chain/main.go

* replace hex with yaml format of fixed byte array

* fix test and check if comment

* move to node package

* gaz

* added contract address case

* fix key name issue

* add tests

* gaz

* add 1 byte handling

* change to fatal

* add config printout

* revert main changes

* revert line removal

* fix one byte handling

* fix test and one byte handling

* remove log

* Apply suggestions from code review

* change to debug

* Update beacon-chain/node/node.go

* move helper methods

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2020-05-05 20:58:07 +03:00

42 lines
794 B
Go

package fuzz
import (
"os"
"strings"
"github.com/prysmaticlabs/go-ssz"
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
)
func init() {
featureconfig.Init(&featureconfig.Flags{
SkipBLSVerify: true,
})
}
func fail(err error) ([]byte, bool) {
shouldPanic := false
if val, ok := os.LookupEnv("PANIC_ON_ERROR"); ok {
shouldPanic = strings.ToLower(val) == "true"
}
if shouldPanic {
panic(err)
}
return nil, false
}
func success(post *stateTrie.BeaconState) ([]byte, bool) {
if val, ok := os.LookupEnv("RETURN_SSZ_POST_STATE"); ok {
if strings.ToLower(val) != "true" {
return nil, true
}
}
result, err := ssz.Marshal(post.InnerStateUnsafe())
if err != nil {
panic(err)
}
return result, true
}