Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Incede committed Mar 23, 2021
1 parent 53e9848 commit eaac12c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions framework/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ export class Application {
getNodeInfo: {
handler: () => this._node.actions.getNodeInfo(),
},
getRegisteredActions: {
handler: () => this._controller.bus.getActions(),
},
getRegisteredEvents: {
handler: () => this._controller.bus.getEvents(),
},
},
{ skipInternalEvents: true },
);
Expand Down
15 changes: 15 additions & 0 deletions framework/test/functional/rpc-api/ipc/ipc_client_in_memory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ describe('api client ipc mode', () => {
client.invoke('app:getAccount', { address: 'randomString*&&^%^' }),
).rejects.toThrow('Specified key accounts:address: does not exist');
});

it('should return a list of registered actions', async () => {
const actions = await await client.invoke('app:getRegisteredActions');
expect(actions).toBeArray();
expect(actions).toContain('app:getConnectedPeers');
expect(actions).toContain('dpos:getAllDelegates');
expect(actions).toContain('hello:callGreet');
});
});

describe('application events', () => {
Expand All @@ -115,6 +123,13 @@ describe('api client ipc mode', () => {
expect(newBlockEvent.length).toBeGreaterThan(0);
expect(newBlockEvent[0]).toHaveProperty('block');
});
it('should return a list of registered events', async () => {
const events = await await client.invoke('app:getRegisteredEvents');
expect(events).toBeArray();
expect(events).toContain('app:ready');
expect(events).toContain('token:registeredToBus');
expect(events).toContain('hello:greet');
});
});

describe('module actions', () => {
Expand Down

0 comments on commit eaac12c

Please sign in to comment.