Skip to content

TestChaincodeStub.getObjectsByPartialCompositeKeyWithPagination ignores limit and bookmark #655

Description

@sentientforest

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<StateQueryResponse<Iterators.StateQueryIterator>> & AsyncIterable<Iterators.KV> {

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<T extends ChainObject>(
  ctx: GalaChainContext,
  objectType: string,
  attributes: string[],
  constructor: ClassConstructor<Inferred<T, ChainObject>>,
  bookmark: string | undefined,
  limit: number = TOTAL_RESULTS_LIMIT
): Promise<{ results: Array<T>; 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions