forked from openwallet-foundation/credo-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge branch 'main' into 0.3.0-pre (openwallet-foundation#1030)
* feat: OOB public did (openwallet-foundation#930) Signed-off-by: Pavel Zarecky <[email protected]> * feat(routing): manual mediator pickup lifecycle management (openwallet-foundation#989) Signed-off-by: Ariel Gentile <[email protected]> * docs(demo): faber creates invitation (openwallet-foundation#995) Signed-off-by: conanoc <[email protected]> * chore(release): v0.2.3 (openwallet-foundation#999) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(question-answer): question answer protocol state/role check (openwallet-foundation#1001) Signed-off-by: Ariel Gentile <[email protected]> * feat: Action Menu protocol (Aries RFC 0509) implementation (openwallet-foundation#974) Signed-off-by: Ariel Gentile <[email protected]> * fix(ledger): remove poolConnected on pool close (openwallet-foundation#1011) Signed-off-by: Niall Shaw <[email protected]> * fix(ledger): check taa version instad of aml version (openwallet-foundation#1013) Signed-off-by: Jakub Koci <[email protected]> * chore: add @janrtvld to maintainers (openwallet-foundation#1016) Signed-off-by: Timo Glastra <[email protected]> * feat(routing): add settings to control back off strategy on mediator reconnection (openwallet-foundation#1017) Signed-off-by: Sergi Garreta <[email protected]> * fix: avoid crash when an unexpected message arrives (openwallet-foundation#1019) Signed-off-by: Pavel Zarecky <[email protected]> * chore(release): v0.2.4 (openwallet-foundation#1024) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * style: fix some lint errors Signed-off-by: Ariel Gentile <[email protected]> * feat: use did:key flag (openwallet-foundation#1029) Signed-off-by: Ariel Gentile <[email protected]> * ci: set default rust version (openwallet-foundation#1036) Signed-off-by: Sai Ranjit Tummalapalli <[email protected]> * fix(oob): allow encoding in content type header (openwallet-foundation#1037) Signed-off-by: Timo Glastra <[email protected]> * feat: connection type (openwallet-foundation#994) Signed-off-by: KolbyRKunz <[email protected]> * chore(module-tenants): match package versions Signed-off-by: Ariel Gentile <[email protected]> * feat: improve sending error handling (openwallet-foundation#1045) Signed-off-by: Ariel Gentile <[email protected]> * feat: expose findAllByQuery method in modules and services (openwallet-foundation#1044) Signed-off-by: Jim Ezesinachi <[email protected]> * feat: possibility to set masterSecretId inside of WalletConfig (openwallet-foundation#1043) Signed-off-by: Andrii Uhryn <[email protected]> * fix(oob): set connection alias when creating invitation (openwallet-foundation#1047) Signed-off-by: Jakub Koci <[email protected]> * build: fix missing parameter Signed-off-by: Ariel Gentile <[email protected]> Signed-off-by: Pavel Zarecky <[email protected]> Signed-off-by: Ariel Gentile <[email protected]> Signed-off-by: conanoc <[email protected]> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Niall Shaw <[email protected]> Signed-off-by: Jakub Koci <[email protected]> Signed-off-by: Timo Glastra <[email protected]> Signed-off-by: Sergi Garreta <[email protected]> Signed-off-by: Sai Ranjit Tummalapalli <[email protected]> Signed-off-by: KolbyRKunz <[email protected]> Signed-off-by: Jim Ezesinachi <[email protected]> Signed-off-by: Andrii Uhryn <[email protected]> Co-authored-by: Iskander508 <[email protected]> Co-authored-by: conanoc <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Niall Shaw <[email protected]> Co-authored-by: jakubkoci <[email protected]> Co-authored-by: Timo Glastra <[email protected]> Co-authored-by: Sergi Garreta Serra <[email protected]> Co-authored-by: Sai Ranjit Tummalapalli <[email protected]> Co-authored-by: KolbyRKunz <[email protected]> Co-authored-by: Jim Ezesinachi <[email protected]> Co-authored-by: an-uhryn <[email protected]>
- Loading branch information
1 parent
9ca4221
commit edd81bc
Showing
56 changed files
with
925 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { OutboundMessage } from '../types' | ||
|
||
import { AriesFrameworkError } from './AriesFrameworkError' | ||
|
||
export class MessageSendingError extends AriesFrameworkError { | ||
public outboundMessage: OutboundMessage | ||
public constructor(message: string, { outboundMessage, cause }: { outboundMessage: OutboundMessage; cause?: Error }) { | ||
super(message, { cause }) | ||
this.outboundMessage = outboundMessage | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
packages/core/src/modules/basic-messages/__tests__/basic-messages.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import type { SubjectMessage } from '../../../../../../tests/transport/SubjectInboundTransport' | ||
import type { ConnectionRecord } from '../../../modules/connections' | ||
|
||
import { Subject } from 'rxjs' | ||
|
||
import { SubjectInboundTransport } from '../../../../../../tests/transport/SubjectInboundTransport' | ||
import { SubjectOutboundTransport } from '../../../../../../tests/transport/SubjectOutboundTransport' | ||
import { getAgentOptions, makeConnection, waitForBasicMessage } from '../../../../tests/helpers' | ||
import testLogger from '../../../../tests/logger' | ||
import { Agent } from '../../../agent/Agent' | ||
import { MessageSendingError, RecordNotFoundError } from '../../../error' | ||
import { BasicMessage } from '../messages' | ||
import { BasicMessageRecord } from '../repository' | ||
|
||
const faberConfig = getAgentOptions('Faber Basic Messages', { | ||
endpoints: ['rxjs:faber'], | ||
}) | ||
|
||
const aliceConfig = getAgentOptions('Alice Basic Messages', { | ||
endpoints: ['rxjs:alice'], | ||
}) | ||
|
||
describe('Basic Messages E2E', () => { | ||
let faberAgent: Agent | ||
let aliceAgent: Agent | ||
let faberConnection: ConnectionRecord | ||
let aliceConnection: ConnectionRecord | ||
|
||
beforeEach(async () => { | ||
const faberMessages = new Subject<SubjectMessage>() | ||
const aliceMessages = new Subject<SubjectMessage>() | ||
const subjectMap = { | ||
'rxjs:faber': faberMessages, | ||
'rxjs:alice': aliceMessages, | ||
} | ||
|
||
faberAgent = new Agent(faberConfig) | ||
faberAgent.registerInboundTransport(new SubjectInboundTransport(faberMessages)) | ||
faberAgent.registerOutboundTransport(new SubjectOutboundTransport(subjectMap)) | ||
await faberAgent.initialize() | ||
|
||
aliceAgent = new Agent(aliceConfig) | ||
aliceAgent.registerInboundTransport(new SubjectInboundTransport(aliceMessages)) | ||
aliceAgent.registerOutboundTransport(new SubjectOutboundTransport(subjectMap)) | ||
await aliceAgent.initialize() | ||
;[aliceConnection, faberConnection] = await makeConnection(aliceAgent, faberAgent) | ||
}) | ||
|
||
afterEach(async () => { | ||
await faberAgent.shutdown() | ||
await faberAgent.wallet.delete() | ||
await aliceAgent.shutdown() | ||
await aliceAgent.wallet.delete() | ||
}) | ||
|
||
test('Alice and Faber exchange messages', async () => { | ||
testLogger.test('Alice sends message to Faber') | ||
const helloRecord = await aliceAgent.basicMessages.sendMessage(aliceConnection.id, 'Hello') | ||
|
||
expect(helloRecord.content).toBe('Hello') | ||
|
||
testLogger.test('Faber waits for message from Alice') | ||
await waitForBasicMessage(faberAgent, { | ||
content: 'Hello', | ||
}) | ||
|
||
testLogger.test('Faber sends message to Alice') | ||
const replyRecord = await faberAgent.basicMessages.sendMessage(faberConnection.id, 'How are you?') | ||
expect(replyRecord.content).toBe('How are you?') | ||
|
||
testLogger.test('Alice waits until she receives message from faber') | ||
await waitForBasicMessage(aliceAgent, { | ||
content: 'How are you?', | ||
}) | ||
}) | ||
|
||
test('Alice is unable to send a message', async () => { | ||
testLogger.test('Alice sends message to Faber that is undeliverable') | ||
|
||
const spy = jest.spyOn(aliceAgent.outboundTransports[0], 'sendMessage').mockRejectedValue(new Error('any error')) | ||
|
||
await expect(aliceAgent.basicMessages.sendMessage(aliceConnection.id, 'Hello')).rejects.toThrowError( | ||
MessageSendingError | ||
) | ||
try { | ||
await aliceAgent.basicMessages.sendMessage(aliceConnection.id, 'Hello undeliverable') | ||
} catch (error) { | ||
const thrownError = error as MessageSendingError | ||
expect(thrownError.message).toEqual( | ||
`Message is undeliverable to connection ${aliceConnection.id} (${aliceConnection.theirLabel})` | ||
) | ||
testLogger.test('Error thrown includes the outbound message and recently created record id') | ||
expect(thrownError.outboundMessage.associatedRecord).toBeInstanceOf(BasicMessageRecord) | ||
expect(thrownError.outboundMessage.payload).toBeInstanceOf(BasicMessage) | ||
expect((thrownError.outboundMessage.payload as BasicMessage).content).toBe('Hello undeliverable') | ||
|
||
testLogger.test('Created record can be found and deleted by id') | ||
const storedRecord = await aliceAgent.basicMessages.getById(thrownError.outboundMessage.associatedRecord!.id) | ||
expect(storedRecord).toBeInstanceOf(BasicMessageRecord) | ||
expect(storedRecord.content).toBe('Hello undeliverable') | ||
|
||
await aliceAgent.basicMessages.deleteById(storedRecord.id) | ||
await expect( | ||
aliceAgent.basicMessages.getById(thrownError.outboundMessage.associatedRecord!.id) | ||
).rejects.toThrowError(RecordNotFoundError) | ||
} | ||
spy.mockClear() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.