Skip to content

Commit

Permalink
Merge pull request #93 from ssbc/tape-5
Browse files Browse the repository at this point in the history
Update tape to v5
  • Loading branch information
Powersource authored Sep 28, 2023
2 parents 8d4cd06 + 8f0e7fe commit b218e92
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 154 deletions.
203 changes: 159 additions & 44 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"ssb-replicate": "^1.3.3",
"standard": "^17.1.0",
"tap-arc": "^0.4.0",
"tape": "^4.16.2"
"tape": "^5.7.0"
},
"keywords": [
"scuttlebutt",
Expand Down
27 changes: 12 additions & 15 deletions test/api/add-new-author-listener.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const test = require('tape')
const { promisify: p } = require('util')
const { Server, replicate } = require('../helpers')

test('addNewAuthorListener', async t => {
test('addNewAuthorListener', t => {
t.plan(6)

const admin = Server({ name: 'admin', debug: false }) // me
Expand Down Expand Up @@ -40,27 +40,24 @@ test('addNewAuthorListener', async t => {
setTimeout(() => {
admin.close()
newPerson.close()
t.end()
}, 1000)
})

try {
const groupData = await p(admin.tribes.create)({}).catch(t.fail)
// this makes a group, but also in the background, alerts the newAuthorListeners
// so the above listener can get called *before* we have access to the groupId
// this makes a group, but also in the background, alerts the newAuthorListeners
// so the above listener can get called *before* we have access to the groupId
p(admin.tribes.create)({}).then((groupData) => {
groupId = groupData.groupId
await p(admin.tribes.invite)(groupId, [newPerson.id], { text: 'ahoy' }).catch(err => {
console.error('invite failed:', err)
t.fail(err)
})

await p(admin.tribes.invite)(groupId, [newPerson.id], { text: 'ahoy again' }).catch(t.fail)
return p(admin.tribes.invite)(groupId, [newPerson.id], { text: 'ahoy' })
}).then(() => {
return p(admin.tribes.invite)(groupId, [newPerson.id], { text: 'ahoy again' })
}).then(() => {
// we want to test that duplicate adds dont fire the addNewAuthorListener multiple times,
// unfortunately there are race conditions around calculating the new authors, so
// we have added a small delay here
// later note: no we haven't?

p(replicate)({ from: admin, to: newPerson, name })
} catch (err) {
return p(replicate)({ from: admin, to: newPerson, name })
}).catch((err) => {
t.fail(err)
}
})
})
5 changes: 4 additions & 1 deletion test/lib/group-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ test('groupId', t => {
t.equal(groupId({ groupInitMsg, groupKey }), data.groupId, 'can calculate groupId with groupKey')

server.close()
t.end()
})
})

// -----------------------------------------------------------
// -----------------------------------------------------------

test('groupId vectors', t => {
/* testing against shared test-vectors */
vectors.forEach(vector => {
decodeLeaves(vector)
Expand Down
Loading

0 comments on commit b218e92

Please sign in to comment.