From 5643b1d31a821a31d61f5a37256465895260f117 Mon Sep 17 00:00:00 2001 From: Daniel Norman <1992255+2color@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:43:27 +0200 Subject: [PATCH] fix: respect trustless gateway options for sessions (#566) pass down trustless gateway options to session subclass --------- Co-authored-by: Daniel N <2color@users.noreply.github.com> Co-authored-by: Alex Potsides --- .../src/trustless-gateway/broker.ts | 6 +++- .../test/trustless-gateway-utils.spec.ts | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 packages/block-brokers/test/trustless-gateway-utils.spec.ts diff --git a/packages/block-brokers/src/trustless-gateway/broker.ts b/packages/block-brokers/src/trustless-gateway/broker.ts index ec566a90f..310adbf5c 100644 --- a/packages/block-brokers/src/trustless-gateway/broker.ts +++ b/packages/block-brokers/src/trustless-gateway/broker.ts @@ -90,6 +90,10 @@ export class TrustlessGatewayBlockBroker implements BlockBroker { + it('filterNonHTTPMultiaddrs respects allowInsecure multiaddrs correctly', async function () { + const nonSecureMaddr = uriToMultiaddr('http://mygw.com') + const secureMaddr = uriToMultiaddr('https://mygw.com') + + const filtered = filterNonHTTPMultiaddrs([nonSecureMaddr, secureMaddr], true, true) + + expect(filtered.length).to.deep.equal(2) + }) + + it('filterNonHTTPMultiaddrs filters local multiaddrs correctly', async function () { + const localMaddr = uriToMultiaddr('http://localhost') + + const filtered = filterNonHTTPMultiaddrs([localMaddr], true, true) + + expect(filtered.length).to.deep.equal(1) + }) + + it('filterNonHTTPMultiaddrs filters multiaddrs correctly', async function () { + const localMaddr = uriToMultiaddr('http://localhost') + + const filtered = filterNonHTTPMultiaddrs([localMaddr], false, false) + + expect(filtered.length).to.deep.equal(0) + }) +})