MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / setupMuxParallel

Function setupMuxParallel

xenomint/mux_test.go:43–131  ·  view source on GitHub ↗
(priv *ca.PrivateKey)

Source from the content-addressed store, hash-verified

41}
42
43func setupMuxParallel(priv *ca.PrivateKey) (
44 bp, miner *nodeRPCInfo, ms *MuxService, err error,
45) {
46 var (
47 nis []proto.Node
48 dht *route.DHTService
49 bpSv, mnSv *rpc.Server
50 )
51 if nis, err = createNodesWithPublicKey(priv.PubKey(), testingNonceDifficulty, 3); err != nil {
52 err = errors.Wrap(err, "failed to setup bench environment: ")
53 return
54 } else if l := len(nis); l != 3 {
55 err = errors.Wrapf(err, "failed to setup bench environment: unexpected length %d", l)
56 return
57 }
58 // Setup block producer RPC and register server address
59 bpSv = rpc.NewServer()
60 if err = bpSv.InitRPCServer(
61 "localhost:0", testingPrivateKeyFile, testingMasterKey,
62 ); err != nil {
63 err = errors.Wrap(err, "failed to setup bench environment: ")
64 return
65 }
66 nis[0].Addr = bpSv.Listener.Addr().String()
67 nis[0].Role = proto.Leader
68 // Setup miner RPC and register server address
69 mnSv = rpc.NewServer()
70 if err = mnSv.InitRPCServer(
71 "localhost:0", testingPrivateKeyFile, testingMasterKey,
72 ); err != nil {
73 err = errors.Wrap(err, "failed to setup bench environment: ")
74 return
75 }
76 nis[1].Addr = mnSv.Listener.Addr().String()
77 nis[1].Role = proto.Miner
78 // Setup client
79 nis[2].Role = proto.Client
80 // Setup global config
81 conf.GConf = &conf.Config{
82 UseTestMasterKey: true,
83 GenerateKeyPair: false,
84 MinNodeIDDifficulty: testingNonceDifficulty,
85 BP: &conf.BPInfo{
86 PublicKey: priv.PubKey(),
87 NodeID: nis[0].ID,
88 Nonce: nis[0].Nonce,
89 },
90 KnownNodes: nis,
91 }
92 // Register DHT service, this will also initialize the public key store
93 if dht, err = route.NewDHTService(
94 testingPublicKeyStoreFile, &con.KMSStorage{}, true,
95 ); err != nil {
96 err = errors.Wrap(err, "failed to setup bench environment: ")
97 return
98 } else if err = bpSv.RegisterService(route.DHTRPCName, dht); err != nil {
99 err = errors.Wrap(err, "failed to setup bench environment: ")
100 return

Callers 2

TestMuxServiceFunction · 0.85

Calls 14

NewDHTServiceFunction · 0.92
SetLocalNodeIDNonceFunction · 0.92
SetNodeAddrCacheFunction · 0.92
SetNodeFunction · 0.92
createNodesWithPublicKeyFunction · 0.85
PubKeyMethod · 0.80
InitRPCServerMethod · 0.80
AddrMethod · 0.80
RegisterServiceMethod · 0.80
CloneBytesMethod · 0.80
ToRawNodeIDMethod · 0.80
NewMuxServiceFunction · 0.70

Tested by

no test coverage detected