2021-01-12 10:48:26 +00:00
|
|
|
import std/unittest
|
|
|
|
import std/os
|
2021-01-14 12:54:03 +00:00
|
|
|
import pkg/ipfs/chunking
|
2021-01-12 10:48:26 +00:00
|
|
|
|
|
|
|
suite "chunking":
|
|
|
|
|
|
|
|
var input, output: File
|
|
|
|
|
|
|
|
setup:
|
|
|
|
input = open("tests/input.txt", fmReadWrite)
|
|
|
|
output = open("tests/output.txt", fmReadWrite)
|
|
|
|
input.write("foo")
|
|
|
|
input.setFilePos(0)
|
|
|
|
|
|
|
|
teardown:
|
|
|
|
input.close()
|
|
|
|
output.close()
|
|
|
|
removeFile("tests/input.txt")
|
|
|
|
removeFile("tests/output.txt")
|
|
|
|
|
2021-01-14 13:21:07 +00:00
|
|
|
test "creates an IPFS object from a file":
|
|
|
|
check createObject(input) != IpfsObject.default
|
2021-01-12 10:48:26 +00:00
|
|
|
|
2021-01-14 13:21:07 +00:00
|
|
|
test "writes an IPFS object to a file":
|
|
|
|
let obj = createObject(input)
|
|
|
|
writeToFile(obj, output)
|
2021-01-12 10:48:26 +00:00
|
|
|
|
|
|
|
input.setFilePos(0)
|
|
|
|
output.setFilePos(0)
|
|
|
|
check output.readAll() == input.readAll()
|
|
|
|
|