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 {
32
32
protected messageReceiver : MessageReceiver
33
33
protected messageSender : MessageSender
34
34
public inboundTransporter ?: InboundTransporter
35
+ private _isInitialized = false
35
36
36
37
public readonly connections ! : ConnectionsModule
37
38
public readonly proofs ! : ProofsModule
@@ -114,6 +115,10 @@ export class Agent {
114
115
return this . eventEmitter
115
116
}
116
117
118
+ public get isInitialized ( ) {
119
+ return this . _isInitialized
120
+ }
121
+
117
122
public async init ( ) {
118
123
await this . wallet . init ( )
119
124
@@ -126,6 +131,8 @@ export class Agent {
126
131
if ( this . inboundTransporter ) {
127
132
await this . inboundTransporter . start ( this )
128
133
}
134
+
135
+ this . _isInitialized = true
129
136
}
130
137
131
138
public get publicDid ( ) {
Original file line number Diff line number Diff line change @@ -26,9 +26,21 @@ import { Dispatcher } from '../Dispatcher'
26
26
import { EnvelopeService } from '../EnvelopeService'
27
27
import { getBaseConfig } from '../../__tests__/helpers'
28
28
29
- const config = getBaseConfig ( 'DI Test' )
29
+ const config = getBaseConfig ( 'Agent Class Test' )
30
30
31
31
describe ( '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
+
32
44
describe ( 'Dependency Injection' , ( ) => {
33
45
it ( 'should be able to resolve registered instances' , ( ) => {
34
46
const agent = new Agent ( config )
You can’t perform that action at this time.
0 commit comments