@@ -6,14 +6,22 @@ import { ChainSimulatorUtils } from "./utils/test.utils";
66
77const WS_SERVER_URL = `${ config . subscriptionsServiceUrl } ` ;
88
9- // --- Client 4 Configuration (Editable) ---
9+ // --- Test Configuration ---
10+ const verbose = false ; // Set to true to see console logs
11+
1012const client4SubscriptionConfig = {
1113 pool : { from : 0 , size : 25 } ,
1214 events : { from : 0 , size : 25 , shard : 1 } ,
1315 transactions : { from : 0 , size : 25 , status : 'success' } ,
1416 blocks : { from : 0 , size : 25 , shard : 1 } ,
1517} ;
16- // -----------------------------------------
18+ // --------------------------
19+
20+ const log = ( ...args : any [ ] ) => {
21+ if ( verbose ) {
22+ console . log ( ...args ) ;
23+ }
24+ } ;
1725
1826const txResponses : Map < string , any [ ] > = new Map ( ) ;
1927const eventResponses : Map < string , any [ ] > = new Map ( ) ;
@@ -72,24 +80,24 @@ describe('Websocket subscriptions e2e tests (Txs and Events)', () => {
7280 } ) ;
7381
7482 client . on ( "customTransactionUpdate" , ( data : { transactions : any [ ] } ) => {
75- console . log ( `\n💸 ${ clientId } received ${ data . transactions . length } txs` ) ;
83+ log ( `\n💸 ${ clientId } received ${ data . transactions . length } txs` ) ;
7684 receivedTxs . push ( ...data . transactions ) ;
7785 } ) ;
7886
7987 client . on ( "customEventUpdate" , ( data : { events : any [ ] } ) => {
80- console . log ( `\n🔔 ${ clientId } received ${ data . events . length } events` ) ;
88+ log ( `\n🔔 ${ clientId } received ${ data . events . length } events` ) ;
8189 receivedEvents . push ( ...data . events ) ;
8290 } ) ;
8391
8492 client . on ( "connect" , ( ) => {
85- console . log ( `\n ${ clientId } connected.` ) ;
93+ log ( `\n ${ clientId } connected.` ) ;
8694
8795 client . emit ( "subscribeCustomTransactions" , txFilter , ( ack : any ) => {
88- console . log ( ` ACK TXs ${ clientId } :` , ack ) ;
96+ log ( ` ACK TXs ${ clientId } :` , ack ) ;
8997 } ) ;
9098
9199 client . emit ( "subscribeCustomEvents" , eventFilter , ( ack : any ) => {
92- console . log ( ` ACK Events ${ clientId } :` , ack ) ;
100+ log ( ` ACK Events ${ clientId } :` , ack ) ;
93101 } ) ;
94102 } ) ;
95103 } ;
@@ -111,15 +119,14 @@ describe('Websocket subscriptions e2e tests (Txs and Events)', () => {
111119 client . on ( "statsUpdate" , ( data : any ) => generalResponses . stats . push ( data ) ) ;
112120
113121 client . on ( "connect" , ( ) => {
114- console . log ( `\n ${ clientId } connected with specific configs.` ) ;
122+ log ( `\n ${ clientId } connected with specific configs.` ) ;
115123
116- // Max 5 subscriptions per client
117- client . emit ( "subscribePool" , subConfig . pool , ( ack : any ) => console . log ( `ACK Pool ${ clientId } :` , ack ) ) ;
118- client . emit ( "subscribeEvents" , subConfig . events , ( ack : any ) => console . log ( `ACK Events ${ clientId } :` , ack ) ) ;
119- client . emit ( "subscribeTransactions" , subConfig . transactions , ( ack : any ) => console . log ( `ACK Txs ${ clientId } :` , ack ) ) ;
120- client . emit ( "subscribeBlocks" , subConfig . blocks , ( ack : any ) => console . log ( `ACK Blocks ${ clientId } :` , ack ) ) ;
124+ client . emit ( "subscribePool" , subConfig . pool , ( ack : any ) => log ( `ACK Pool ${ clientId } :` , ack ) ) ;
125+ client . emit ( "subscribeEvents" , subConfig . events , ( ack : any ) => log ( `ACK Events ${ clientId } :` , ack ) ) ;
126+ client . emit ( "subscribeTransactions" , subConfig . transactions , ( ack : any ) => log ( `ACK Txs ${ clientId } :` , ack ) ) ;
127+ client . emit ( "subscribeBlocks" , subConfig . blocks , ( ack : any ) => log ( `ACK Blocks ${ clientId } :` , ack ) ) ;
121128
122- client . emit ( "subscribeStats" , ( ack : any ) => console . log ( `ACK Stats ${ clientId } :` , ack ) ) ;
129+ client . emit ( "subscribeStats" , ( ack : any ) => log ( `ACK Stats ${ clientId } :` , ack ) ) ;
123130 } ) ;
124131 } ;
125132
@@ -137,12 +144,11 @@ describe('Websocket subscriptions e2e tests (Txs and Events)', () => {
137144 connectAndSubscribe ( item . key , item . txFilter , item . eventFilter , item . clientId ) ;
138145 }
139146
140- // Initialize General Client (Client 4) using the top-level config
141147 connectAndSubscribeGeneral ( "client4" , client4SubscriptionConfig ) ;
142148
143149 await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
144150
145- console . log ( "\n--- Starting Operations ---" ) ;
151+ log ( "\n--- Starting Operations ---" ) ;
146152
147153 await transferEgld ( config . chainSimulatorUrl , config . aliceAddress , config . bobAddress , 1 ) ;
148154 await transferEgld ( config . chainSimulatorUrl , config . bobAddress , config . aliceAddress , 2 ) ;
0 commit comments