Skip to content

Commit 5c1de0a

Browse files
committed
Add manual coordinator test
1 parent d72a6d6 commit 5c1de0a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tss/ecdsa/signing/signing_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,60 @@ func (s *SigningTestSuite) Test_ValidSigningProcess() {
8080
s.Nil(err)
8181
}
8282

83+
func (s *SigningTestSuite) Test_ValidSigningProcess_ManualCoordinator() {
84+
communicationMap := make(map[peer.ID]*tsstest.TestCommunication)
85+
coordinators := []*tss.Coordinator{}
86+
processes := []tss.TssProcess{}
87+
88+
for i, host := range s.Hosts {
89+
communication := tsstest.TestCommunication{
90+
Host: host,
91+
Subscriptions: make(map[comm.SubscriptionID]chan *comm.WrappedMessage),
92+
}
93+
communicationMap[host.ID()] = &communication
94+
fetcher := keyshare.NewECDSAKeyshareStore(fmt.Sprintf("../../test/keyshares/%d.keyshare", i))
95+
96+
msgBytes := []byte("Message")
97+
msg := big.NewInt(0)
98+
msg.SetBytes(msgBytes)
99+
signing, err := signing.NewSigning(msg, "signing1", "signing1", host, &communication, fetcher)
100+
if err != nil {
101+
panic(err)
102+
}
103+
electorFactory := elector.NewCoordinatorElectorFactory(host, s.BullyConfig)
104+
coordinators = append(coordinators, tss.NewCoordinator(host, &communication, electorFactory))
105+
processes = append(processes, signing)
106+
}
107+
tsstest.SetupCommunication(communicationMap)
108+
109+
resultChn := make(chan interface{}, 2)
110+
111+
coordinatorPeerID := s.Hosts[1].ID()
112+
ctx, cancel := context.WithCancel(context.Background())
113+
pool := pool.New().WithContext(ctx)
114+
for i, coordinator := range coordinators {
115+
coordinator := coordinator
116+
117+
if s.Hosts[i].ID().String() == coordinatorPeerID.String() {
118+
pool.Go(func(ctx context.Context) error {
119+
return coordinator.Execute(ctx, []tss.TssProcess{processes[i]}, resultChn, coordinatorPeerID)
120+
})
121+
} else {
122+
pool.Go(func(ctx context.Context) error {
123+
return coordinator.Execute(ctx, []tss.TssProcess{processes[i]}, make(chan interface{}, 1), coordinatorPeerID)
124+
})
125+
}
126+
}
127+
128+
sig := <-resultChn
129+
s.NotNil(sig)
130+
131+
time.Sleep(time.Millisecond * 100)
132+
cancel()
133+
err := pool.Wait()
134+
s.Nil(err)
135+
}
136+
83137
func (s *SigningTestSuite) Test_SigningTimeout() {
84138
communicationMap := make(map[peer.ID]*tsstest.TestCommunication)
85139
coordinators := []*tss.Coordinator{}

0 commit comments

Comments
 (0)