mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-22 00:52:01 -07:00
25 lines
737 B
JavaScript
25 lines
737 B
JavaScript
/*
|
|
An end-to-end test for testing the functionality of uploading a file to
|
|
IPFS is working.
|
|
*/
|
|
|
|
process.env.IPFS_API = 'http://localhost:5001'
|
|
// process.env.IPFS_API = `https://ipfs-api.fullstack.cash`
|
|
|
|
const BCHJS = require('../../../src/bch-js')
|
|
const bchjs = new BCHJS()
|
|
|
|
describe('#IPFS', () => {
|
|
it('should upload a file to the server', async () => {
|
|
const path = `${__dirname.toString()}/ipfs-e2e.js`
|
|
|
|
const fileModel = await bchjs.IPFS.createFileModel(path)
|
|
console.log(`fileModel: ${JSON.stringify(fileModel, null, 2)}`)
|
|
|
|
const fileId = fileModel.file._id
|
|
|
|
const fileObj = await bchjs.IPFS.uploadFile(path, fileId)
|
|
console.log(`fileObj: ${JSON.stringify(fileObj, null, 2)}`)
|
|
}).timeout(30000)
|
|
})
|