From f4ca0a63d1c99fc796e62e887b02b390a280cc9d Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 21:08:52 +0100 Subject: [PATCH 1/6] ci: use fdp-play --- .github/workflows/tests.yaml | 7 +++---- package.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 914aa16d..8a120d8d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,11 +36,10 @@ jobs: cache: 'npm' - name: Install npm deps - run: npm install -g npm && npm ci && npm install -g @ethersphere/bee-factory + run: npm install -g npm && npm ci && npm install -g @fairdatasociety/fdp-play - # Start Bee Factory environment - - name: Start Bee Factory environment - run: npm run bee -- --verbose --detach + - name: Start fdp-play environment + run: npm run bee - name: Tests run: npm run test diff --git a/package.json b/package.json index 050a5b28..855241d2 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"", "depcheck": "depcheck .", - "bee": "npx bee-factory start" + "bee": "npx fdp-play start --detach --bee-version 1.8.2" }, "dependencies": { "@ethersphere/swarm-cid": "^0.1.0", From aaca73554ee134fc5ad329690194334d7d3ae089 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 21:14:39 +0100 Subject: [PATCH 2/6] ci: run tests with node 16 and 18 --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8a120d8d..e933bf24 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,7 +21,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x] + node-version: [16.x, 18.x] steps: - name: Checkout From db143f08444ec1f59df55ecefd7853abc6cce779 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 21:15:56 +0100 Subject: [PATCH 3/6] ci: run tests with node 18 --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e933bf24..973f7eb5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,7 +21,7 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [18.x] steps: - name: Checkout From 59b606dc019c62cdc477d16cdf581abe81adf87a Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 21:35:19 +0100 Subject: [PATCH 4/6] chore: bump bee version --- package.json | 4 ++-- src/modules/debug/status.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 855241d2..e4f817f7 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"", "depcheck": "depcheck .", - "bee": "npx fdp-play start --detach --bee-version 1.8.2" + "bee": "npx fdp-play start --detach --bee-version 1.18.2" }, "dependencies": { "@ethersphere/swarm-cid": "^0.1.0", @@ -129,6 +129,6 @@ "npm": ">=6.0.0", "beeApiVersion": "4.0.0", "beeDebugApiVersion": "4.0.0", - "bee": "1.13.0-f1067884" + "bee": "1.18.2-759f56f" } } diff --git a/src/modules/debug/status.ts b/src/modules/debug/status.ts index 1c12ed19..02ef0e04 100644 --- a/src/modules/debug/status.ts +++ b/src/modules/debug/status.ts @@ -6,7 +6,7 @@ import { http } from '../../utils/http' // Following lines bellow are automatically updated with GitHub Action when Bee version is updated // so if you are changing anything about them change the `update_bee` action accordingly! -export const SUPPORTED_BEE_VERSION_EXACT = '1.13.0-f1067884' +export const SUPPORTED_BEE_VERSION_EXACT = '1.18.2-759f56f' export const SUPPORTED_API_VERSION = '4.0.0' export const SUPPORTED_DEBUG_API_VERSION = '4.0.0' From 2c9843b4e3c79695c9ce46db9a9d11693822a672 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 21:44:27 +0100 Subject: [PATCH 5/6] ci: use fresh and latest bee nodes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e4f817f7..1983f73c 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"", "depcheck": "depcheck .", - "bee": "npx fdp-play start --detach --bee-version 1.18.2" + "bee": "npx fdp-play start --detach --fresh" }, "dependencies": { "@ethersphere/swarm-cid": "^0.1.0", From f32fca71776e7364819a3e99a42a335fb7f5a57c Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Wed, 6 Mar 2024 22:23:22 +0100 Subject: [PATCH 6/6] test(fix): fix tests --- src/utils/type.ts | 31 +++++------------------- test/integration/modules/bzz.spec.ts | 2 +- test/integration/modules/pinning.spec.ts | 18 +++++++------- test/integration/modules/tag.spec.ts | 19 ++++++++++----- 4 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/utils/type.ts b/src/utils/type.ts index 41e69b73..11ca6f49 100644 --- a/src/utils/type.ts +++ b/src/utils/type.ts @@ -1,11 +1,11 @@ import { decodeCid, encodeReference, ReferenceType } from '@ethersphere/swarm-cid' import { Address, - AddressPrefix, ADDRESS_HEX_LENGTH, + AddressPrefix, AllTagsOptions, - BatchId, BATCH_ID_HEX_LENGTH, + BatchId, BeeRequestOptions, CashoutOptions, CollectionUploadOptions, @@ -13,14 +13,14 @@ import { FileUploadOptions, NumberString, PostageBatchOptions, - PssMessageHandler, PSS_TARGET_HEX_LENGTH_MAX, + PssMessageHandler, PUBKEY_HEX_LENGTH, PublicKey, Readable, Reference, - ReferenceOrEns, REFERENCE_HEX_LENGTH, + ReferenceOrEns, Tag, TAGS_LIMIT_MAX, TAGS_LIMIT_MIN, @@ -51,17 +51,7 @@ export function isObject(value: unknown): value is Record { return value !== null && typeof value === 'object' } -/** - * Generally it is discouraged to use `object` type, but in this case I think - * it is best to do so as it is possible to easily convert from `object`to other - * types, which will be usually the case after asserting that the object is - * strictly object. With for example Record you have to first - * cast it to `unknown` which I think bit defeat the purpose. - * - * @param value - */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function isStrictlyObject(value: unknown): value is object { +export function isStrictlyObject(value: unknown): value is Record { return isObject(value) && !Array.isArray(value) } @@ -301,16 +291,7 @@ export function isTag(value: unknown): value is Tag { return false } - const tag = value as Record - - const numberProperties = ['total', 'processed', 'synced', 'uid'] - const correctNumberProperties = numberProperties.every(numberProperty => typeof tag[numberProperty] === 'number') - - if (!correctNumberProperties || !tag.startedAt || typeof tag.startedAt !== 'string') { - return false - } - - return true + return !!value.uid } export function assertTag(value: unknown): asserts value is Tag { diff --git a/test/integration/modules/bzz.spec.ts b/test/integration/modules/bzz.spec.ts index 815f3df1..5f8f96db 100644 --- a/test/integration/modules/bzz.spec.ts +++ b/test/integration/modules/bzz.spec.ts @@ -228,7 +228,7 @@ describe('modules/bzz', () => { // Relates to how many chunks is uploaded which depends on manifest serialization. // https://github.com/ethersphere/bee/pull/1501#discussion_r611385602 - const EXPECTED_TAGS_COUNT = 6 + const EXPECTED_TAGS_COUNT = 2 const data = randomByteArray(5000, 2) const filename = 'hello.txt' diff --git a/test/integration/modules/pinning.spec.ts b/test/integration/modules/pinning.spec.ts index 6c4c7094..4a7ed92f 100644 --- a/test/integration/modules/pinning.spec.ts +++ b/test/integration/modules/pinning.spec.ts @@ -35,11 +35,11 @@ describe('modules/pin', () => { it('should not pin a non-existing file', async function () { this.timeout(ERR_TIMEOUT) - await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should not unpin a non-existing file', async function () { - await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) }) @@ -68,11 +68,11 @@ describe('modules/pin', () => { it('should not pin a non-existing collections', async function () { this.timeout(ERR_TIMEOUT) - await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should not unpin a non-existing collections', async function () { - await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) }) @@ -92,11 +92,11 @@ describe('modules/pin', () => { it('should not pin a non-existing data', async function () { this.timeout(ERR_TIMEOUT) - await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should not unpin a non-existing data', async function () { - await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) }) @@ -118,11 +118,11 @@ describe('modules/pin', () => { it('should not pin a non-existing chunk', async function () { this.timeout(ERR_TIMEOUT) - await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.pin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should not unpin a non-existing chunk', async function () { - await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.unpin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should return pinning status of existing chunk', async function () { @@ -135,7 +135,7 @@ describe('modules/pin', () => { }) it('should not return pinning status of non-existing chunk', async function () { - await expect(pinning.getPin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 404') + await expect(pinning.getPin(BEE_KY_OPTIONS, invalidReference)).rejectedWith('Request failed with status code 500') }) it('should return list of pinned chunks', async function () { diff --git a/test/integration/modules/tag.spec.ts b/test/integration/modules/tag.spec.ts index ec292962..53c05eab 100644 --- a/test/integration/modules/tag.spec.ts +++ b/test/integration/modules/tag.spec.ts @@ -15,11 +15,14 @@ describe('modules/tag', () => { jestExpect(tags).toEqual( jestExpect.arrayContaining([ jestExpect.objectContaining({ - total: jestExpect.any(Number), - processed: jestExpect.any(Number), + address: jestExpect.any(String), + seen: jestExpect.any(Number), + sent: jestExpect.any(Number), + split: jestExpect.any(Number), + startedAt: jestExpect.any(String), + stored: jestExpect.any(Number), synced: jestExpect.any(Number), uid: jestExpect.any(Number), - startedAt: jestExpect.any(String), }), ]), ) @@ -31,6 +34,7 @@ describe('modules/tag', () => { expect(tag1.split).to.eql(0) expect(tag1.sent).to.eql(0) expect(tag1.synced).to.eql(0) + expect(tag1.stored).to.eql(0) expect(Number.isInteger(tag1.uid)).to.be.ok() expect(tag1.startedAt).a('string') }) @@ -42,11 +46,14 @@ describe('modules/tag', () => { expect(tag1).to.eql(tag2) jestExpect(tag1).toEqual( jestExpect.objectContaining({ - total: jestExpect.any(Number), - processed: jestExpect.any(Number), + address: jestExpect.any(String), + seen: jestExpect.any(Number), + sent: jestExpect.any(Number), + split: jestExpect.any(Number), + startedAt: jestExpect.any(String), + stored: jestExpect.any(Number), synced: jestExpect.any(Number), uid: jestExpect.any(Number), - startedAt: jestExpect.any(String), }), ) })