Skip to content

Commit

Permalink
Merge pull request #110 from richardschneider/46-small-files
Browse files Browse the repository at this point in the history
Inline file tests
  • Loading branch information
richardschneider authored Jun 3, 2019
2 parents 89422e6 + 76c6d7c commit 85e6147
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/CoreApi/FileSystemApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,31 @@ public async Task Add_Raw()
Assert.AreEqual("hello world", text);
}

[TestMethod]
public async Task Add_Inline()
{
var ipfs = TestFixture.Ipfs;
var original = ipfs.Options.Block.AllowInlineCid;
try
{
ipfs.Options.Block.AllowInlineCid = true;

var node = await ipfs.FileSystem.AddTextAsync("hiya");
Assert.AreEqual(1, node.Id.Version);
Assert.IsTrue(node.Id.Hash.IsIdentityHash);
Assert.AreEqual(4, node.Size);
Assert.AreEqual(0, node.Links.Count());
Assert.AreEqual(false, node.IsDirectory);
Assert.AreEqual("zBJ95gnTvsVtx49wHb2LGj", node.Id.Encode());
var text = await ipfs.FileSystem.ReadAllTextAsync(node.Id);
Assert.AreEqual("hiya", text);
}
finally
{
ipfs.Options.Block.AllowInlineCid = original;
}
}

[TestMethod]
public async Task Add_RawAndChunked()
{
Expand Down
25 changes: 24 additions & 1 deletion test/CoreApi/ObjectApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ipfs.CoreApi;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
Expand Down Expand Up @@ -135,5 +136,27 @@ public async Task Get_Nonexistent()
}
}

[TestMethod]
/// <seealso href="https://github.com/ipfs/js-ipfs/issues/2084"/>
public async Task Get_Inlinefile()
{
var original = ipfs.Options.Block.AllowInlineCid;
try
{
ipfs.Options.Block.AllowInlineCid = true;

var node = await ipfs.FileSystem.AddTextAsync("hiya");
Assert.AreEqual(1, node.Id.Version);
Assert.IsTrue(node.Id.Hash.IsIdentityHash);

var dag = await ipfs.Object.GetAsync(node.Id);
Assert.AreEqual(12, dag.Size);
}
finally
{
ipfs.Options.Block.AllowInlineCid = original;
}
}

}
}

0 comments on commit 85e6147

Please sign in to comment.