-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix api * test api * cleanup * cleanup * cleanup
- Loading branch information
1 parent
005f007
commit bf91870
Showing
10 changed files
with
87 additions
and
36 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Api } from './api' | ||
import { WsProvider } from '@polkadot/api' | ||
import { expect, test } from 'vitest' | ||
|
||
test('handle invalid block hash', async () => { | ||
const api = new Api(new WsProvider('wss://acala-rpc-0.aca-api.network')) | ||
await api.isReady | ||
|
||
await expect(api.getHeader('0x')).rejects.toThrow('invalid length') | ||
expect(await api.getHeader('0xc87ae632b2cc4583a37659785f5098947acfdc6a36dbb07abcfa6ad694f97c5d')).toBeNull() | ||
expect(await api.getBlock('0xc87ae632b2cc4583a37659785f5098947acfdc6a36dbb07abcfa6ad694f97c5d')).toBeNull() | ||
expect(await api.getBlockHash(999999999)).toBeNull() | ||
expect(await api.getBlockHash()).toBeTruthy() | ||
expect(await api.getStorage('0x0001')).toBeNull() | ||
await expect( | ||
api.getKeysPaged('0x', 1, '0x', '0xc87ae632b2cc4583a37659785f5098947acfdc6a36dbb07abcfa6ad694f97c5d'), | ||
).rejects.toThrow('Header was not found') | ||
|
||
await api.disconnect() | ||
}) |
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect, test } from 'vitest' | ||
import { setup } from './setup' | ||
|
||
test('handle invalid block ', async () => { | ||
await expect(setup({ endpoint: 'wss://acala-rpc-0.aca-api.network', block: '0x' })).rejects.toThrow('invalid length') | ||
await expect(setup({ endpoint: 'wss://acala-rpc-0.aca-api.network', block: 999999999 })).rejects.toThrow( | ||
'Cannot find block hash for 999999999', | ||
) | ||
await expect( | ||
setup({ | ||
endpoint: 'wss://acala-rpc-0.aca-api.network', | ||
block: '0xc87ae632b2cc4583a37659785f5098947acfdc6a36dbb07abcfa6ad694f97c5d', | ||
}), | ||
).rejects.toThrow('Cannot find header for 0xc87ae632b2cc4583a37659785f5098947acfdc6a36dbb07abcfa6ad694f97c5d') | ||
}) |
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
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