Skip to content

Commit

Permalink
test(connector-fabric): fix rename type to responseType getBlockV1()
Browse files Browse the repository at this point in the history
The system chaincode query method's returns were not decoded correctly
because the test request assembling code was not updated to call the
responseType as such (old name was type)

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Jul 17, 2024
1 parent c8b33c8 commit 5660c4e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,19 @@ describe("Query system chain methods and endpoints tests", () => {
* Can be reused throughout the tests.
*
* @param query how to find requested block
* @param type response type requested
* @param responseType response type requested
*
* @returns block object / block buffer
*/
async function getBlock(
query: GetBlockRequestV1Query,
type: GetBlockResponseTypeV1 = GetBlockResponseTypeV1.Full,
responseType: GetBlockResponseTypeV1 = GetBlockResponseTypeV1.Full,
): Promise<any> {
const getBlockReq = {
channelName: ledgerChannelName,
gatewayOptions,
query,
type,
responseType,
};

const getBlockResponse = await apiClient.getBlockV1(getBlockReq);
Expand All @@ -248,7 +248,7 @@ describe("Query system chain methods and endpoints tests", () => {
expect(getBlockResponse.status).toEqual(200);
expect(getBlockResponse.data).toBeTruthy();

switch (type) {
switch (responseType) {
case GetBlockResponseTypeV1.Full:
if (!("decodedBlock" in getBlockResponse.data)) {
throw new Error(
Expand Down Expand Up @@ -283,7 +283,7 @@ describe("Query system chain methods and endpoints tests", () => {
return getBlockResponse.data.cactiFullEvents;
default:
// Will not compile if any type was not handled by above switch.
const unknownType: never = type;
const unknownType: never = responseType;
const validTypes = Object.keys(GetBlockResponseTypeV1).join(";");
const errorMessage = `Unknown get block response type '${unknownType}'. Accepted types for GetBlockResponseTypeV1 are: [${validTypes}]`;
throw new Error(errorMessage);
Expand Down

0 comments on commit 5660c4e

Please sign in to comment.