Skip to content

Commit a45461c

Browse files
committed
Add configuration scripts for local IPFS server
1 parent 331bcb9 commit a45461c

File tree

6 files changed

+56
-7
lines changed

6 files changed

+56
-7
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ You can submit bug reports using the
208208

209209
### Setting up a local development environment
210210

211-
1. Follow the instructions in the IPFS documentation to install go-IPFS into your `${PATH}`:
212-
https://docs.ipfs.io/install/command-line/
211+
1. [Install and configure a local IPFS server](tools/ipfs/README.md):
213212
2. Follow the instructions in the (Python) tox documentation to install the `tox` Python environment runner:
214213
https://tox.readthedocs.io/en/latest/install.html
215214
3. Clone the GIT repository if you haven't already:
@@ -235,7 +234,13 @@ make sure that your code passes both the
235234

236235
$ tox -e styleck -e typeck
237236

238-
As well as the unit tests:
237+
As well as the tests:
238+
239+
1. Start IPFS server (do this once in a separate terminal):
240+
241+
$ ./tools/ipfs/run.sh
242+
243+
2. Execute unit and functional tests:
239244

240245
$ tox -e py3 -e py3-httpx
241246

test/functional/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Note that this file is special in that py.test will automatically import this file and gather
22
# its list of fixtures even if it is not directly imported into the corresponding test case.
3-
import pathlib
43

4+
import pathlib
55
import pytest
66

77
import ipfshttpclient

test/functional/test_pin.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import pathlib
1+
from pathlib import Path
22

33
import pytest
44

55
import ipfshttpclient.exceptions
66

77

88
class Resources:
9-
def __init__(self, client, source_folder: pathlib.Path) -> None:
9+
def __init__(self, client, source_folder: Path) -> None:
1010
self.msg = client.add_str("Mary had a little lamb")
1111
self.msg2 = client.add_str("Mary had a little alpaca")
12-
resp_add = client.add(source_folder, recursive=True)
12+
resp_add = client.add(str(source_folder), recursive=True)
1313
self.fake_dir_hashes = [el["Hash"] for el in resp_add if "Hash" in el]
1414
for resp in resp_add:
1515
if resp["Name"] == "fake_dir":

tools/ipfs/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# Local IPFS Server
3+
4+
`py-ipfs-httpclient` requires a live local server to run its
5+
functional tests.
6+
7+
## Installation
8+
9+
To install it, follow the [official instructions](https://docs.ipfs.io/install/command-line/),
10+
then finish with some [local configuration](configure.sh):
11+
12+
$ ./configure.sh
13+
14+
The above script is run once after installing.
15+
16+
## Running Tests
17+
18+
You can run unit tests without a live server; `pytest` will skip
19+
over the functional tests when our fixtures detect the server
20+
isn't running.
21+
22+
In a separate terminal, start IPFS with:
23+
24+
$ ./run.sh
25+
26+
Stop it with Ctrl+C. You can keep it running across multiple
27+
executions of the functional test suite.

tools/ipfs/configure.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Configures, but does not start, the IPFS daemon. Run once in your environment.
4+
#
5+
# Description of experimental features:
6+
# https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-filestore
7+
8+
set -e
9+
10+
ipfs init
11+
ipfs config --json Experimental.FilestoreEnabled true
12+
ipfs config --json Experimental.UrlstoreEnabled true

tools/ipfs/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Run the IPFS server. To stop it, press Ctrl+C.
4+
5+
ipfs daemon --enable-namesys-pubsub

0 commit comments

Comments
 (0)