<commit_before>package testutil

import (
	"time"
	"testing"
	"github.com/hashicorp/consul/consul/structs"
)

type testFn func() (bool, error)
type errorFn func(error)

func WaitForResult(test testFn, error errorFn) {
	retries := 100  // 5 seconds timeout

	for retries > 0 {
		time.Sleep(50 * time.Millisecond)
		retries--

		success, err := test()
		if success {
			return
		}

		if retries == 0 {
			error(err)
		}
	}
}

type rpcFn func(string, interface {}, interface {}) error

func WaitForLeader(t *testing.T, rpc rpcFn, dc string) structs.IndexedNodes {
	var out structs.IndexedNodes
	WaitForResult(func() (bool, error) {
		args := &structs.RegisterRequest{
			Datacenter: dc,
		}<commit_msg>Increase timeout for `WaitForResult`<commit_after>package testutil

import (
	"time"
	"testing"
	"github.com/hashicorp/consul/consul/structs"
)

type testFn func() (bool, error)
type errorFn func(error)

func WaitForResult(test testFn, error errorFn) {
	retries := 100

	for retries > 0 {
		time.Sleep(100 * time.Millisecond)
		retries--

		success, err := test()
		if success {
			return
		}

		if retries == 0 {
			error(err)
		}
	}
}

type rpcFn func(string, interface {}, interface {}) error

func WaitForLeader(t *testing.T, rpc rpcFn, dc string) structs.IndexedNodes {
	var out structs.IndexedNodes
	WaitForResult(func() (bool, error) {
		args := &structs.RegisterRequest{
			Datacenter: dc,
		}
{'fraction_non_alphanumeric': 0.12428571428571429, 'fraction_numerical': 0.011428571428571429, 'mean_word_length': 3.9157894736842107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4286530', 'n_tokens_mistral': 561, 'n_tokens_neox': 508, 'n_words': 128}