Skip to content

Commit

Permalink
ensure endorsetimeout is set on v2 fabric connector
Browse files Browse the repository at this point in the history
  • Loading branch information
D committed Mar 2, 2022
1 parent 71a5a87 commit 8607762
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class V2FabricGateway extends ConnectorBase {
enabled: connectionProfileDefinition.isDynamicConnectionProfile()
},
eventHandlerOptions: {
endorseTimeout: this.configDefaultTimeout,
commitTimeout: this.configDefaultTimeout,
strategy: EventStrategies[this.configEventStrategy]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const configWith2Orgs1AdminInWalletNotMutual = '../../sample-configs/BasicConfig
const { Gateway, Transaction, Network, Wallets } = require('./V2GatewayStubs');
const GenerateConfiguration = require('../../utils/GenerateConfiguration');
const ConnectorConfigurationFactory = require('../../../lib/connector-configuration/ConnectorConfigurationFactory');
const { ConfigUtil } = require('@hyperledger/caliper-core');

describe('A Node-SDK V2 Fabric Gateway', () => {

Expand Down Expand Up @@ -131,6 +132,33 @@ describe('A Node-SDK V2 Fabric Gateway', () => {
}
});

const checkTimeouts = (connectionArgs, expectedTimeoutValue) => {
connectionArgs.eventHandlerOptions.endorseTimeout.should.equal(expectedTimeoutValue);
connectionArgs.eventHandlerOptions.commitTimeout.should.equal(expectedTimeoutValue);
connectionArgs.queryHandlerOptions.timeout.should.equal(expectedTimeoutValue);
}

it('should create a Gateway with defaults for submit and query timeouts when invokeorquery is not specified', async () => {
const connectorConfiguration = await new ConnectorConfigurationFactory().create(path.resolve(__dirname, configWith2Orgs1AdminInWallet), walletFacadeFactory);
const fabricGateway = new FabricGateway(connectorConfiguration, 1, 'fabric');
const context = await fabricGateway.getContext();
Gateway.constructed.should.equal(4);
for (let i = 0; i < 4; i++) {
checkTimeouts(Gateway.connectArgs[i][1], 60);
}
});

it('should create a Gateway with invokeorquery specified value for submit and query timeouts', async () => {
ConfigUtil.set(ConfigUtil.keys.Fabric.Timeout.InvokeOrQuery, 99);
const connectorConfiguration = await new ConnectorConfigurationFactory().create(path.resolve(__dirname, configWith2Orgs1AdminInWallet), walletFacadeFactory);
const fabricGateway = new FabricGateway(connectorConfiguration, 1, 'fabric');
const context = await fabricGateway.getContext();
Gateway.constructed.should.equal(4);
for (let i = 0; i < 4; i++) {
checkTimeouts(Gateway.connectArgs[i][1], 99);
}
});

it('should disconnect Gateways when a context is released', async () => {
const connectorConfiguration = await new ConnectorConfigurationFactory().create(path.resolve(__dirname, configWith2Orgs1AdminInWallet), walletFacadeFactory);
const fabricGateway = new FabricGateway(connectorConfiguration, 1, 'fabric');
Expand Down

0 comments on commit 8607762

Please sign in to comment.