From 20a5992d76e5a8cf0b119db517a4ff3da87b14e6 Mon Sep 17 00:00:00 2001 From: Zainen Suzuki Date: Thu, 1 Dec 2022 17:23:26 -0800 Subject: [PATCH 1/3] add tests for parsing mode for all testnets, and fail case --- integration-tests/rpc-taquito.spec.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/integration-tests/rpc-taquito.spec.ts b/integration-tests/rpc-taquito.spec.ts index 61c71a003a..f7f8152034 100644 --- a/integration-tests/rpc-taquito.spec.ts +++ b/integration-tests/rpc-taquito.spec.ts @@ -1,8 +1,9 @@ import { CONFIGS } from "./config"; import { RpcClient } from '@taquito/rpc'; +import { HttpResponseError } from "@taquito/http-utils"; -CONFIGS().forEach(({ rpc }) => { +CONFIGS().forEach(({ rpc, knownContract }) => { const client = new RpcClient(rpc); describe(`Test Taquito RPC: ${rpc}`, () => { @@ -28,6 +29,25 @@ CONFIGS().forEach(({ rpc }) => { expect(predecessorBlock.hash).toEqual(block.header.predecessor); done(); }) + it('Verify that unparse_mode has no error: Readable', async (done) => { + const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Readable'}) + expect(response.code).toBeDefined(); + done() + }) + it('Verify that unparse_mode has no error: Optimized', async (done) => { + const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Optimized'}) + expect(response.code).toBeDefined(); + done() + }) + it('Verify that unparse_mode has no error: Optimized_legacy', async (done) => { + const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Optimized_legacy'}) + expect(response.code).toBeDefined(); + done() + }) + it('Should fail unparsing_mode not acceptable', async (done) => { + expect(() => client.getNormalizedScript(knownContract, {unparsing_mode: 'else' as any})).rejects.toThrowError(HttpResponseError) + done() + }) }) }) }) From 00ba5cfd5861a7654cbd5b57ee8cdbc484e07cd3 Mon Sep 17 00:00:00 2001 From: Zainen Suzuki Date: Thu, 1 Dec 2022 17:26:24 -0800 Subject: [PATCH 2/3] one more test fail --- integration-tests/rpc-taquito.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-tests/rpc-taquito.spec.ts b/integration-tests/rpc-taquito.spec.ts index f7f8152034..1ae8b59931 100644 --- a/integration-tests/rpc-taquito.spec.ts +++ b/integration-tests/rpc-taquito.spec.ts @@ -48,6 +48,10 @@ CONFIGS().forEach(({ rpc, knownContract }) => { expect(() => client.getNormalizedScript(knownContract, {unparsing_mode: 'else' as any})).rejects.toThrowError(HttpResponseError) done() }) + it('Should fail unparsing_mode not acceptable', async (done) => { + expect(() => client.getNormalizedScript(knownContract, {} as any )).rejects.toThrowError(HttpResponseError) + done() + }) }) }) }) From f7f8a0e0bc3d765e7ee70123ff2c7b469b96222a Mon Sep 17 00:00:00 2001 From: Zainen Suzuki Date: Thu, 1 Dec 2022 17:27:32 -0800 Subject: [PATCH 3/3] format --- integration-tests/rpc-taquito.spec.ts | 94 +++++++++++++-------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/integration-tests/rpc-taquito.spec.ts b/integration-tests/rpc-taquito.spec.ts index 1ae8b59931..841cb43658 100644 --- a/integration-tests/rpc-taquito.spec.ts +++ b/integration-tests/rpc-taquito.spec.ts @@ -4,54 +4,54 @@ import { HttpResponseError } from "@taquito/http-utils"; CONFIGS().forEach(({ rpc, knownContract }) => { - const client = new RpcClient(rpc); + const client = new RpcClient(rpc); - describe(`Test Taquito RPC: ${rpc}`, () => { - describe('Test getBlock', () => { - it('Verify that client.getBlock returns a block using default syntax', async (done) => { - // defaults to /chains/main/blocks/head/ - const block = await client.getBlock(); + describe(`Test Taquito RPC: ${rpc}`, () => { + describe('Test getBlock', () => { + it('Verify that client.getBlock returns a block using default syntax', async (done) => { + // defaults to /chains/main/blocks/head/ + const block = await client.getBlock(); - expect(block.protocol).toBeTruthy(); - done(); - }) - it('Verify that client.getBlock({ block: \'head~2\' }) returns a block using head and tilde syntax', async (done) => { - const block = await client.getBlock({ block: 'head~2' }); - const blockHeader = await client.getBlockHeader({ block: block.hash }) + expect(block.protocol).toBeTruthy(); + done(); + }); + it('Verify that client.getBlock({ block: \'head~2\' }) returns a block using head and tilde syntax', async (done) => { + const block = await client.getBlock({ block: 'head~2' }); + const blockHeader = await client.getBlockHeader({ block: block.hash }); - expect(block.header.predecessor).toEqual(blockHeader.predecessor); - done(); - }) - it('Verify that client.getBlock({ block: `${block.hash}~1` }) returns a block using hash and tilde syntax', async (done) => { - const block = await client.getBlock(); - const predecessorBlock = await client.getBlock({ block: `${block.hash}~1` }) + expect(block.header.predecessor).toEqual(blockHeader.predecessor); + done(); + }); + it('Verify that client.getBlock({ block: `${block.hash}~1` }) returns a block using hash and tilde syntax', async (done) => { + const block = await client.getBlock(); + const predecessorBlock = await client.getBlock({ block: `${block.hash}~1` }); - expect(predecessorBlock.hash).toEqual(block.header.predecessor); - done(); - }) - it('Verify that unparse_mode has no error: Readable', async (done) => { - const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Readable'}) - expect(response.code).toBeDefined(); - done() - }) - it('Verify that unparse_mode has no error: Optimized', async (done) => { - const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Optimized'}) - expect(response.code).toBeDefined(); - done() - }) - it('Verify that unparse_mode has no error: Optimized_legacy', async (done) => { - const response = await client.getNormalizedScript(knownContract, {unparsing_mode: 'Optimized_legacy'}) - expect(response.code).toBeDefined(); - done() - }) - it('Should fail unparsing_mode not acceptable', async (done) => { - expect(() => client.getNormalizedScript(knownContract, {unparsing_mode: 'else' as any})).rejects.toThrowError(HttpResponseError) - done() - }) - it('Should fail unparsing_mode not acceptable', async (done) => { - expect(() => client.getNormalizedScript(knownContract, {} as any )).rejects.toThrowError(HttpResponseError) - done() - }) - }) - }) -}) + expect(predecessorBlock.hash).toEqual(block.header.predecessor); + done(); + }); + it('Verify that unparse_mode has no error: Readable', async (done) => { + const response = await client.getNormalizedScript(knownContract, { unparsing_mode: 'Readable' }); + expect(response.code).toBeDefined(); + done(); + }); + it('Verify that unparse_mode has no error: Optimized', async (done) => { + const response = await client.getNormalizedScript(knownContract, { unparsing_mode: 'Optimized' }); + expect(response.code).toBeDefined(); + done(); + }); + it('Verify that unparse_mode has no error: Optimized_legacy', async (done) => { + const response = await client.getNormalizedScript(knownContract, { unparsing_mode: 'Optimized_legacy' }); + expect(response.code).toBeDefined(); + done(); + }); + it('Should fail unparsing_mode not acceptable', async (done) => { + expect(() => client.getNormalizedScript(knownContract, { unparsing_mode: 'else' as any })).rejects.toThrowError(HttpResponseError); + done(); + }); + it('Should fail unparsing_mode not acceptable', async (done) => { + expect(() => client.getNormalizedScript(knownContract, {} as any)).rejects.toThrowError(HttpResponseError); + done(); + }); + }); + }); +});