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) + }) +})