mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Multiclient E2E With Lighthouse (#10020)
* save work * current progress * fix it more * save progress * fixes so far * add signature test * fix up changes so far * change to latest * update lighthouse version * fix build * fix again * do one * clean up * fix build * fix it * fix test * change tag * remove e2e * Update config/params/testnet_e2e_config.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * update * Update sha Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prestonvanloon <preston@prysmaticlabs.com>
This commit is contained in:
@@ -95,6 +95,53 @@ func WaitForTextInFile(file *os.File, text string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// FindFollowingTextInFile checks a file every polling interval for the following text requested.
|
||||
func FindFollowingTextInFile(file *os.File, text string) (string, error) {
|
||||
d := time.Now().Add(maxPollingWaitTime)
|
||||
ctx, cancel := context.WithDeadline(context.Background(), d)
|
||||
defer cancel()
|
||||
|
||||
// Use a ticker with a deadline to poll a given file.
|
||||
ticker := time.NewTicker(filePollingInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
contents, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "", fmt.Errorf("could not find requested text \"%s\" in logs:\n%s", text, contents)
|
||||
case <-ticker.C:
|
||||
fileScanner := bufio.NewScanner(file)
|
||||
buf := make([]byte, 0, fileBufferSize)
|
||||
fileScanner.Buffer(buf, maxFileBufferSize)
|
||||
for fileScanner.Scan() {
|
||||
scanned := fileScanner.Text()
|
||||
if strings.Contains(scanned, text) {
|
||||
lastIdx := strings.LastIndex(scanned, text)
|
||||
truncatedIdx := lastIdx + len(text)
|
||||
if len(scanned) <= truncatedIdx {
|
||||
return "", fmt.Errorf("truncated index is larger than the size of whole scanned line")
|
||||
}
|
||||
splitObjs := strings.Split(scanned[truncatedIdx:], " ")
|
||||
if len(splitObjs) == 0 {
|
||||
return "", fmt.Errorf("0 split substrings retrieved")
|
||||
}
|
||||
return splitObjs[0], nil
|
||||
}
|
||||
}
|
||||
if err := fileScanner.Err(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err := file.Seek(0, io.SeekStart)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GraffitiYamlFile outputs graffiti YAML file into a testing directory.
|
||||
func GraffitiYamlFile(testDir string) (string, error) {
|
||||
b := []byte(`default: "Rice"
|
||||
|
||||
Reference in New Issue
Block a user