mirror of https://codeberg.org/pzp/pzp-sync.git
update secret-stack to 8.0
This commit is contained in:
parent
d7a5c2694f
commit
0cd2a56fc8
|
@ -46,8 +46,8 @@
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"pretty-quick": "^3.1.3",
|
"pretty-quick": "^3.1.3",
|
||||||
"rimraf": "^4.4.0",
|
"rimraf": "^4.4.0",
|
||||||
"secret-stack": "~7.1.1",
|
"secret-stack": "~8.0.0",
|
||||||
"secret-handshake-ext": "0.0.9",
|
"secret-handshake-ext": "0.0.11",
|
||||||
"ssb-box": "^1.0.1",
|
"ssb-box": "^1.0.1",
|
||||||
"typescript": "^5.1.3"
|
"typescript": "^5.1.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,8 +14,8 @@ function getAccount(iter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('sync an account tangle', async (t) => {
|
test('sync an account tangle', async (t) => {
|
||||||
const alice = createPeer({ name: 'alice', keypair: aliceKeypair })
|
const alice = createPeer({ name: 'alice', global: { keypair: aliceKeypair } })
|
||||||
const bob = createPeer({ name: 'bob', keypair: bobKeys })
|
const bob = createPeer({ name: 'bob', global: { keypair: bobKeys } })
|
||||||
|
|
||||||
await alice.db.loaded()
|
await alice.db.loaded()
|
||||||
await bob.db.loaded()
|
await bob.db.loaded()
|
||||||
|
@ -51,7 +51,6 @@ test('sync an account tangle', async (t) => {
|
||||||
"bob doesn't have alice's account tangle"
|
"bob doesn't have alice's account tangle"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// start() on purpose before connect, to test whether this also works
|
// start() on purpose before connect, to test whether this also works
|
||||||
bob.sync.start()
|
bob.sync.start()
|
||||||
const remoteAlice = await p(bob.connect)(alice.getAddress())
|
const remoteAlice = await p(bob.connect)(alice.getAddress())
|
||||||
|
|
|
@ -17,7 +17,9 @@ test('sync goal=dict with ghostSpan=2', async (t) => {
|
||||||
const SPAN = 5
|
const SPAN = 5
|
||||||
const alice = createPeer({
|
const alice = createPeer({
|
||||||
name: 'alice',
|
name: 'alice',
|
||||||
|
global: {
|
||||||
keypair: aliceKeypair,
|
keypair: aliceKeypair,
|
||||||
|
},
|
||||||
dict: { ghostSpan: SPAN },
|
dict: { ghostSpan: SPAN },
|
||||||
})
|
})
|
||||||
const bob = createPeer({ name: 'bob' })
|
const bob = createPeer({ name: 'bob' })
|
||||||
|
@ -132,11 +134,7 @@ test('sync goal=dict with ghostSpan=2', async (t) => {
|
||||||
.map((msg) => msg.data?.update)
|
.map((msg) => msg.data?.update)
|
||||||
.filter((x) => !!x)
|
.filter((x) => !!x)
|
||||||
.map((x) => x.age ?? x.name ?? x.gender)
|
.map((x) => x.age ?? x.name ?? x.gender)
|
||||||
assert.deepEqual(
|
assert.deepEqual(arr, [25, 'ALICE', 'w'], 'alice has age+name+gender dict')
|
||||||
arr,
|
|
||||||
[25, 'ALICE', 'w'],
|
|
||||||
'alice has age+name+gender dict'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
assert.deepEqual(alice.db.ghosts.get(moot.id), [rec2.id])
|
assert.deepEqual(alice.db.ghosts.get(moot.id), [rec2.id])
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,9 @@ test('sync goal=set with ghostSpan=2', async (t) => {
|
||||||
const SPAN = 5
|
const SPAN = 5
|
||||||
const alice = createPeer({
|
const alice = createPeer({
|
||||||
name: 'alice',
|
name: 'alice',
|
||||||
|
global: {
|
||||||
keypair: aliceKeypair,
|
keypair: aliceKeypair,
|
||||||
|
},
|
||||||
set: { ghostSpan: SPAN },
|
set: { ghostSpan: SPAN },
|
||||||
})
|
})
|
||||||
const bob = createPeer({ name: 'bob' })
|
const bob = createPeer({ name: 'bob' })
|
||||||
|
|
38
test/util.js
38
test/util.js
|
@ -1,20 +1,29 @@
|
||||||
const os = require('node:os')
|
const OS = require('node:os')
|
||||||
const path = require('node:path')
|
const Path = require('node:path')
|
||||||
const rimraf = require('rimraf')
|
const rimraf = require('rimraf')
|
||||||
const caps = require('ppppp-caps')
|
const caps = require('ppppp-caps')
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
|
|
||||||
function createPeer(opts) {
|
function createPeer(config) {
|
||||||
if (opts.name) {
|
if (config.name) {
|
||||||
const tmp = os.tmpdir()
|
const name = config.name
|
||||||
opts.db ??= {path: path.join(tmp, `ppppp-sync-${opts.name}-${Date.now()}`)}
|
const tmp = OS.tmpdir()
|
||||||
opts.keypair ??= Keypair.generate('ed25519', opts.name)
|
config.global ??= {}
|
||||||
opts.name = undefined
|
config.global.path ??= Path.join(tmp, `ppppp-sync-${name}-${Date.now()}`)
|
||||||
|
config.global.keypair ??= Keypair.generate('ed25519', name)
|
||||||
|
delete config.name
|
||||||
|
}
|
||||||
|
if (!config.global) {
|
||||||
|
throw new Error('need config.global in createPeer()')
|
||||||
|
}
|
||||||
|
if (!config.global.path) {
|
||||||
|
throw new Error('need config.global.path in createPeer()')
|
||||||
|
}
|
||||||
|
if (!config.global.keypair) {
|
||||||
|
throw new Error('need config.global.keypair in createPeer()')
|
||||||
}
|
}
|
||||||
if (!opts.db.path) throw new Error('need opts.db.path in createPeer()')
|
|
||||||
if (!opts.keypair) throw new Error('need opts.keypair in createPeer()')
|
|
||||||
|
|
||||||
rimraf.sync(opts.db.path)
|
rimraf.sync(config.global.path)
|
||||||
return require('secret-stack/bare')()
|
return require('secret-stack/bare')()
|
||||||
.use(require('secret-stack/plugins/net'))
|
.use(require('secret-stack/plugins/net'))
|
||||||
.use(require('secret-handshake-ext/secret-stack'))
|
.use(require('secret-handshake-ext/secret-stack'))
|
||||||
|
@ -25,7 +34,9 @@ function createPeer(opts) {
|
||||||
.use(require('ssb-box'))
|
.use(require('ssb-box'))
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
.call(null, {
|
.call(null, {
|
||||||
caps,
|
shse: { caps },
|
||||||
|
...config,
|
||||||
|
global: {
|
||||||
connections: {
|
connections: {
|
||||||
incoming: {
|
incoming: {
|
||||||
net: [{ scope: 'device', transform: 'shse', port: null }],
|
net: [{ scope: 'device', transform: 'shse', port: null }],
|
||||||
|
@ -34,7 +45,8 @@ function createPeer(opts) {
|
||||||
net: [{ transform: 'shse' }],
|
net: [{ transform: 'shse' }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...opts,
|
...config.global,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue