Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/nfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ describe('NFS emulation', () => {
)
);

it.only('create file with NFS and read it with IMD API', async () => {
const md = await app.mutableData.newRandomPublic(TYPE_TAG);
await md.quickSetup({});
const nfs = await md.emulateAs('nfs');
const file = await nfs.open(null, CONSTANTS.NFS_FILE_MODE_OVERWRITE);
await file.write('hello, SAFE world!');
await file.close();
await nfs.insert('hello.txt', file);
const retrievedFile = await nfs.fetch('hello.txt');
// const fetchedFile = await nfs.open(retrievedFile, CONSTANTS.NFS_FILE_MODE_READ);
// const data = await fetchedFile.read(CONSTANTS.NFS_FILE_START, CONSTANTS.NFS_FILE_END);
const fetchedFile = await app.immutableData.fetch(retrievedFile.dataMapName);
const data = await fetchedFile.read();
should(data.toString()).be.equal('hello, SAFE world!');
});

it('provides helper function to create and save file to the network', () => app.mutableData.newRandomPublic(TYPE_TAG)
.then((md) => md.quickSetup({}).then(() => md.emulateAs('nfs')))
.then((nfs) => should(nfs.create('testing')).be.fulfilled())
Expand Down