File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export class Agent {
3232 protected messageReceiver : MessageReceiver
3333 protected messageSender : MessageSender
3434 public inboundTransporter ?: InboundTransporter
35+ private _isInitialized = false
3536
3637 public readonly connections ! : ConnectionsModule
3738 public readonly proofs ! : ProofsModule
@@ -114,6 +115,10 @@ export class Agent {
114115 return this . eventEmitter
115116 }
116117
118+ public get isInitialized ( ) {
119+ return this . _isInitialized
120+ }
121+
117122 public async init ( ) {
118123 await this . wallet . init ( )
119124
@@ -126,6 +131,8 @@ export class Agent {
126131 if ( this . inboundTransporter ) {
127132 await this . inboundTransporter . start ( this )
128133 }
134+
135+ this . _isInitialized = true
129136 }
130137
131138 public get publicDid ( ) {
Original file line number Diff line number Diff line change @@ -26,9 +26,21 @@ import { Dispatcher } from '../Dispatcher'
2626import { EnvelopeService } from '../EnvelopeService'
2727import { getBaseConfig } from '../../__tests__/helpers'
2828
29- const config = getBaseConfig ( 'DI Test' )
29+ const config = getBaseConfig ( 'Agent Class Test' )
3030
3131describe ( 'Agent' , ( ) => {
32+ describe ( 'Initialization' , ( ) => {
33+ it ( 'isInitialized should only return true after initialization' , async ( ) => {
34+ expect . assertions ( 2 )
35+
36+ const agent = new Agent ( config )
37+
38+ expect ( agent . isInitialized ) . toBe ( false )
39+ await agent . init ( )
40+ expect ( agent . isInitialized ) . toBe ( true )
41+ } )
42+ } )
43+
3244 describe ( 'Dependency Injection' , ( ) => {
3345 it ( 'should be able to resolve registered instances' , ( ) => {
3446 const agent = new Agent ( config )
You can’t perform that action at this time.
0 commit comments