Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare 82 virtual channels #114

Merged
27 changes: 15 additions & 12 deletions client/test/progression.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/stretchr/testify/assert"

"perun.network/go-perun/channel"
"perun.network/go-perun/log"
)

// ProgressionExecConfig contains config parameters for the progression test.
Expand All @@ -30,22 +31,22 @@ type ProgressionExecConfig struct {

// Watcher is a client that handles adjudicator events.
type Watcher struct {
t *testing.T
log.Logger
registered chan *channel.RegisteredEvent
progressed chan *channel.ProgressedEvent
}

func makeWatcher(t *testing.T) Watcher {
func makeWatcher(log log.Logger) Watcher {
return Watcher{
t: t,
Logger: log,
registered: make(chan *channel.RegisteredEvent),
progressed: make(chan *channel.ProgressedEvent),
}
}

// HandleAdjudicatorEvent is the callback for adjudicator event handling.
func (w *Watcher) HandleAdjudicatorEvent(e channel.AdjudicatorEvent) {
w.t.Logf("HandleAdjudicatorEvent: %v", e)
w.Infof("HandleAdjudicatorEvent: %v", e)
switch e := e.(type) {
case *channel.RegisteredEvent:
w.registered <- e
Expand All @@ -64,9 +65,10 @@ type Paul struct {

// NewPaul creates a new party that executes the Paul protocol.
func NewPaul(t *testing.T, setup RoleSetup) *Paul {
p := NewProposer(setup, t, 1)
return &Paul{
Proposer: *NewProposer(setup, t, 1),
Watcher: makeWatcher(t),
Proposer: *p,
Watcher: makeWatcher(p.log),
}
}

Expand All @@ -83,8 +85,8 @@ func (r *Paul) exec(_cfg ExecConfig, ch *paymentChannel) {
// start watcher
go func() {
r.log.Info("Starting channel watcher.")
assert.NoError(ch.Watch(r))
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
r.log.Debug("Channel watcher returned.")
err := ch.Watch(r)
r.log.Infof("Channel watcher returned: %v", err)
}()

r.waitStage() // wait for setup complete
Expand Down Expand Up @@ -130,9 +132,10 @@ type Paula struct {

// NewPaula creates a new party that executes the Paula protocol.
func NewPaula(t *testing.T, setup RoleSetup) *Paula {
r := NewResponder(setup, t, 1)
return &Paula{
Responder: *NewResponder(setup, t, 1),
Watcher: makeWatcher(t),
Responder: *r,
Watcher: makeWatcher(r.log),
}
}

Expand All @@ -149,8 +152,8 @@ func (r *Paula) exec(_cfg ExecConfig, ch *paymentChannel, _ *acceptNextPropHandl
// start watcher
go func() {
r.log.Info("Starting channel watcher.")
assert.NoError(ch.Watch(r))
r.log.Debug("Channel watcher returned.")
err := ch.Watch(r)
r.log.Infof("Channel watcher returned: %v", err)
}()

r.waitStage() // wait for setup complete
Expand Down