subscribeNewHeads (#1338)
* subscribeNewHeads * Update CHANGELOG * Rebuild interfaces * Sort interfaces, really expose plural * Fix mocks
This commit is contained in:
@@ -24,8 +24,8 @@ describe('Cached Observables', (): void => {
|
||||
});
|
||||
|
||||
it('creates a single observable for subscriptions (multiple calls, no arguments)', (): void => {
|
||||
const observable1 = rpc.chain.subscribeNewHead();
|
||||
const observable2 = rpc.chain.subscribeNewHead();
|
||||
const observable1 = rpc.chain.subscribeNewHeads();
|
||||
const observable2 = rpc.chain.subscribeNewHeads();
|
||||
|
||||
expect(observable2).toBe(observable1);
|
||||
});
|
||||
@@ -45,8 +45,8 @@ describe('Cached Observables', (): void => {
|
||||
});
|
||||
|
||||
it('clears cache if there are no more subscribers', (): void => {
|
||||
const observable1 = rpc.chain.subscribeNewHead();
|
||||
const observable2 = rpc.chain.subscribeNewHead();
|
||||
const observable1 = rpc.chain.subscribeNewHeads();
|
||||
const observable2 = rpc.chain.subscribeNewHeads();
|
||||
|
||||
expect(observable1).toBe(observable2);
|
||||
|
||||
@@ -57,14 +57,14 @@ describe('Cached Observables', (): void => {
|
||||
sub2.unsubscribe();
|
||||
|
||||
// No more subscribers, now create a new observable
|
||||
const observable3 = rpc.chain.subscribeNewHead();
|
||||
const observable3 = rpc.chain.subscribeNewHeads();
|
||||
|
||||
expect(observable3).not.toBe(observable1);
|
||||
});
|
||||
|
||||
it('creates different observables for different methods but same arguments', (): void => {
|
||||
// @ts-ignore
|
||||
const observable1 = rpc.chain.subscribeNewHead([123]);
|
||||
const observable1 = rpc.chain.subscribeNewHeads([123]);
|
||||
const observable2 = rpc.state.subscribeStorage([123]);
|
||||
|
||||
expect(observable2).not.toBe(observable1);
|
||||
|
||||
@@ -11,11 +11,11 @@ import { Codec, IExtrinsic } from '@polkadot/types/types';
|
||||
export interface RpcInterface {
|
||||
author: {
|
||||
insertKey(keyType: Text | string, suri: Text | string, maybePublic?: Bytes | Uint8Array | string): Observable<Bytes>;
|
||||
pendingExtrinsics(): Observable<Vec<Extrinsic>>;
|
||||
removeExtrinsic(bytesOrHash: (ExtrinsicOrHash)[]): Observable<Vec<Hash>>;
|
||||
rotateKeys(): Observable<Bytes>;
|
||||
pendingExtrinsics(): Observable<Vec<Extrinsic>>;
|
||||
submitExtrinsic(extrinsic: IExtrinsic): Observable<Hash>;
|
||||
submitAndWatchExtrinsic(extrinsic: IExtrinsic): Observable<ExtrinsicStatus>;
|
||||
submitExtrinsic(extrinsic: IExtrinsic): Observable<Hash>;
|
||||
};
|
||||
chain: {
|
||||
getBlock(hash?: Hash | Uint8Array | string): Observable<SignedBlock>;
|
||||
@@ -24,8 +24,8 @@ export interface RpcInterface {
|
||||
getHeader(hash?: Hash | Uint8Array | string): Observable<Header>;
|
||||
getRuntimeVersion(hash?: Hash | Uint8Array | string): Observable<RuntimeVersion>;
|
||||
subscribeFinalizedHeads(): Observable<Header>;
|
||||
subscribeNewHeads(): Observable<Header>;
|
||||
subscribeRuntimeVersion(): Observable<RuntimeVersion>;
|
||||
subscribeNewHead(): Observable<Header>;
|
||||
};
|
||||
state: {
|
||||
call(method: Text | string, data: Bytes | Uint8Array | string, block?: Hash | Uint8Array | string): Observable<Bytes>;
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('replay', (): void => {
|
||||
it('unsubscribes as required', (done): void => {
|
||||
rpc.provider.unsubscribe = jest.fn();
|
||||
|
||||
const subscription = rpc.chain.subscribeNewHead().subscribe((): void => {
|
||||
const subscription = rpc.chain.subscribeNewHeads().subscribe((): void => {
|
||||
subscription.unsubscribe();
|
||||
|
||||
// There's a promise inside .unsubscribe(), wait a bit
|
||||
|
||||
Reference in New Issue
Block a user