mirror of https://codeberg.org/pzp/pzp-db.git
refactor/prettify tests
This commit is contained in:
parent
9356b9b3d9
commit
f40ea71ff9
|
@ -12,6 +12,7 @@ const DIR = path.join(os.tmpdir(), 'ppppp-db-account-add')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
test('account.add()', async (t) => {
|
test('account.add()', async (t) => {
|
||||||
|
await t.test('Basic usage', async (t) => {
|
||||||
const keypair1 = Keypair.generate('ed25519', 'alice')
|
const keypair1 = Keypair.generate('ed25519', 'alice')
|
||||||
const keypair2 = Keypair.generate('ed25519', 'bob')
|
const keypair2 = Keypair.generate('ed25519', 'bob')
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ test('account.add()', async (t) => {
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('keypair with no "add" powers cannot account.add()', async (t) => {
|
await t.test('keypair with no "add" powers cannot add', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
const keypair1 = Keypair.generate('ed25519', 'alice')
|
const keypair1 = Keypair.generate('ed25519', 'alice')
|
||||||
const keypair2 = Keypair.generate('ed25519', 'bob')
|
const keypair2 = Keypair.generate('ed25519', 'bob')
|
||||||
|
@ -150,7 +151,7 @@ test('keypair with no "add" powers cannot account.add()', async (t) => {
|
||||||
await p(peer1again.close)()
|
await p(peer1again.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('publish with a key in the account', async (t) => {
|
await t.test('publish with a key in the account', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
const keypair1 = Keypair.generate('ed25519', 'alice')
|
const keypair1 = Keypair.generate('ed25519', 'alice')
|
||||||
|
@ -226,3 +227,4 @@ test('publish with a key in the account', async (t) => {
|
||||||
|
|
||||||
await p(carol.close)()
|
await p(carol.close)()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -11,7 +11,8 @@ const Keypair = require('ppppp-keypair')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-account-create')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-account-create')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
test('account.create() with just "domain"', async (t) => {
|
test('account.create() ', async (t) => {
|
||||||
|
await t.test('create with just "domain"', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const peer = SecretStack({ appKey: caps.shse })
|
const peer = SecretStack({ appKey: caps.shse })
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
|
@ -53,7 +54,7 @@ test('account.create() with just "domain"', async (t) => {
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('account.create() with "keypair" and "domain"', async (t) => {
|
await t.test('create with "keypair" and "domain"', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ test('account.create() with "keypair" and "domain"', async (t) => {
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('account.find() can find', async (t) => {
|
await t.test('account.find() can find', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const domain = 'person'
|
const domain = 'person'
|
||||||
|
@ -102,7 +103,7 @@ test('account.find() can find', async (t) => {
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('account.findOrCreate() can find', async (t) => {
|
await t.test('account.findOrCreate() can find', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const domain = 'person'
|
const domain = 'person'
|
||||||
|
@ -122,7 +123,7 @@ test('account.findOrCreate() can find', async (t) => {
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('account.findOrCreate() can create', async (t) => {
|
await t.test('account.findOrCreate() can create', async (t) => {
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const domain = 'person'
|
const domain = 'person'
|
||||||
|
@ -156,3 +157,4 @@ test('account.findOrCreate() can create', async (t) => {
|
||||||
|
|
||||||
await p(peer.close)()
|
await p(peer.close)()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -6,14 +6,13 @@ const p = require('node:util').promisify
|
||||||
const rimraf = require('rimraf')
|
const rimraf = require('rimraf')
|
||||||
const SecretStack = require('secret-stack')
|
const SecretStack = require('secret-stack')
|
||||||
const Log = require('../lib/log')
|
const Log = require('../lib/log')
|
||||||
const push = require('push-stream')
|
|
||||||
const caps = require('ppppp-caps')
|
const caps = require('ppppp-caps')
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
|
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-del')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-del')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
test('del', async (t) => {
|
test('del()', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const peer = SecretStack({ appKey: caps.shse })
|
const peer = SecretStack({ appKey: caps.shse })
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
|
|
|
@ -13,7 +13,7 @@ const Keypair = require('ppppp-keypair')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-erase')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-erase')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
test('erase', async (t) => {
|
test('erase()', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const peer = SecretStack({ appKey: caps.shse })
|
const peer = SecretStack({ appKey: caps.shse })
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
|
|
|
@ -12,31 +12,23 @@ const MsgV3 = require('../lib/msg-v3')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-publish')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-publish')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
|
test('feed.getID()', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
let peer
|
const peer = SecretStack({ appKey: caps.shse })
|
||||||
let id
|
|
||||||
let moot
|
|
||||||
let mootID
|
|
||||||
test('setup', async (t) => {
|
|
||||||
peer = SecretStack({ appKey: caps.shse })
|
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
.use(require('ssb-box'))
|
.use(require('ssb-box'))
|
||||||
.call(null, { keypair, path: DIR })
|
.call(null, { keypair, path: DIR })
|
||||||
|
|
||||||
await peer.db.loaded()
|
await peer.db.loaded()
|
||||||
|
|
||||||
id = (await p(peer.db.account.create)({domain: 'person'}))
|
const id = await p(peer.db.account.create)({ domain: 'person' })
|
||||||
moot = MsgV3.createMoot(id, 'post', keypair)
|
const moot = MsgV3.createMoot(id, 'post', keypair)
|
||||||
mootID = MsgV3.getMsgID(moot)
|
const mootID = MsgV3.getMsgID(moot)
|
||||||
|
|
||||||
await p(peer.db.add)(moot, mootID)
|
await p(peer.db.add)(moot, mootID)
|
||||||
})
|
|
||||||
|
|
||||||
test('feed.getID()', async (t) => {
|
|
||||||
const feedID = peer.db.feed.getID(id, 'post')
|
const feedID = peer.db.feed.getID(id, 'post')
|
||||||
assert.equal(feedID, mootID, 'feed.getID() returns moot ID')
|
assert.equal(feedID, mootID, 'feed.getID() returns moot ID')
|
||||||
})
|
|
||||||
|
|
||||||
test('teardown', (t) => {
|
await p(peer.close)(true)
|
||||||
peer.close(t.end)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,13 +12,16 @@ const MsgV3 = require('../lib/msg-v3')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-publish')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-publish')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
|
test('feed.publish()', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const bobKeypair = Keypair.generate('ed25519', 'bob')
|
const bobKeypair = Keypair.generate('ed25519', 'bob')
|
||||||
let peer
|
let peer
|
||||||
let id
|
let id
|
||||||
let moot
|
let moot
|
||||||
let mootID
|
let mootID
|
||||||
test('setup', async (t) => {
|
|
||||||
|
// Setup
|
||||||
|
{
|
||||||
peer = SecretStack({ appKey: caps.shse })
|
peer = SecretStack({ appKey: caps.shse })
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
.use(require('ssb-box'))
|
.use(require('ssb-box'))
|
||||||
|
@ -26,15 +29,16 @@ test('setup', async (t) => {
|
||||||
|
|
||||||
await peer.db.loaded()
|
await peer.db.loaded()
|
||||||
|
|
||||||
id = (await p(peer.db.account.create)({domain: 'person'}))
|
id = await p(peer.db.account.create)({ domain: 'person' })
|
||||||
moot = MsgV3.createMoot(id, 'post', keypair)
|
moot = MsgV3.createMoot(id, 'post', keypair)
|
||||||
mootID = MsgV3.getMsgID(moot)
|
mootID = MsgV3.getMsgID(moot)
|
||||||
})
|
}
|
||||||
|
|
||||||
let msgID1
|
let msgID1
|
||||||
let rec1
|
let rec1
|
||||||
let msgID2
|
let msgID2
|
||||||
test('feed.publish()', async (t) => {
|
|
||||||
|
await t.test('can add new msgs to the db', async (t) => {
|
||||||
rec1 = await p(peer.db.feed.publish)({
|
rec1 = await p(peer.db.feed.publish)({
|
||||||
account: id,
|
account: id,
|
||||||
domain: 'post',
|
domain: 'post',
|
||||||
|
@ -73,7 +77,7 @@ test('feed.publish()', async (t) => {
|
||||||
msgID2 = MsgV3.getMsgID(rec2.msg)
|
msgID2 = MsgV3.getMsgID(rec2.msg)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('add() forked then feed.publish() merged', async (t) => {
|
await t.test('merges tangle after a forked add()', async (t) => {
|
||||||
const tangle = new MsgV3.Tangle(mootID)
|
const tangle = new MsgV3.Tangle(mootID)
|
||||||
tangle.add(mootID, moot)
|
tangle.add(mootID, moot)
|
||||||
tangle.add(rec1.id, rec1.msg)
|
tangle.add(rec1.id, rec1.msg)
|
||||||
|
@ -117,7 +121,7 @@ test('add() forked then feed.publish() merged', async (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('feed.publish() encrypted with box', async (t) => {
|
await t.test('publish encrypted with box', async (t) => {
|
||||||
const recEncrypted = await p(peer.db.feed.publish)({
|
const recEncrypted = await p(peer.db.feed.publish)({
|
||||||
account: id,
|
account: id,
|
||||||
domain: 'post',
|
domain: 'post',
|
||||||
|
@ -131,7 +135,7 @@ test('feed.publish() encrypted with box', async (t) => {
|
||||||
assert.equal(msgDecrypted.data.text, 'I am chewing food')
|
assert.equal(msgDecrypted.data.text, 'I am chewing food')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('feed.publish() with tangles', async (t) => {
|
await t.test('publish with tangles', async (t) => {
|
||||||
const recA = await p(peer.db.feed.publish)({
|
const recA = await p(peer.db.feed.publish)({
|
||||||
account: id,
|
account: id,
|
||||||
domain: 'comment',
|
domain: 'comment',
|
||||||
|
@ -154,6 +158,5 @@ test('feed.publish() with tangles', async (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('teardown', (t) => {
|
await p(peer.close)(true)
|
||||||
peer.close(t.end)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,34 +12,27 @@ const MsgV3 = require('../lib/msg-v3')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-get')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-get')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
|
test('get()', async (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
let peer
|
const peer = SecretStack({ appKey: caps.shse })
|
||||||
let id
|
|
||||||
let msgID1
|
|
||||||
test('setup', async (t) => {
|
|
||||||
peer = SecretStack({ appKey: caps.shse })
|
|
||||||
.use(require('../lib'))
|
.use(require('../lib'))
|
||||||
.use(require('ssb-box'))
|
.use(require('ssb-box'))
|
||||||
.call(null, { keypair, path: DIR })
|
.call(null, { keypair, path: DIR })
|
||||||
|
|
||||||
await peer.db.loaded()
|
await peer.db.loaded()
|
||||||
|
|
||||||
id = (await p(peer.db.account.create)({domain: 'person'}))
|
const id = await p(peer.db.account.create)({ domain: 'person' })
|
||||||
|
|
||||||
const rec1 = await p(peer.db.feed.publish)({
|
const rec1 = await p(peer.db.feed.publish)({
|
||||||
account: id,
|
account: id,
|
||||||
domain: 'post',
|
domain: 'post',
|
||||||
data: { text: 'I am 1st post' },
|
data: { text: 'I am 1st post' },
|
||||||
})
|
})
|
||||||
msgID1 = MsgV3.getMsgID(rec1.msg)
|
const msgID1 = MsgV3.getMsgID(rec1.msg)
|
||||||
})
|
|
||||||
|
|
||||||
test('get() supports msg IDs', async (t) => {
|
|
||||||
const msg = peer.db.get(msgID1)
|
const msg = peer.db.get(msgID1)
|
||||||
assert.ok(msg, 'msg exists')
|
assert.ok(msg, 'msg exists')
|
||||||
assert.equal(msg.data.text, 'I am 1st post')
|
assert.equal(msg.data.text, 'I am 1st post')
|
||||||
})
|
|
||||||
|
|
||||||
test('teardown', (t) => {
|
await p(peer.close)(true)
|
||||||
peer.close(t.end)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,10 +11,13 @@ const Keypair = require('ppppp-keypair')
|
||||||
const DIR = path.join(os.tmpdir(), 'ppppp-db-tangle')
|
const DIR = path.join(os.tmpdir(), 'ppppp-db-tangle')
|
||||||
rimraf.sync(DIR)
|
rimraf.sync(DIR)
|
||||||
|
|
||||||
|
test('getTangle()', async (t) => {
|
||||||
let peer
|
let peer
|
||||||
let rootPost, reply1Lo, reply1Hi, reply2, reply3Lo, reply3Hi
|
let rootPost, reply1Lo, reply1Hi, reply2, reply3Lo, reply3Hi
|
||||||
let tangle
|
let tangle
|
||||||
test('setup', async (t) => {
|
|
||||||
|
// Setup
|
||||||
|
{
|
||||||
const keypairA = Keypair.generate('ed25519', 'alice')
|
const keypairA = Keypair.generate('ed25519', 'alice')
|
||||||
const keypairB = Keypair.generate('ed25519', 'bob')
|
const keypairB = Keypair.generate('ed25519', 'bob')
|
||||||
const keypairC = Keypair.generate('ed25519', 'carol')
|
const keypairC = Keypair.generate('ed25519', 'carol')
|
||||||
|
@ -92,9 +95,9 @@ test('setup', async (t) => {
|
||||||
reply3Hi = reply3B.localeCompare(reply3C) < 0 ? reply3C : reply3B
|
reply3Hi = reply3B.localeCompare(reply3C) < 0 ? reply3C : reply3B
|
||||||
|
|
||||||
tangle = peer.db.getTangle(rootPost)
|
tangle = peer.db.getTangle(rootPost)
|
||||||
})
|
}
|
||||||
|
|
||||||
test('Tangle.has', (t) => {
|
await t.test('Tangle.has', (t) => {
|
||||||
assert.equal(tangle.has(rootPost), true, 'has rootPost')
|
assert.equal(tangle.has(rootPost), true, 'has rootPost')
|
||||||
assert.equal(tangle.has(reply1Lo), true, 'has reply1Lo')
|
assert.equal(tangle.has(reply1Lo), true, 'has reply1Lo')
|
||||||
assert.equal(tangle.has(reply1Hi), true, 'has reply1Hi')
|
assert.equal(tangle.has(reply1Hi), true, 'has reply1Hi')
|
||||||
|
@ -104,7 +107,7 @@ test('Tangle.has', (t) => {
|
||||||
assert.equal(tangle.has('nonsense'), false, 'does not have nonsense')
|
assert.equal(tangle.has('nonsense'), false, 'does not have nonsense')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getDepth', (t) => {
|
await t.test('Tangle.getDepth', (t) => {
|
||||||
assert.equal(tangle.getDepth(rootPost), 0, 'depth of rootPost is 0')
|
assert.equal(tangle.getDepth(rootPost), 0, 'depth of rootPost is 0')
|
||||||
assert.equal(tangle.getDepth(reply1Lo), 1, 'depth of reply1Lo is 1')
|
assert.equal(tangle.getDepth(reply1Lo), 1, 'depth of reply1Lo is 1')
|
||||||
assert.equal(tangle.getDepth(reply1Hi), 1, 'depth of reply1Hi is 1')
|
assert.equal(tangle.getDepth(reply1Hi), 1, 'depth of reply1Hi is 1')
|
||||||
|
@ -113,11 +116,11 @@ test('Tangle.getDepth', (t) => {
|
||||||
assert.equal(tangle.getDepth(reply3Hi), 3, 'depth of reply3Hi is 3')
|
assert.equal(tangle.getDepth(reply3Hi), 3, 'depth of reply3Hi is 3')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.maxDepth', (t) => {
|
await t.test('Tangle.maxDepth', (t) => {
|
||||||
assert.equal(tangle.maxDepth, 3, 'max depth is 3')
|
assert.equal(tangle.maxDepth, 3, 'max depth is 3')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.topoSort', (t) => {
|
await t.test('Tangle.topoSort', (t) => {
|
||||||
const sorted = tangle.topoSort()
|
const sorted = tangle.topoSort()
|
||||||
|
|
||||||
assert.deepEqual(sorted, [
|
assert.deepEqual(sorted, [
|
||||||
|
@ -130,7 +133,7 @@ test('Tangle.topoSort', (t) => {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.precedes', (t) => {
|
await t.test('Tangle.precedes', (t) => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
tangle.precedes(rootPost, reply1Lo),
|
tangle.precedes(rootPost, reply1Lo),
|
||||||
true,
|
true,
|
||||||
|
@ -173,7 +176,7 @@ test('Tangle.precedes', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.tips', (t) => {
|
await t.test('Tangle.tips', (t) => {
|
||||||
const tips = tangle.tips
|
const tips = tangle.tips
|
||||||
|
|
||||||
assert.equal(tips.size, 2, 'there are 2 tips')
|
assert.equal(tips.size, 2, 'there are 2 tips')
|
||||||
|
@ -181,7 +184,7 @@ test('Tangle.tips', (t) => {
|
||||||
assert.equal(tips.has(reply3Hi), true, 'tips contains reply3Hi')
|
assert.equal(tips.has(reply3Hi), true, 'tips contains reply3Hi')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getLipmaaSet', (t) => {
|
await t.test('Tangle.getLipmaaSet', (t) => {
|
||||||
assert.equal(tangle.getLipmaaSet(0).size, 0, 'lipmaa 0 (empty)')
|
assert.equal(tangle.getLipmaaSet(0).size, 0, 'lipmaa 0 (empty)')
|
||||||
|
|
||||||
assert.equal(tangle.getLipmaaSet(1).size, 1, 'lipmaa 1 (-1)')
|
assert.equal(tangle.getLipmaaSet(1).size, 1, 'lipmaa 1 (-1)')
|
||||||
|
@ -201,14 +204,14 @@ test('Tangle.getLipmaaSet', (t) => {
|
||||||
assert.equal(tangle.getLipmaaSet(5).size, 0, 'lipmaa 5 (empty)')
|
assert.equal(tangle.getLipmaaSet(5).size, 0, 'lipmaa 5 (empty)')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getDeletablesAndErasables basic', (t) => {
|
await t.test('Tangle.getDeletablesAndErasables basic', (t) => {
|
||||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(reply2)
|
const { deletables, erasables } = tangle.getDeletablesAndErasables(reply2)
|
||||||
|
|
||||||
assert.deepEqual([...deletables], [reply1Hi], 'deletables')
|
assert.deepEqual([...deletables], [reply1Hi], 'deletables')
|
||||||
assert.deepEqual([...erasables], [reply1Lo, rootPost], 'erasables')
|
assert.deepEqual([...erasables], [reply1Lo, rootPost], 'erasables')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getDeletablesAndErasables with many inputs', (t) => {
|
await t.test('Tangle.getDeletablesAndErasables with many inputs', (t) => {
|
||||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(
|
const { deletables, erasables } = tangle.getDeletablesAndErasables(
|
||||||
reply3Lo,
|
reply3Lo,
|
||||||
reply2
|
reply2
|
||||||
|
@ -218,24 +221,35 @@ test('Tangle.getDeletablesAndErasables with many inputs', (t) => {
|
||||||
assert.deepEqual([...erasables], [reply1Lo, rootPost], 'erasables')
|
assert.deepEqual([...erasables], [reply1Lo, rootPost], 'erasables')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getDeletablesAndErasables with many inputs again', (t) => {
|
await t.test(
|
||||||
|
'Tangle.getDeletablesAndErasables with many inputs again',
|
||||||
|
(t) => {
|
||||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(
|
const { deletables, erasables } = tangle.getDeletablesAndErasables(
|
||||||
reply3Lo,
|
reply3Lo,
|
||||||
reply3Hi
|
reply3Hi
|
||||||
)
|
)
|
||||||
|
|
||||||
assert.deepEqual([...deletables], [reply1Lo, reply1Hi, reply2], 'deletables')
|
assert.deepEqual(
|
||||||
|
[...deletables],
|
||||||
|
[reply1Lo, reply1Hi, reply2],
|
||||||
|
'deletables'
|
||||||
|
)
|
||||||
assert.deepEqual([...erasables], [rootPost], 'erasables')
|
assert.deepEqual([...erasables], [rootPost], 'erasables')
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test('Tangle.getDeletablesAndErasables with lipmaa', (t) => {
|
await t.test('Tangle.getDeletablesAndErasables with lipmaa', (t) => {
|
||||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(reply3Lo)
|
const { deletables, erasables } = tangle.getDeletablesAndErasables(reply3Lo)
|
||||||
|
|
||||||
assert.deepEqual([...deletables], [reply1Lo, reply1Hi, reply2], 'deletables')
|
assert.deepEqual(
|
||||||
|
[...deletables],
|
||||||
|
[reply1Lo, reply1Hi, reply2],
|
||||||
|
'deletables'
|
||||||
|
)
|
||||||
assert.deepEqual([...erasables], [rootPost], 'erasables')
|
assert.deepEqual([...erasables], [rootPost], 'erasables')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.getMinimumAmong', (t) => {
|
await t.test('Tangle.getMinimumAmong', (t) => {
|
||||||
const actual1 = tangle.getMinimumAmong([reply1Lo, reply1Hi])
|
const actual1 = tangle.getMinimumAmong([reply1Lo, reply1Hi])
|
||||||
const expected1 = [reply1Lo, reply1Hi]
|
const expected1 = [reply1Lo, reply1Hi]
|
||||||
assert.deepEqual(actual1, expected1)
|
assert.deepEqual(actual1, expected1)
|
||||||
|
@ -253,8 +267,11 @@ test('Tangle.getMinimumAmong', (t) => {
|
||||||
assert.deepEqual(actual4, expected4)
|
assert.deepEqual(actual4, expected4)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tangle.topoSort after some have been deleted and erased', async (t) => {
|
await t.test(
|
||||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(reply3Lo)
|
'Tangle.topoSort after some have been deleted and erased',
|
||||||
|
async (t) => {
|
||||||
|
const { deletables, erasables } =
|
||||||
|
tangle.getDeletablesAndErasables(reply3Lo)
|
||||||
for (const msgID of deletables) {
|
for (const msgID of deletables) {
|
||||||
await p(peer.db.del)(msgID)
|
await p(peer.db.del)(msgID)
|
||||||
}
|
}
|
||||||
|
@ -266,8 +283,8 @@ test('Tangle.topoSort after some have been deleted and erased', async (t) => {
|
||||||
const sorted = tangle2.topoSort()
|
const sorted = tangle2.topoSort()
|
||||||
|
|
||||||
assert.deepEqual(sorted, [rootPost, reply3Lo, reply3Hi])
|
assert.deepEqual(sorted, [rootPost, reply3Lo, reply3Hi])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test('teardown', async (t) => {
|
|
||||||
await p(peer.close)(true)
|
await p(peer.close)(true)
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,8 @@ const fs = require('node:fs')
|
||||||
const p = require('node:util').promisify
|
const p = require('node:util').promisify
|
||||||
const Log = require('../../lib/log')
|
const Log = require('../../lib/log')
|
||||||
|
|
||||||
test('Log handles basic binary records', async function (t) {
|
test('Log basics', async function (t) {
|
||||||
|
await t.test('Log handles basic binary records', async function (t) {
|
||||||
const file = '/tmp/ppppp-db-log-test-basic-binary.log'
|
const file = '/tmp/ppppp-db-log-test-basic-binary.log'
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file)
|
fs.unlinkSync(file)
|
||||||
|
@ -32,7 +33,7 @@ test('Log handles basic binary records', async function (t) {
|
||||||
const json1 = { text: 'testing' }
|
const json1 = { text: 'testing' }
|
||||||
const json2 = { test: 'testing2' }
|
const json2 = { test: 'testing2' }
|
||||||
|
|
||||||
test('Log handles basic json records', async function (t) {
|
await t.test('Log handles basic json records', async function (t) {
|
||||||
const file = '/tmp/ppppp-db-log-test-basic-json.log'
|
const file = '/tmp/ppppp-db-log-test-basic-json.log'
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file)
|
fs.unlinkSync(file)
|
||||||
|
@ -57,7 +58,7 @@ test('Log handles basic json records', async function (t) {
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Log handles basic json record re-reading', async function (t) {
|
await t.test('Log handles basic json record re-reading', async function (t) {
|
||||||
const file = '/tmp/ppppp-db-log-test-basic-json.log'
|
const file = '/tmp/ppppp-db-log-test-basic-json.log'
|
||||||
const log = Log(file, {
|
const log = Log(file, {
|
||||||
blockSize: 2 * 1024,
|
blockSize: 2 * 1024,
|
||||||
|
@ -75,3 +76,4 @@ test('Log handles basic json record re-reading', async function (t) {
|
||||||
|
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -14,7 +14,8 @@ const msg3 = Buffer.from(
|
||||||
'hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db'
|
'hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db hello offsetty db'
|
||||||
)
|
)
|
||||||
|
|
||||||
test('Log performing simple delete', async (t) => {
|
test('Log deletes', async (t) => {
|
||||||
|
await t.test('Simple delete', async (t) => {
|
||||||
const file = '/tmp/ppppp-db-log-test-del.log'
|
const file = '/tmp/ppppp-db-log-test-del.log'
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file)
|
fs.unlinkSync(file)
|
||||||
|
@ -47,7 +48,7 @@ test('Log performing simple delete', async (t) => {
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Log deleted records are not invalid upon re-opening', async (t) => {
|
await t.test('Deleted records are not invalid upon re-opening', async (t) => {
|
||||||
const file = '/tmp/ppppp-db-log-test-del-invalid.log'
|
const file = '/tmp/ppppp-db-log-test-del-invalid.log'
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file)
|
fs.unlinkSync(file)
|
||||||
|
@ -109,7 +110,7 @@ test('Log deleted records are not invalid upon re-opening', async (t) => {
|
||||||
await p(log2.close)()
|
await p(log2.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Log deletes are handled by scan()', async (t) => {
|
await t.test('Deletes are noticed by scan()', async (t) => {
|
||||||
const file = '/tmp/offset-test_' + Date.now() + '.log'
|
const file = '/tmp/offset-test_' + Date.now() + '.log'
|
||||||
const log = Log(file, { blockSize: 64 * 1024 })
|
const log = Log(file, { blockSize: 64 * 1024 })
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ test('Log deletes are handled by scan()', async (t) => {
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Log can handle many deleted records', { timeout: 60e3 }, async (t) => {
|
await t.test('Many deleted records', { timeout: 60e3 }, async (t) => {
|
||||||
const file = '/tmp/aaol-test-delete-many' + Date.now() + '.log'
|
const file = '/tmp/aaol-test-delete-many' + Date.now() + '.log'
|
||||||
const log = Log(file, { blockSize: 64 * 1024 })
|
const log = Log(file, { blockSize: 64 * 1024 })
|
||||||
|
|
||||||
|
@ -187,3 +188,4 @@ test('Log can handle many deleted records', { timeout: 60e3 }, async (t) => {
|
||||||
|
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -9,7 +9,8 @@ var file = '/tmp/ds-test_restart.log'
|
||||||
var msg1 = { text: 'hello world hello world' }
|
var msg1 = { text: 'hello world hello world' }
|
||||||
var msg2 = { text: 'hello world hello world 2' }
|
var msg2 = { text: 'hello world hello world 2' }
|
||||||
|
|
||||||
test('Log (fix buggy write) simple', async (t) => {
|
test('Log fix buggy write', async (t) => {
|
||||||
|
await t.test('Simple', async (t) => {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file)
|
fs.unlinkSync(file)
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
@ -41,7 +42,7 @@ test('Log (fix buggy write) simple', async (t) => {
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Log (fix buggy write) reread', async (t) => {
|
await t.test('Re-read', async (t) => {
|
||||||
const log = Log(file, {
|
const log = Log(file, {
|
||||||
block: 16 * 1024,
|
block: 16 * 1024,
|
||||||
codec: require('flumecodec/json'),
|
codec: require('flumecodec/json'),
|
||||||
|
@ -64,3 +65,4 @@ test('Log (fix buggy write) reread', async (t) => {
|
||||||
|
|
||||||
await p(log.close)()
|
await p(log.close)()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -3,7 +3,8 @@ const assert = require('node:assert')
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
const MsgV3 = require('../../lib/msg-v3')
|
const MsgV3 = require('../../lib/msg-v3')
|
||||||
|
|
||||||
test('MsgV3 invalid domain not a string', (t) => {
|
test('MsgV3 domain validation', async (t) => {
|
||||||
|
await t.test('Not a string', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -19,7 +20,7 @@ test('MsgV3 invalid domain not a string', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid domain with "/" character', (t) => {
|
await t.test('"/" character', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -35,7 +36,7 @@ test('MsgV3 invalid domain with "/" character', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid domain with "*" character', (t) => {
|
await t.test('"*" character', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -51,7 +52,7 @@ test('MsgV3 invalid domain with "*" character', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid domain too short', (t) => {
|
await t.test('Too short', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -67,7 +68,7 @@ test('MsgV3 invalid domain too short', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid domain too long', (t) => {
|
await t.test('too long', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -82,3 +83,4 @@ test('MsgV3 invalid domain too long', (t) => {
|
||||||
'invalid domain if too long'
|
'invalid domain if too long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -10,7 +10,8 @@ const account = MsgV3.getMsgID(
|
||||||
)
|
)
|
||||||
const pubkeys = new Set([keypair.public])
|
const pubkeys = new Set([keypair.public])
|
||||||
|
|
||||||
test('MsgV3 invalid msg with non-array prev', (t) => {
|
test('MsgV3 tangles prev validation', async (t) => {
|
||||||
|
await t.test('Non-array is a bad prev', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -41,7 +42,7 @@ test('MsgV3 invalid msg with non-array prev', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid msg with bad prev', (t) => {
|
await t.test('Number not allowed in prev', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -86,7 +87,7 @@ test('MsgV3 invalid msg with bad prev', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid msg with URI in prev', (t) => {
|
await t.test('URI not allowed in prev', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -129,7 +130,7 @@ test('MsgV3 invalid msg with URI in prev', (t) => {
|
||||||
assert.match(err, /prev item ".*" is a URI/, 'invalid 2nd msg description')
|
assert.match(err, /prev item ".*" is a URI/, 'invalid 2nd msg description')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid msg with unknown prev', (t) => {
|
await t.test('Locally unknown prev msgID', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -189,7 +190,7 @@ test('MsgV3 invalid msg with unknown prev', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid feed msg with a different pubkey', (t) => {
|
await t.test('Feed msg with the wrong pubkey', (t) => {
|
||||||
const keypairA = Keypair.generate('ed25519', 'alice')
|
const keypairA = Keypair.generate('ed25519', 'alice')
|
||||||
const keypairB = Keypair.generate('ed25519', 'bob')
|
const keypairB = Keypair.generate('ed25519', 'bob')
|
||||||
|
|
||||||
|
@ -223,7 +224,7 @@ test('MsgV3 invalid feed msg with a different pubkey', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid feed msg with a different domain', (t) => {
|
await t.test('Feed msg with the wrong domain', (t) => {
|
||||||
const keypairA = Keypair.generate('ed25519', 'alice')
|
const keypairA = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -252,7 +253,7 @@ test('MsgV3 invalid feed msg with a different domain', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid feed msg with non-alphabetical prev', (t) => {
|
await t.test('Feed msg with non-alphabetically sorted prev', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -317,7 +318,7 @@ test('MsgV3 invalid feed msg with non-alphabetical prev', (t) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 invalid feed msg with duplicate prev', (t) => {
|
await t.test('Feed msg with duplicate prev', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
|
|
||||||
const moot = MsgV3.createMoot(account, 'post', keypair)
|
const moot = MsgV3.createMoot(account, 'post', keypair)
|
||||||
|
@ -345,3 +346,4 @@ test('MsgV3 invalid feed msg with duplicate prev', (t) => {
|
||||||
assert.ok(err, 'invalid 1st msg throws')
|
assert.ok(err, 'invalid 1st msg throws')
|
||||||
assert.match(err, /prev ".*" contains duplicates/, 'invalid error message')
|
assert.match(err, /prev ".*" contains duplicates/, 'invalid error message')
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -3,7 +3,8 @@ const assert = require('node:assert')
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
const MsgV3 = require('../../lib/msg-v3')
|
const MsgV3 = require('../../lib/msg-v3')
|
||||||
|
|
||||||
test('MsgV3 validate root msg', (t) => {
|
test('MsgV3 validation', async (t) => {
|
||||||
|
await t.test('Correct root msg', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const account = MsgV3.getMsgID(
|
const account = MsgV3.getMsgID(
|
||||||
MsgV3.createAccount(keypair, 'person', 'alice')
|
MsgV3.createAccount(keypair, 'person', 'alice')
|
||||||
|
@ -19,7 +20,7 @@ test('MsgV3 validate root msg', (t) => {
|
||||||
assert.ifError(err, 'valid root msg')
|
assert.ifError(err, 'valid root msg')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 validate account tangle', (t) => {
|
await t.test('Correct account tangle', (t) => {
|
||||||
const pubkeys = new Set()
|
const pubkeys = new Set()
|
||||||
const keypair1 = Keypair.generate('ed25519', 'alice')
|
const keypair1 = Keypair.generate('ed25519', 'alice')
|
||||||
pubkeys.add(keypair1.public)
|
pubkeys.add(keypair1.public)
|
||||||
|
@ -56,17 +57,11 @@ test('MsgV3 validate account tangle', (t) => {
|
||||||
})
|
})
|
||||||
const accountMsg1ID = MsgV3.getMsgID(accountMsg1)
|
const accountMsg1ID = MsgV3.getMsgID(accountMsg1)
|
||||||
|
|
||||||
err = MsgV3.validate(
|
err = MsgV3.validate(accountMsg1, tangle, pubkeys, accountMsg1ID, account)
|
||||||
accountMsg1,
|
|
||||||
tangle,
|
|
||||||
pubkeys,
|
|
||||||
accountMsg1ID,
|
|
||||||
account
|
|
||||||
)
|
|
||||||
assert.ifError(err, 'valid account msg')
|
assert.ifError(err, 'valid account msg')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 validate 2nd msg with existing root', (t) => {
|
await t.test('2nd msg correct with existing root', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const account = MsgV3.getMsgID(
|
const account = MsgV3.getMsgID(
|
||||||
MsgV3.createAccount(keypair, 'person', 'alice')
|
MsgV3.createAccount(keypair, 'person', 'alice')
|
||||||
|
@ -95,7 +90,7 @@ test('MsgV3 validate 2nd msg with existing root', (t) => {
|
||||||
assert.ifError(err, 'valid 2nd msg')
|
assert.ifError(err, 'valid 2nd msg')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 validate 2nd forked msg', (t) => {
|
await t.test('2nd forked msg correct', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const account = MsgV3.getMsgID(
|
const account = MsgV3.getMsgID(
|
||||||
MsgV3.createAccount(keypair, 'person', 'alice')
|
MsgV3.createAccount(keypair, 'person', 'alice')
|
||||||
|
@ -137,7 +132,7 @@ test('MsgV3 validate 2nd forked msg', (t) => {
|
||||||
assert.ifError(err, 'valid 2nd forked msg')
|
assert.ifError(err, 'valid 2nd forked msg')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('MsgV3 validate erased msg', (t) => {
|
await t.test('Correct erased msg', (t) => {
|
||||||
const keypair = Keypair.generate('ed25519', 'alice')
|
const keypair = Keypair.generate('ed25519', 'alice')
|
||||||
const account = MsgV3.getMsgID(
|
const account = MsgV3.getMsgID(
|
||||||
MsgV3.createAccount(keypair, 'person', 'alice')
|
MsgV3.createAccount(keypair, 'person', 'alice')
|
||||||
|
@ -165,3 +160,4 @@ test('MsgV3 validate erased msg', (t) => {
|
||||||
const err = MsgV3.validate(msg1, tangle, pubkeys, msgID1, mootID)
|
const err = MsgV3.validate(msg1, tangle, pubkeys, msgID1, mootID)
|
||||||
assert.ifError(err, 'valid erased msg')
|
assert.ifError(err, 'valid erased msg')
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue