Skip to content

Commit

Permalink
Adjust code to multiple addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Aug 10, 2023
1 parent 2e69186 commit 7510cab
Show file tree
Hide file tree
Showing 13 changed files with 429 additions and 81 deletions.
298 changes: 297 additions & 1 deletion packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"@quiet/types": "^1.6.0",
"multiaddr": "^10.0.1",
"cross-env": "^5.2.0",
"debug": "^4.3.1"
},
Expand Down
28 changes: 24 additions & 4 deletions packages/common/src/invitationCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,42 @@ import { Site } from './static'

describe('Invitation code helper', () => {
it('retrieves invitation code from argv', () => {
const expectedCodes = [
{ peerId: 'peerID1', address: 'address1' },
{ peerId: 'peerID2', address: 'address2' },
]
const result = argvInvitationCode([
'something',
'quiet:/invalid',
'zbay://invalid',
'quiet://invalid',
'quiet://?param=invalid',
invitationDeepUrl('validCode'),
invitationDeepUrl(expectedCodes),
])
expect(result).toBe('validCode')
expect(result).toBe(expectedCodes)
})

it('builds proper invitation deep url', () => {
expect(invitationDeepUrl('validCode')).toEqual('quiet://?code=validCode')
expect(
invitationDeepUrl([
{ peerId: 'peerID1', address: 'address1' },
{ peerId: 'peerID2', address: 'address2' },
])
).toEqual('quiet://?peerID1=address1&peerID2=address2')
})

// it('builds proper invitation share url', () => {
// expect(invitationShareUrl('validCode')).toEqual(`https://${Site.DOMAIN}/${Site.JOIN_PAGE}#validCode`)
// })

it('builds proper invitation share url', () => {
expect(invitationShareUrl('validCode')).toEqual(`https://${Site.DOMAIN}/${Site.JOIN_PAGE}#validCode`)
const peerList = [
'/dns4/gloao6h5plwjy4tdlze24zzgcxll6upq2ex2fmu2ohhyu4gtys4nrjad.onion/tcp/443/wss/p2p/QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE',
'invalidAddress',
'/dns4/somethingElse.onion/tcp/443/wss/p2p/QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSA',
]
expect(invitationShareUrl(peerList)).toEqual(
`https://${Site.DOMAIN}/${Site.JOIN_PAGE}#QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE=gloao6h5plwjy4tdlze24zzgcxll6upq2ex2fmu2ohhyu4gtys4nrjad&QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSA=somethingElse`
)
})
})
Loading

0 comments on commit 7510cab

Please sign in to comment.