forked from yangmiok/thorchain-tss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mock_tss_server.go
46 lines (38 loc) · 1.13 KB
/
mock_tss_server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"errors"
"github.com/joltgeorge/tss/blame"
"github.com/joltgeorge/tss/common"
"github.com/joltgeorge/tss/conversion"
"github.com/joltgeorge/tss/keygen"
"github.com/joltgeorge/tss/keysign"
)
type MockTssServer struct {
failToStart bool
failToKeyGen bool
failToKeySign bool
}
func (mts *MockTssServer) Start() error {
if mts.failToStart {
return errors.New("you ask for it")
}
return nil
}
func (mts *MockTssServer) Stop() {
}
func (mts *MockTssServer) GetLocalPeerID() string {
return conversion.GetRandomPeerID().String()
}
func (mts *MockTssServer) Keygen(req keygen.Request) (keygen.Response, error) {
if mts.failToKeyGen {
return keygen.Response{}, errors.New("you ask for it")
}
return keygen.NewResponse(conversion.GetRandomPubKey(), "whatever", common.Success, blame.Blame{}), nil
}
func (mts *MockTssServer) KeySign(req keysign.Request) (keysign.Response, error) {
if mts.failToKeySign {
return keysign.Response{}, errors.New("you ask for it")
}
newSig := keysign.NewSignature("", "", "", "")
return keysign.NewResponse([]keysign.Signature{newSig}, common.Success, blame.Blame{}), nil
}