Get the first tests running

This commit is contained in:
haad
2023-02-16 11:07:13 +02:00
parent f6f14511c1
commit b946741c5c
25 changed files with 3517 additions and 3517 deletions

View File

@@ -1,102 +1,102 @@
import assert from 'assert'
import OrbitDB from '../src/OrbitDB.js'
import rmrf from 'rimraf'
import path from 'path'
// import assert from 'assert'
// import OrbitDB from '../src/OrbitDB.js'
// import rmrf from 'rimraf'
// import path from 'path'
// Include test utilities
import {
config,
startIpfs,
stopIpfs,
testAPIs,
} from 'orbit-db-test-utils'
// // Include test utilities
// import {
// config,
// startIpfs,
// stopIpfs,
// testAPIs,
// } from 'orbit-db-test-utils'
const last = arr => arr[arr.length - 1]
// const last = arr => arr[arr.length - 1]
const dbPath = './orbitdb/tests/feed-load'
// const dbPath = './orbitdb/tests/feed-load'
Object.keys(testAPIs).forEach(API => {
describe(`orbit-db - Feed Load Amount (${API})`, function() {
this.timeout(config.timeout)
// Object.keys(testAPIs).forEach(API => {
// describe(`orbit-db - Feed Load Amount (${API})`, function() {
// this.timeout(config.timeout)
let ipfsd, ipfs, orbitdb1, db, address
// let ipfsd, ipfs, orbitdb1, db, address
before(async () => {
rmrf.sync(dbPath)
ipfsd = await startIpfs(API, config.daemon1)
ipfs = ipfsd.api
orbitdb1 = await OrbitDB.createInstance(ipfs, { directory: path.join(dbPath, '1') })
})
// before(async () => {
// rmrf.sync(dbPath)
// ipfsd = await startIpfs(API, config.daemon1)
// ipfs = ipfsd.api
// orbitdb1 = await OrbitDB.createInstance(ipfs, { directory: path.join(dbPath, '1') })
// })
after(async () => {
if(orbitdb1)
await orbitdb1.stop()
// after(async () => {
// if(orbitdb1)
// await orbitdb1.stop()
if (ipfsd)
await stopIpfs(ipfsd)
})
// if (ipfsd)
// await stopIpfs(ipfsd)
// })
describe('Feed Load Amount', function() {
// describe('Feed Load Amount', function() {
it('add 10 items and verify they are in the index', async () => {
db = await orbitdb1.feed('feed database')
// it('add 10 items and verify they are in the index', async () => {
// db = await orbitdb1.feed('feed database')
//All tests should retrieve these 10 items.
for (var i=0; i < 10; i++) {
await db.add({content: (i + 10).toString()})
}
// //All tests should retrieve these 10 items.
// for (var i=0; i < 10; i++) {
// await db.add({content: (i + 10).toString()})
// }
assert.equal(Object.keys(db.index).length, 10)
})
// assert.equal(Object.keys(db.index).length, 10)
// })
it('reopen store and load 10 items', async () => {
// it('reopen store and load 10 items', async () => {
address = db.address.toString()
await db.close()
db = await orbitdb1.open(address)
// address = db.address.toString()
// await db.close()
// db = await orbitdb1.open(address)
//Load 10 items
await db.load(10)
// //Load 10 items
// await db.load(10)
assert.equal(Object.keys(db.index).length, 10)
// assert.equal(Object.keys(db.index).length, 10)
})
// })
it('reopen store and load 1 item more than exists', async () => {
await db.close()
db = await orbitdb1.open(address)
// it('reopen store and load 1 item more than exists', async () => {
// await db.close()
// db = await orbitdb1.open(address)
//Load 11 items
await db.load(11)
// //Load 11 items
// await db.load(11)
assert.equal(Object.keys(db.index).length, 10)
// assert.equal(Object.keys(db.index).length, 10)
})
// })
it('reopen store and load 5 item more than exists', async () => {
// it('reopen store and load 5 item more than exists', async () => {
await db.close()
db = await orbitdb1.open(address)
// await db.close()
// db = await orbitdb1.open(address)
//Load 15 items
await db.load(15)
// //Load 15 items
// await db.load(15)
assert.equal(Object.keys(db.index).length, 10)
})
// assert.equal(Object.keys(db.index).length, 10)
// })
it('reopen store and load 20 items more than exists', async () => {
// it('reopen store and load 20 items more than exists', async () => {
await db.close()
db = await orbitdb1.open(address)
// await db.close()
// db = await orbitdb1.open(address)
//Load 30 items
await db.load(30)
// //Load 30 items
// await db.load(30)
assert.equal(Object.keys(db.index).length, 10)
})
// assert.equal(Object.keys(db.index).length, 10)
// })
})
// })
})
})
// })
// })