1- package test
1+ package dirkdaemon
22
33import (
44 "context"
55 "fmt"
6- "net"
76 "path/filepath"
87
9- "github.com/attestantio/dirk/testing/daemon"
108 "github.com/attestantio/dirk/testing/logger"
9+ "github.com/jshufro/remote-signer-dirk-interop/test/dirkdaemon/proc"
1110)
1211
13- func getUnusedPort () (uint32 , error ) {
14- listener , err := net .Listen ("tcp" , "localhost:0" )
15- if err != nil {
16- return 0 , fmt .Errorf ("failed to get unused port: %w" , err )
17- }
18- defer func () { _ = listener .Close () }()
19- return uint32 (listener .Addr ().(* net.TCPAddr ).Port ), nil
12+ var ports = map [int ]uint32 {
13+ 1 : 34925 ,
14+ 2 : 33015 ,
15+ 3 : 42923 ,
16+ 4 : 46453 ,
17+ 5 : 41283 ,
2018}
2119
2220func StartDaemons (ctx context.Context , tmpdir string ) (map [uint64 ]string , map [int ]* logger.LogCapture , error ) {
23- portMap := make (map [int ]uint32 )
2421 logCaptureMap := make (map [int ]* logger.LogCapture )
25- for id := 1 ; id <= 5 ; id ++ {
26- port , err := getUnusedPort ()
27- if err != nil {
28- return nil , nil , fmt .Errorf ("failed to get unused port: %w" , err )
29- }
30- portMap [id ] = port
31- }
3222 peerMap := make (map [uint64 ]string )
33- for id , port := range portMap {
23+ for id , port := range ports {
3424 peerMap [uint64 (id )] = fmt .Sprintf ("signer-test%02d:%d" , id , port )
3525 }
36- for id , port := range portMap {
26+ for id , port := range ports {
3727 walletPath := filepath .Join (tmpdir , fmt .Sprintf ("signer-test%02d" , id ))
3828 logCapture , err := newDirkDaemon (ctx , uint64 (id ), port , walletPath , peerMap )
3929 if err != nil {
@@ -45,7 +35,7 @@ func StartDaemons(ctx context.Context, tmpdir string) (map[uint64]string, map[in
4535}
4636
4737func newDirkDaemon (ctx context.Context , id uint64 , port uint32 , tmpdir string , peerMap map [uint64 ]string ) (* logger.LogCapture , error ) {
48- logCapture , _ , err := daemon .New (
38+ logCapture , _ , err := proc .New (
4939 ctx ,
5040 tmpdir ,
5141 id ,
0 commit comments