-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for parsing mode for all testnets, and fail case (#2184)
* 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
Showing
1 changed file
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); | ||
}); |