GalaChain / GalaChain/sdk

TestChaincodeStub.getObjectsByPartialCompositeKeyWithPagination ignores limit and bookmark

Open
#655 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
TypeScript
Stars
138
Forks
44
Avg merge
1d 16h
Merged PRs (30d)
22

Description

The `TestChaincodeStub` implementation of `getObjectsByPartialCompositeKeyWithPagination` ignores the `limit` and `bookmark` properties:

https://github.com/GalaChain/sdk/blob/main/chain-test/src/unit/TestChaincodeStub.ts#L256-L259

```
getStateByPartialCompositeKeyWithPagination(
indexKey: string,
keyParts: string[]
): Promise> & AsyncIterable {

```

The above is missing the properties we see here:

https://github.com/GalaChain/sdk/blob/main/chaincode/src/utils/state.ts#L191C1-L206C5

```
export async function getObjectsByPartialCompositeKeyWithPagination(
ctx: GalaChainContext,
objectType: string,
attributes: string[],
constructor: ClassConstructor>,
bookmark: string | undefined,
limit: number = TOTAL_RESULTS_LIMIT
): Promise<{ results: Array; metadata: QueryResponseMetadata }> {
// Uses default fabric call. No need for cache support, since Fabric disallows
// this call in submit queries.
const response = ctx.stub.getStateByPartialCompositeKeyWithPagination(
objectType,
attributes,
limit,
bookmark
);
```

When we call `getObjectsByPartialCompositeKey` using a mocked `TestChaincodeStub`, we're unable to mock scenarios where certain objects are retrieved (or not) due to `limit` or `bookmark` values.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.