Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

[WIP] test/NFS: add test which creates a file with NFS and reads it with ImD API #314

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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