Skip to content

Commit

Permalink
Fixes required by changes to typing in dependencies (#682)
Browse files Browse the repository at this point in the history
Scheduled build began failing last week, with the typing / import errors related to the version of the long package inherited from the protobuf packages. Add explicit dependencies on the long package and adjust imports accordingly.

Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday committed Sep 4, 2023
1 parent 9bf4de0 commit 8743c2e
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 124 deletions.
4 changes: 2 additions & 2 deletions fabric-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"fabric-protos": "file:../fabric-protos",
"js-sha3": "^0.8.0",
"jsrsasign": "^10.5.25",
"long": "^5.2.3",
"nconf": "^0.12.0",
"promise-settle": "^0.3.0",
"sjcl": "^1.0.8",
Expand Down Expand Up @@ -61,6 +62,5 @@
"type": "Apache-2.0",
"url": "https://github.com/hyperledger/fabric/blob/main/LICENSE"
}
],
"devDependencies": {}
]
}
2 changes: 1 addition & 1 deletion fabric-common/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

import * as Long from 'long';
import Long from 'long';
import * as fabproto6 from 'fabric-protos';
import winston = require('winston');

Expand Down
8 changes: 4 additions & 4 deletions fabric-common/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node10/tsconfig.json",
"compilerOptions": {
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"declaration": true,
"noImplicitAny": true,
"declarationMap": true,
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"*": [
Expand Down
4 changes: 2 additions & 2 deletions fabric-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"fabric-common": "file:../fabric-common",
"fabric-protos": "file:../fabric-protos",
"long": "^5.2.3",
"nano": "^9.0.5"
},
"nyc": {
Expand Down Expand Up @@ -54,6 +55,5 @@
"type": "Apache-2.0",
"url": "https://github.com/hyperledger/fabric/blob/master/LICENSE"
}
],
"devDependencies": {}
]
}
2 changes: 1 addition & 1 deletion fabric-network/src/checkpointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as Long from 'long';
import Long from 'long';

export interface Checkpointer {
addTransactionId(transactionId: string): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {BlockType, Endorser} from 'fabric-common';
import * as fabproto6 from 'fabric-protos';
import {Checkpointer} from './checkpointer';
import * as Long from 'long';
import Long from 'long';

export type EventType = BlockType;

Expand Down
2 changes: 1 addition & 1 deletion fabric-network/src/impl/event/blockeventsource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {newFullBlockEvent} from './fullblockeventfactory';
import {OrderedBlockQueue} from './orderedblockqueue';
import {newPrivateBlockEvent} from './privateblockeventfactory';
import {notNullish} from '../gatewayutils';
import * as Long from 'long';
import Long from 'long';

const logger = Logger.getLogger('BlockEventSource');

Expand Down
2 changes: 1 addition & 1 deletion fabric-network/src/impl/event/commitlistenersession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class CommitListenerSession implements ListenerSession {
return startErrors;
}

private async startEventService(eventService: EventService): Promise<CommitError|undefined> {
private async startEventService(eventService: EventService): Promise<CommitError|void> {
try {
await this.eventServiceManager.startEventService(eventService);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/src/impl/event/orderedblockqueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import {BlockEvent} from '../../events';
import * as Long from 'long';
import Long from 'long';

export class OrderedBlockQueue {
private readonly queue = new Map<string, BlockEvent>();
Expand Down
4 changes: 2 additions & 2 deletions fabric-network/src/impl/filecheckpointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import {Checkpointer} from '../checkpointer';
import * as Long from 'long';
import Long from 'long';
import * as fs from 'fs';

const encoding = 'utf8';
Expand Down Expand Up @@ -58,7 +58,7 @@ export class FileCheckpointer implements Checkpointer {
}
}

private async readFile(): Promise<Buffer | undefined> {
private async readFile(): Promise<Buffer | void> {
try {
return await fs.promises.readFile(this.path);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/event/commitlistener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Client,
Eventer
} from 'fabric-common';
import * as Long from 'long';
import Long from 'long';

import {NetworkImpl} from '../../../src/network';
import {EventServiceManager} from '../../../src/impl/event/eventservicemanager';
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/event/contractlistener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import * as sinon from 'sinon';
import {expect} from 'chai';
import * as Long from 'long';
import Long from 'long';

import {Channel, Client, Endorser, Eventer, EventInfo, IdentityContext} from 'fabric-common';
import * as fabproto6 from 'fabric-protos';
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/event/listeners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as Listeners from '../../../src/impl/event/listeners';
import {StubCheckpointer} from './stubcheckpointer';
import {BlockEvent, BlockListener, TransactionEvent, ContractEvent} from '../../../src/events';
import * as Long from 'long';
import Long from 'long';
import * as chai from 'chai';
import * as sinon from 'sinon';

Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/event/orderedblockqueue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {BlockEvent} from '../../../src/events';
import {OrderedBlockQueue} from '../../../src/impl/event/orderedblockqueue';
import * as Long from 'long';
import Long from 'long';

import * as chai from 'chai';
const expect = chai.expect;
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/event/stubcheckpointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import {Checkpointer} from '../../../src/checkpointer';
import * as Long from 'long';
import Long from 'long';

export class StubCheckpointer implements Checkpointer {
private blockNumber: Long;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
EventInfo,
IdentityContext
} from 'fabric-common';
import * as Long from 'long';
import Long from 'long';

import {Gateway, ConnectedGatewayOptions} from '../../../src/gateway';
import {Network, NetworkImpl} from '../../../src/network';
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/test/impl/filecheckpointer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {Checkpointer} from '../../src/checkpointer';
import {DefaultCheckpointers} from '../../src/defaultcheckpointers';
import * as testUtils from '../testutils';
import * as Long from 'long';
import Long from 'long';
import * as path from 'path';
import * as fs from 'fs';
import * as chai from 'chai';
Expand Down
7 changes: 6 additions & 1 deletion fabric-network/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"extends": "@tsconfig/node10/tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"outDir": "./lib",
"rootDir": "./src",
"sourceMap": true
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"ink-docstrap": "^1.3.2",
"jsdoc": "^3.6.6",
"jsrsasign": "^10.5.25",
"long": "^5.2.3",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.0",
Expand Down
79 changes: 0 additions & 79 deletions test/ts-scenario/src/steps/channel_operations.ts

This file was deleted.

8 changes: 3 additions & 5 deletions test/ts-scenario/src/steps/lib/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as Constants from '../constants';
import * as GatewayHelper from './gateway';
import * as BaseUtils from './utility/baseUtils';
import {StateStore} from './utility/stateStore';
import * as Long from 'long';
import Long from 'long';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
Expand Down Expand Up @@ -263,10 +263,8 @@ export function checkContractListenerPayloads(listenerName: string, checkData: s
const contractEvents: ContractEvent[] = listenerObject.payloads;

const found = contractEvents.some((contractEvent) => {
if (contractEvent.payload) {
// Check a contract event payload is what we expect
return contractEvent.payload.toString() === checkData;
}
// Check a contract event payload is what we expect
return contractEvent.payload?.toString() === checkData;
});

if (found) {
Expand Down
2 changes: 1 addition & 1 deletion test/ts-scenario/src/steps/lib/utility/clientUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
StartRequestOptions, SendEventOptions, BuildProposalRequest, SendProposalRequest, EventRegistrationOptions, EventListener
} from 'fabric-common';
import * as fs from 'fs';
import * as Long from 'long';
import Long from 'long';
import * as Constants from '../../constants';
import * as BaseUtils from './baseUtils';
import {CommonConnectionProfileHelper} from './commonConnectionProfileHelper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ export class CommonConnectionProfileHelper {

/**
* Retrieve all the peers named in the profile
* @return {Object[]} the peers named in the profile
* @return {Record<string, any>} the peers named in the profile
*/
public getPeers(): any[] {
return this.profile.peers;
public getPeers(): Record<string, any> {
return this.profile.peers ?? {};
}

/**
Expand All @@ -205,7 +205,7 @@ export class CommonConnectionProfileHelper {
* @return {Object} the peer object
*/
public getPeer(peerName: string): Endpoint {
return this.profile.peers[peerName];
return this.getPeers()[peerName];
}

/**
Expand All @@ -229,16 +229,13 @@ export class CommonConnectionProfileHelper {
/**
* check if the CCP is for a TLS network
*/
public isTls(): boolean | undefined {
const peers: any = this.getPeers();
if (peers) {
for (const key of Object.keys(peers as Record<string, unknown>)) {
const peer: any = peers[key];
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
return (peer.url).includes('grpcs');
}
} else {
throw new Error('No peers listed in the CCP');
public isTls(): boolean {
const peers = this.getPeers();
for (const peer of Object.values(peers)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
return peer.url.includes('grpcs');
}

throw new Error('No peers listed in the CCP');
}
}
6 changes: 5 additions & 1 deletion test/ts-scenario/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node10/tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"outDir": "lib",
"rootDir": "src"
}
Expand Down

0 comments on commit 8743c2e

Please sign in to comment.