Skip to content

Commit c78d0b5

Browse files
committed
[fabric-api-fix] testing
Signed-off-by: David Echelberger <[email protected]>
1 parent 0b369e9 commit c78d0b5

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

server/src/interfaces.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,16 @@ export class ContractAPI {
250250
interfaceVersion: string;
251251

252252
@IsString()
253-
address: string;
253+
@IsOptional()
254+
address?: string;
254255

255256
@IsString()
256-
channel: string;
257+
@IsOptional()
258+
channel?: string;
257259

258260
@IsString()
259-
chaincode: string;
261+
@IsOptional()
262+
chaincode?: string;
260263
}
261264

262265
export class ContractAPIURLs {

server/test/contracts.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,34 @@ describe('Smart Contracts', () => {
101101
});
102102
});
103103

104+
test('Create contract API with Fabric', async () => {
105+
const req: ContractAPI = {
106+
name: 'my-api-fabric',
107+
channel: '0x123',
108+
chaincode: 'chaincode',
109+
interfaceName: 'my-contract',
110+
interfaceVersion: '1.0',
111+
};
112+
const api = {
113+
name: 'my-api-fabric',
114+
message: 'msg1',
115+
} as FireFlyContractAPIResponse;
116+
117+
mockFireFly.createContractAPI.mockResolvedValueOnce(api);
118+
119+
await request(server)
120+
.post('/api/contracts/apifabric')
121+
.send(req)
122+
.expect(202)
123+
.expect({ type: 'message', id: 'msg1' });
124+
125+
expect(mockFireFly.createContractAPI).toHaveBeenCalledWith({
126+
interface: { name: 'my-contract', version: '1.0' },
127+
location: { chaincode: 'chaincode', channel: '0x123' },
128+
name: 'my-api-fabric',
129+
});
130+
});
131+
104132
test('Get contract Interfaces', async () => {
105133
const int = [
106134
{

0 commit comments

Comments
 (0)