Skip to content

Commit

Permalink
add tests for parsing mode for all testnets, and fail case (#2184)
Browse files Browse the repository at this point in the history
* add tests for parsing mode for all testnets, and fail case

* one more test fail

* format

Co-authored-by: Zainen Suzuki <[email protected]>
  • Loading branch information
zainen and Zainen Suzuki authored Dec 2, 2022
1 parent 5d53dc9 commit c898804
Showing 1 changed file with 49 additions and 25 deletions.
74 changes: 49 additions & 25 deletions integration-tests/rpc-taquito.spec.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
import { CONFIGS } from "./config";
import { RpcClient } from '@taquito/rpc';
import { HttpResponseError } from "@taquito/http-utils";


CONFIGS().forEach(({ rpc }) => {
const client = new RpcClient(rpc);
CONFIGS().forEach(({ rpc, knownContract }) => {
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();
})
})
})
})
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();
});
});
});
});

0 comments on commit c898804

Please sign in to comment.