Skip to content

Commit

Permalink
fix: Agent isInitialized on shutdown
Browse files Browse the repository at this point in the history
Fixes problem where agent cannot be initialized (again) after shutdown

Signed-off-by: Niall Shaw <niall.shaw@absa.africa>
  • Loading branch information
niall-shaw committed Mar 10, 2022
1 parent 5cc2eea commit f4542cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class Agent {
if (this.wallet.isInitialized) {
await this.wallet.close()
}
this._isInitialized = false
}

public get publicDid() {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/tests/agents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ describe('agents', () => {

expect(basicMessage.content).toBe(message)
})

test('can shutdown and re-initialize the same agent', async () => {
expect(aliceAgent.isInitialized).toBe(true)
await aliceAgent.shutdown()
expect(aliceAgent.isInitialized).toBe(false)
await aliceAgent.initialize()
expect(aliceAgent.isInitialized).toBe(true)
})
})

0 comments on commit f4542cc

Please sign in to comment.