Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for parsing mode for all testnets, and fail case #2184

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});
});