func (d *Decorator) Await(ctx context.Context) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	if err := d.errs.Await; err != nil {
		return err
	}
	_, cancel := watchContext(ctx, &d.mu, d.cond)
	defer cancel()
	for d.block && ctx.Err() == nil {
		d.cond.Wait()
	}
	if err := ctx.Err(); err != nil {
		return err
	}
	return d.e.Await(ctx)
}
Await blocks until the instance captures mastership.
package testonly
import (
	"context"
	"sync"
	"github.com/google/trillian/util/election2"
)
type Errs struct {
	Await          error
	WithMastership error
	Resign         error
	Close          error
}
type Decorator struct {
	e     election2.Election
	errs  Errs
	block bool
	mu    sync.Mutex
	cond  *sync.Cond
}
func NewDecorator(e election2.Election) *Decorator {
	d := &Decorator{e: e}
	d.cond = sync.NewCond(&d.mu)
	return d
}
func (d *Decorator) Update(errs Errs) {
	d.mu.Lock()
	defer d.mu.Unlock()
	d.errs = errs
}
func (d *Decorator) BlockAwait(block bool) {
	d.mu.Lock()
	defer d.mu.Unlock()
	d.block = block
	d.cond.Broadcast()
}