diff --git a/src/lib/nodes/channels/Channel.spec.ts b/src/lib/nodes/channels/Channel.spec.ts index e6ac045ce..866d9e0b0 100644 --- a/src/lib/nodes/channels/Channel.spec.ts +++ b/src/lib/nodes/channels/Channel.spec.ts @@ -165,7 +165,7 @@ describe('wrapMessagePayload', () => { }); class StubChannel extends Channel { - getOutboundRAMFAddress(): string { + async getOutboundRAMFAddress(): Promise { throw new Error('not implemented'); } } diff --git a/src/lib/nodes/channels/Channel.ts b/src/lib/nodes/channels/Channel.ts index f08314ff9..87347282f 100644 --- a/src/lib/nodes/channels/Channel.ts +++ b/src/lib/nodes/channels/Channel.ts @@ -45,7 +45,7 @@ export abstract class Channel { return envelopedData.serialize(); } - public abstract getOutboundRAMFAddress(): string; + public abstract getOutboundRAMFAddress(): Promise; protected async getNodePrivateAddress(): Promise { return getPrivateAddressFromIdentityKey(this.nodePrivateKey); diff --git a/src/lib/nodes/channels/GatewayChannel.spec.ts b/src/lib/nodes/channels/GatewayChannel.spec.ts index 2da85edee..529055ed7 100644 --- a/src/lib/nodes/channels/GatewayChannel.spec.ts +++ b/src/lib/nodes/channels/GatewayChannel.spec.ts @@ -338,7 +338,7 @@ class StubGatewayChannel extends GatewayChannel { ); } - public getOutboundRAMFAddress(): string { + async getOutboundRAMFAddress(): Promise { return StubGatewayChannel.OUTBOUND_RAMF_ADDRESS; } } diff --git a/src/lib/nodes/channels/GatewayChannel.ts b/src/lib/nodes/channels/GatewayChannel.ts index a8b2680b7..54d175d7c 100644 --- a/src/lib/nodes/channels/GatewayChannel.ts +++ b/src/lib/nodes/channels/GatewayChannel.ts @@ -14,7 +14,7 @@ export abstract class GatewayChannel extends Channel { public async *generateCargoes(messages: CargoMessageStream): AsyncIterable { const messagesAsArrayBuffers = convertBufferMessagesToArrayBuffer(messages); const cargoMessageSets = CargoMessageSet.batchMessagesSerialized(messagesAsArrayBuffers); - const recipientAddress = this.getOutboundRAMFAddress(); + const recipientAddress = await this.getOutboundRAMFAddress(); for await (const { messageSerialized, expiryDate } of cargoMessageSets) { const creationDate = getCargoCreationTime(); const ttl = getSecondsBetweenDates(creationDate, expiryDate); diff --git a/src/lib/nodes/channels/PrivateGatewayChannel.spec.ts b/src/lib/nodes/channels/PrivateGatewayChannel.spec.ts index 60f8d609a..79c7503d0 100644 --- a/src/lib/nodes/channels/PrivateGatewayChannel.spec.ts +++ b/src/lib/nodes/channels/PrivateGatewayChannel.spec.ts @@ -201,7 +201,7 @@ class StubPrivateGatewayChannel extends PrivateGatewayChannel { ); } - public getOutboundRAMFAddress(): string { + async getOutboundRAMFAddress(): Promise { throw new Error('not implemented'); } } diff --git a/src/lib/nodes/channels/PrivatePublicGatewayChannel.spec.ts b/src/lib/nodes/channels/PrivatePublicGatewayChannel.spec.ts index 1a1c0ff8e..6bacdf49e 100644 --- a/src/lib/nodes/channels/PrivatePublicGatewayChannel.spec.ts +++ b/src/lib/nodes/channels/PrivatePublicGatewayChannel.spec.ts @@ -84,8 +84,10 @@ beforeEach(() => { ); }); -test('getOutboundRAMFAddress should return public address of public gateway', () => { - expect(channel.getOutboundRAMFAddress()).toEqual(`https://${PUBLIC_GATEWAY_PUBLIC_ADDRESS}`); +test('getOutboundRAMFAddress should return public address of public gateway', async () => { + await expect(channel.getOutboundRAMFAddress()).resolves.toEqual( + `https://${PUBLIC_GATEWAY_PUBLIC_ADDRESS}`, + ); }); describe('Endpoint registration', () => { diff --git a/src/lib/nodes/channels/PrivatePublicGatewayChannel.ts b/src/lib/nodes/channels/PrivatePublicGatewayChannel.ts index 172c9bc66..2c7341411 100644 --- a/src/lib/nodes/channels/PrivatePublicGatewayChannel.ts +++ b/src/lib/nodes/channels/PrivatePublicGatewayChannel.ts @@ -40,7 +40,7 @@ export class PrivatePublicGatewayChannel extends PrivateGatewayChannel { ); } - getOutboundRAMFAddress(): string { + async getOutboundRAMFAddress(): Promise { return `https://${this.publicGatewayPublicAddress}`; } @@ -111,7 +111,7 @@ export class PrivatePublicGatewayChannel extends PrivateGatewayChannel { const ccr = new CargoCollectionRequest(cargoDeliveryAuthorization); const ccaPayload = await this.wrapMessagePayload(ccr); const cca = new CargoCollectionAuthorization( - this.getOutboundRAMFAddress(), + await this.getOutboundRAMFAddress(), this.nodeDeliveryAuth, Buffer.from(ccaPayload), { creationDate: startDate, ttl: differenceInSeconds(endDate, startDate) },