Change type and proc names to better match IPFS API

This commit is contained in:
Mark Spanbroek 2021-01-14 14:04:04 +01:00 committed by markspanbroek
parent 05a7f47113
commit 5a36e26e7c
2 changed files with 16 additions and 16 deletions

View File

@ -1,22 +1,22 @@
import pkg/chronos
type
DaggerPeer* = ref object
Ipfs* = ref object
proc newDaggerPeer*: DaggerPeer =
DaggerPeer()
proc create*(t: typedesc[Ipfs]): Ipfs =
Ipfs()
proc listen*(peer: DaggerPeer, address: TransportAddress) =
proc listen*(peer: Ipfs, address: TransportAddress) =
discard
proc dial*(peer: DaggerPeer, address: TransportAddress) =
proc connect*(peer: Ipfs, address: TransportAddress) =
discard
proc upload*(peer: DaggerPeer, input: File): Future[string] {.async.} =
proc add*(peer: Ipfs, input: File): Future[string] {.async.} =
discard
proc download*(peer: DaggerPeer, identifier: string, output: File) {.async.} =
proc get*(peer: Ipfs, identifier: string, output: File) {.async.} =
discard
proc close*(peer: DaggerPeer) =
proc stop*(peer: Ipfs) =
discard

View File

@ -7,14 +7,14 @@ suite "integration":
let address = initTAddress("127.0.0.1:48952")
var peer1, peer2: DaggerPeer
var peer1, peer2: Ipfs
var input, output: File
proc setupPeers =
peer1 = newDaggerPeer()
peer2 = newDaggerPeer()
peer1 = Ipfs.create()
peer2 = Ipfs.create()
peer1.listen(address)
peer2.dial(address)
peer2.connect(address)
proc setupFiles =
input = open("tests/input.txt", fmReadWrite)
@ -23,8 +23,8 @@ suite "integration":
input.setFilePos(0)
proc teardownPeers =
peer1.close()
peer2.close()
peer1.stop()
peer2.stop()
proc teardownFiles =
input.close()
@ -41,8 +41,8 @@ suite "integration":
teardownFiles()
test "file can be transferred from one peer to another":
let identifier = await peer1.upload(input)
await peer2.download(identifier, output)
let identifier = await peer1.add(input)
await peer2.get(identifier, output)
input.setFilePos(0)
output.setFilePos(0)