Created by
August Botsford
| import {
makeKeyPair,
make_tuid,
add_file,
} from "../src/blockchain"
import * as crypto from 'crypto'
import {executeWithConnection} from "../src/database";
import {
getFileByTUID,
} from "../src/blockchain_queries";
const should = require('chai').should();
const issuer = makeKeyPair()
const fileTUID = make_tuid()
const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, 'Energirapport.pdf');
function binarise(file) {
return Buffer.from(fs.readFileSync(file));
}
describe("Context", function() {
this.timeout(50000)
it("add file", async function () {
await add_file(issuer, fileTUID, 'EnergiRapport', 'pdf', binarise(filePath))
await executeWithConnection(async conn => {
const result = await getFileByTUID(conn, fileTUID)
result.should.have.property('tuid').to.deep.equal(fileTUID)
})
})
})
|