@@ -11,6 +11,24 @@ import MockOTNode from '../../utilities/MockOTNode.mjs';
1111
1212const stepsUtils = new StepsUtils ( ) ;
1313
14+ /**
15+ * Extracts the first blockchain configuration for use with DkgClientHelper.
16+ * @param {Object } localBlockchains - The localBlockchains state object
17+ * @returns {Object } Blockchain config with name, publicKey, privateKey, and rpc
18+ */
19+ function getFirstBlockchainConfig ( localBlockchains ) {
20+ const firstBlockchainId = Object . keys ( localBlockchains ) [ 0 ] ;
21+ const firstBlockchain = localBlockchains [ firstBlockchainId ] ;
22+ const firstWallet = firstBlockchain . getWallets ( ) [ 0 ] ;
23+
24+ return {
25+ name : firstBlockchainId ,
26+ publicKey : firstWallet . address ,
27+ privateKey : firstWallet . privateKey ,
28+ rpc : `http://localhost:${ firstBlockchain . port } ` ,
29+ } ;
30+ }
31+
1432Given (
1533 / ^ I s e t u p ( \d + ) [ a d d i t i o n a l ] * n o d e [ s ] * $ / ,
1634 { timeout : 30000 } ,
@@ -80,23 +98,13 @@ Given(
8098 } ;
8199 } ) ;
82100
83- // Get the first blockchain for the DKG client config
84- const firstBlockchainId = Object . keys ( this . state . localBlockchains ) [ 0 ] ;
85- const firstBlockchain = this . state . localBlockchains [ firstBlockchainId ] ;
86- const firstWallet = firstBlockchain . getWallets ( ) [ 0 ] ;
87-
88101 const client = new DkgClientHelper ( {
89102 endpoint : 'http://localhost' ,
90103 port : rpcPort ,
91104 maxNumberOfRetries : 5 ,
92105 frequency : 2 ,
93106 contentType : 'all' ,
94- blockchain : {
95- name : firstBlockchainId ,
96- publicKey : firstWallet . address ,
97- privateKey : firstWallet . privateKey ,
98- rpc : `http://localhost:${ firstBlockchain . port } ` ,
99- } ,
107+ blockchain : getFirstBlockchainConfig ( this . state . localBlockchains ) ,
100108 } ) ;
101109
102110 this . state . nodes [ nodeIndex ] = {
@@ -161,23 +169,13 @@ Given(
161169 try {
162170 await nodeInstance . start ( ) ; // This will skip startNetworkModule
163171
164- // Get the first blockchain for the DKG client config
165- const firstBlockchainId = Object . keys ( this . state . localBlockchains ) [ 0 ] ;
166- const firstBlockchain = this . state . localBlockchains [ firstBlockchainId ] ;
167- const firstWallet = firstBlockchain . getWallets ( ) [ 0 ] ;
168-
169172 const client = new DkgClientHelper ( {
170173 endpoint : 'http://localhost' ,
171174 port : rpcPort ,
172175 useSSL : false ,
173176 timeout : 25 ,
174177 loglevel : 'trace' ,
175- blockchain : {
176- name : firstBlockchainId ,
177- publicKey : firstWallet . address ,
178- privateKey : firstWallet . privateKey ,
179- rpc : `http://localhost:${ firstBlockchain . port } ` ,
180- } ,
178+ blockchain : getFirstBlockchainConfig ( this . state . localBlockchains ) ,
181179 } ) ;
182180
183181 this . state . bootstraps . push ( {
0 commit comments