From 286f292c5ee7536b2e4312d1991cde58c38be3aa Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Fri, 25 Oct 2024 21:06:49 +0200 Subject: [PATCH] add comment about tests and skip them again for the ci --- README.md | 8 + .../worker-api/src/integriteeWorker.spec.ts | 210 +++++++++--------- packages/worker-api/src/worker.spec.ts | 2 +- 3 files changed, 115 insertions(+), 105 deletions(-) diff --git a/README.md b/README.md index 72a598fc..594f5b38 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,14 @@ The worker uses the webcrypto api if it is run in the browser. This library is o defined if you access the webpage with `localhost` in firefox. It is not available on `127.0.0.1` or `0.0.0.0` due to browser security policies. +## Testing +Use the below command to only execute a particular test suite. + + +```bash +// execute worker tests +yarn test --runTestsByPath packages/worker-api/src/integriteeWorker.spec.ts +``` ```bash yarn add @encointer/node-api @encointer/worker-api diff --git a/packages/worker-api/src/integriteeWorker.spec.ts b/packages/worker-api/src/integriteeWorker.spec.ts index 37b42e8f..1cdfd156 100644 --- a/packages/worker-api/src/integriteeWorker.spec.ts +++ b/packages/worker-api/src/integriteeWorker.spec.ts @@ -42,79 +42,79 @@ describe('worker', () => { // skip it, as this requires a worker (and hence a node) to be running // To my knowledge jest does not have an option to run skipped tests specifically, does it? // Todo: add proper CI to test this too. - describe('needs worker and node running', () => { - // describe('getWorkerPubKey', () => { - // it('should return value', async () => { - // const result = await worker.getShieldingKey(); - // // console.log('Shielding Key', result); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('getShardVault', () => { - // it('should return value', async () => { - // const result = await worker.getShardVault(); - // console.log('ShardVault', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('getNonce', () => { - // it('should return value', async () => { - // const result = await worker.getNonce(alice, network.shard); - // console.log('Nonce', result.toHuman); - // expect(result).toBeDefined(); - // }); - // }); - // - // - // describe('getAccountInfo', () => { - // it('should return value', async () => { - // const result = await worker.getAccountInfo(alice, network.shard); - // console.log('getAccountInfo', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('accountInfoGetter', () => { - // it('should return value', async () => { - // const getter = await worker.accountInfoGetter(charlie, network.shard); - // console.log(`AccountInfoGetter: ${JSON.stringify(getter)}`); - // const result = await getter.send(); - // console.log('getAccountInfo:', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('parentchainsInfoGetter', () => { - // it('should return value', async () => { - // const getter = worker.parentchainsInfoGetter(network.shard); - // console.log(`parentchainsInfoGetter: ${JSON.stringify(getter)}`); - // const result = await getter.send(); - // console.log('parentchainsInfoGetter:', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('guessTheNumberInfoGetter', () => { - // it('should return value', async () => { - // const getter = worker.guessTheNumberInfoGetter(network.shard); - // console.log(`GuessTheNumberInfo: ${JSON.stringify(getter)}`); - // const result = await getter.send(); - // console.log('GuessTheNumberInfo:', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('guessTheNumberAttemptsGetter', () => { - // it('should return value', async () => { - // const getter = await worker.guessTheNumberAttemptsTrustedGetter(charlie, network.shard); - // console.log(`Attempts: ${JSON.stringify(getter)}`); - // const result = await getter.send(); - // console.log('Attempts:', result.toHuman()); - // expect(result).toBeDefined(); - // }); - // }); + describe.skip('needs worker and node running', () => { + describe('getWorkerPubKey', () => { + it('should return value', async () => { + const result = await worker.getShieldingKey(); + // console.log('Shielding Key', result); + expect(result).toBeDefined(); + }); + }); + + describe('getShardVault', () => { + it('should return value', async () => { + const result = await worker.getShardVault(); + console.log('ShardVault', result.toHuman()); + expect(result).toBeDefined(); + }); + }); + + describe('getNonce', () => { + it('should return value', async () => { + const result = await worker.getNonce(alice, network.shard); + console.log('Nonce', result.toHuman); + expect(result).toBeDefined(); + }); + }); + + + describe('getAccountInfo', () => { + it('should return value', async () => { + const result = await worker.getAccountInfo(alice, network.shard); + console.log('getAccountInfo', result.toHuman()); + expect(result).toBeDefined(); + }); + }); + + describe('accountInfoGetter', () => { + it('should return value', async () => { + const getter = await worker.accountInfoGetter(charlie, network.shard); + console.log(`AccountInfoGetter: ${JSON.stringify(getter)}`); + const result = await getter.send(); + console.log('getAccountInfo:', result.toHuman()); + expect(result).toBeDefined(); + }); + }); + + describe('parentchainsInfoGetter', () => { + it('should return value', async () => { + const getter = worker.parentchainsInfoGetter(network.shard); + console.log(`parentchainsInfoGetter: ${JSON.stringify(getter)}`); + const result = await getter.send(); + console.log('parentchainsInfoGetter:', result.toHuman()); + expect(result).toBeDefined(); + }); + }); + + describe('guessTheNumberInfoGetter', () => { + it('should return value', async () => { + const getter = worker.guessTheNumberInfoGetter(network.shard); + console.log(`GuessTheNumberInfo: ${JSON.stringify(getter)}`); + const result = await getter.send(); + console.log('GuessTheNumberInfo:', result.toHuman()); + expect(result).toBeDefined(); + }); + }); + + describe('guessTheNumberAttemptsGetter', () => { + it('should return value', async () => { + const getter = await worker.guessTheNumberAttemptsTrustedGetter(charlie, network.shard); + console.log(`Attempts: ${JSON.stringify(getter)}`); + const result = await getter.send(); + console.log('Attempts:', result.toHuman()); + expect(result).toBeDefined(); + }); + }); describe('balance transfer should work', () => { it('should return value', async () => { @@ -132,36 +132,38 @@ describe('worker', () => { }); }); - // describe('balance unshield should work', () => { - // it('should return value', async () => { - // const shard = network.shard; - // - // const result = await worker.balanceUnshieldFunds( - // alice, - // shard, - // network.mrenclave, - // alice.address, - // charlie.address, - // 1100000000000, - // ); - // console.log('balance unshield result', JSON.stringify(result)); - // expect(result).toBeDefined(); - // }); - // }); - // - // describe('guess the number should work', () => { - // it('should return value', async () => { - // const shard = network.shard; - // - // const result = await worker.guessTheNumber( - // alice, - // shard, - // network.mrenclave, - // 1, - // ); - // console.log('guess the number result', JSON.stringify(result)); - // expect(result).toBeDefined(); - // }); - // }); + // race condition so skipped + describe.skip('balance unshield should work', () => { + it('should return value', async () => { + const shard = network.shard; + + const result = await worker.balanceUnshieldFunds( + alice, + shard, + network.mrenclave, + alice.address, + charlie.address, + 1100000000000, + ); + console.log('balance unshield result', JSON.stringify(result)); + expect(result).toBeDefined(); + }); + }); + + // race condition, so skipped + describe.skip('guess the number should work', () => { + it('should return value', async () => { + const shard = network.shard; + + const result = await worker.guessTheNumber( + alice, + shard, + network.mrenclave, + 1, + ); + console.log('guess the number result', JSON.stringify(result)); + expect(result).toBeDefined(); + }); + }); }); }); diff --git a/packages/worker-api/src/worker.spec.ts b/packages/worker-api/src/worker.spec.ts index 31cb5aa1..5566e099 100644 --- a/packages/worker-api/src/worker.spec.ts +++ b/packages/worker-api/src/worker.spec.ts @@ -36,7 +36,7 @@ describe('worker', () => { // skip it, as this requires a worker (and hence a node) to be running // To my knowledge jest does not have an option to run skipped tests specifically, does it? // Todo: add proper CI to test this too. - describe('needs worker and node running', () => { + describe.skip('needs worker and node running', () => { describe('getWorkerPubKey', () => { it('should return value', async () => { const result = await worker.getShieldingKey();