@@ -30,6 +30,7 @@ const configWith2Orgs1AdminInWalletNotMutual = '../../sample-configs/BasicConfig
30
30
const { Gateway, Transaction, Network, Wallets } = require ( './V2GatewayStubs' ) ;
31
31
const GenerateConfiguration = require ( '../../utils/GenerateConfiguration' ) ;
32
32
const ConnectorConfigurationFactory = require ( '../../../lib/connector-configuration/ConnectorConfigurationFactory' ) ;
33
+ const { ConfigUtil } = require ( '@hyperledger/caliper-core' ) ;
33
34
34
35
describe ( 'A Node-SDK V2 Fabric Gateway' , ( ) => {
35
36
@@ -131,6 +132,33 @@ describe('A Node-SDK V2 Fabric Gateway', () => {
131
132
}
132
133
} ) ;
133
134
135
+ const checkTimeouts = ( connectionArgs , expectedTimeoutValue ) => {
136
+ connectionArgs . eventHandlerOptions . endorseTimeout . should . equal ( expectedTimeoutValue ) ;
137
+ connectionArgs . eventHandlerOptions . commitTimeout . should . equal ( expectedTimeoutValue ) ;
138
+ connectionArgs . queryHandlerOptions . timeout . should . equal ( expectedTimeoutValue ) ;
139
+ } ;
140
+
141
+ it ( 'should create a Gateway with defaults for submit and query timeouts when invokeorquery is not specified' , async ( ) => {
142
+ const connectorConfiguration = await new ConnectorConfigurationFactory ( ) . create ( path . resolve ( __dirname , configWith2Orgs1AdminInWallet ) , walletFacadeFactory ) ;
143
+ const fabricGateway = new FabricGateway ( connectorConfiguration , 1 , 'fabric' ) ;
144
+ await fabricGateway . getContext ( ) ;
145
+ Gateway . constructed . should . equal ( 4 ) ;
146
+ for ( let i = 0 ; i < 4 ; i ++ ) {
147
+ checkTimeouts ( Gateway . connectArgs [ i ] [ 1 ] , 60 ) ;
148
+ }
149
+ } ) ;
150
+
151
+ it ( 'should create a Gateway with invokeorquery specified value for submit and query timeouts' , async ( ) => {
152
+ ConfigUtil . set ( ConfigUtil . keys . Fabric . Timeout . InvokeOrQuery , 99 ) ;
153
+ const connectorConfiguration = await new ConnectorConfigurationFactory ( ) . create ( path . resolve ( __dirname , configWith2Orgs1AdminInWallet ) , walletFacadeFactory ) ;
154
+ const fabricGateway = new FabricGateway ( connectorConfiguration , 1 , 'fabric' ) ;
155
+ await fabricGateway . getContext ( ) ;
156
+ Gateway . constructed . should . equal ( 4 ) ;
157
+ for ( let i = 0 ; i < 4 ; i ++ ) {
158
+ checkTimeouts ( Gateway . connectArgs [ i ] [ 1 ] , 99 ) ;
159
+ }
160
+ } ) ;
161
+
134
162
it ( 'should disconnect Gateways when a context is released' , async ( ) => {
135
163
const connectorConfiguration = await new ConnectorConfigurationFactory ( ) . create ( path . resolve ( __dirname , configWith2Orgs1AdminInWallet ) , walletFacadeFactory ) ;
136
164
const fabricGateway = new FabricGateway ( connectorConfiguration , 1 , 'fabric' ) ;
0 commit comments