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

View File

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