From 63a152358b26cb9a56616b72b0a6e40d6c0e3f3c Mon Sep 17 00:00:00 2001 From: chrisli30 Date: Fri, 24 Jan 2025 13:05:45 -0800 Subject: [PATCH 1/2] Fixed test failures caused by disallowing trigger of Completed status --- tests/getExecutions.test.ts | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/tests/getExecutions.test.ts b/tests/getExecutions.test.ts index f38fabf..4aeb473 100644 --- a/tests/getExecutions.test.ts +++ b/tests/getExecutions.test.ts @@ -49,18 +49,18 @@ describe("getExecutions Tests", () => { afterAll(async () => await removeCreatedWorkflows(client, createdWorkflows)); test("options.limit returns the correct number of executions", async () => { - const countFirstPage = 1; - const blockInterval = 5; + const limitOneExecution = 1; + const triggerInterval = 5; const repeatCount = 4; const wallet = await client.getWallet({ salt }); - const blockNumber = await getBlockNumber(); + const currentBlockNumber = await getBlockNumber(); const trigger = TriggerFactory.create({ id: defaultTriggerId, name: "blockTrigger", type: TriggerType.Block, - data: { interval: blockInterval }, + data: { interval: triggerInterval }, }); const workflowId = await client.submitWorkflow( @@ -68,50 +68,47 @@ describe("getExecutions Tests", () => { ...WorkflowTemplate, trigger, smartWalletAddress: wallet.address, + maxExecution: 1000, // Set a high maxExecution to ensure the workflow is not completed; otherwise, mannually triggering a completed workflow will fail }) ); queueForRemoval(createdWorkflows, workflowId); // Get the first page of executions with limit:1 let executions = await client.getExecutions([workflowId], { - limit: countFirstPage, + limit: limitOneExecution, }); expect(executions.result.length).toBe(0); expect(executions.hasMore).toBe(false); - + // Manually trigger the workflow with block number + 20 const result = await client.triggerWorkflow({ id: workflowId, data: { type: TriggerType.Block, - blockNumber: blockNumber, + blockNumber: currentBlockNumber + triggerInterval, }, isBlocking: true, }); // trigger the test {repeatCount} extra time more - for(let i = 0; i < repeatCount; i++){ + for(let i = 1; i <= repeatCount; i++){ await client.triggerWorkflow({ id: workflowId, data: { type: TriggerType.Block, - blockNumber: blockNumber + repeatCount +1 + blockNumber: currentBlockNumber + triggerInterval + repeatCount * triggerInterval, }, isBlocking: true, }); } - console.log("triggerWorkflow.result", result); - // Get the first page of executions with limit:1 executions = await client.getExecutions([workflowId], { - limit: countFirstPage, + limit: limitOneExecution, }); - console.log("executions", executions); - expect(Array.isArray(executions.result)).toBe(true); - expect(executions.result.length).toBe(countFirstPage); + expect(executions.result.length).toBe(limitOneExecution); expect(executions).toHaveProperty("cursor"); expect(executions.hasMore).toBe(true); const firstCursor = executions.cursor; @@ -122,15 +119,12 @@ describe("getExecutions Tests", () => { cursor: firstCursor, }); - console.log("executions2", executions2); - // Verify that the count of the second return is totalCount - limit expect(Array.isArray(executions2.result)).toBe(true); expect(executions2.result.length).toBe(repeatCount); expect(executions2.hasMore).toBe(false); - const secondCursor = executions2.cursor; - - // Make sure there’s no overlap between the two lists + + // Make sure there's no overlap between the two lists expect( _.intersection( executions.result.map((item) => item.id), @@ -159,6 +153,7 @@ describe("getExecutions Tests", () => { ...WorkflowTemplate, trigger, smartWalletAddress: wallet.address, + maxExecution: 1000, // Set a high maxExecution to ensure the workflow is not completed; otherwise, mannually triggering a completed workflow will fail }) ); queueForRemoval(createdWorkflows, workflowId); @@ -198,7 +193,7 @@ describe("getExecutions Tests", () => { expect(Array.isArray(executions2.result)).toBe(true); expect(executions2.result.length).toBe(repeatCount - limit); - // Make sure there’s no overlap between the two lists + // Make sure there's no overlap between the two lists expect( _.intersection( executions.result.map((item) => item.id), From 5bcdb8ecd2ee85a6abba7fa598610eed0591fed7 Mon Sep 17 00:00:00 2001 From: chrisli30 Date: Fri, 24 Jan 2025 13:07:33 -0800 Subject: [PATCH 2/2] Bump up the sdk-js package version to 1.3.3 --- packages/sdk-js/CHANGELOG.md | 6 ++++++ packages/sdk-js/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sdk-js/CHANGELOG.md b/packages/sdk-js/CHANGELOG.md index 0abf165..a757f14 100644 --- a/packages/sdk-js/CHANGELOG.md +++ b/packages/sdk-js/CHANGELOG.md @@ -1,5 +1,11 @@ # @avaprotocol/sdk-js +## 1.3.3 + +### Patch Changes + +- update the new auth method and trigger matcher array + ## 1.3.2 ### Patch Changes diff --git a/packages/sdk-js/package.json b/packages/sdk-js/package.json index 895ecdf..9afa3f4 100644 --- a/packages/sdk-js/package.json +++ b/packages/sdk-js/package.json @@ -1,6 +1,6 @@ { "name": "@avaprotocol/sdk-js", - "version": "1.3.2", + "version": "1.3.3", "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS", "main": "dist/index.js", "types": "dist/index.d.ts",