Compare commits
4 Commits
df172af1f9
...
61d8a94402
Author | SHA1 | Date | |
---|---|---|---|
61d8a94402 | |||
644033e70c | |||
191bc1c3be | |||
65c6274839 |
|
@ -1,16 +1,21 @@
|
|||
FROM ubuntu:focal
|
||||
FROM ubuntu:jammy
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -yq software-properties-common
|
||||
|
||||
RUN apt-add-repository ppa:purplei2p/i2pd
|
||||
RUN apt-get update
|
||||
RUN apt-add-repository ppa:purplei2p/i2pd && apt-get update -qq
|
||||
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
python3-dev python3-pip python3.9 python3.9-dev python3.9-venv sudo i2pd
|
||||
python3-dev python3-pip python-is-python3 python3.11-dev python3.11-venv
|
||||
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends sudo i2pd
|
||||
|
||||
RUN echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
|
||||
RUN python3.9 -m pip install setuptools wheel
|
||||
RUN python3.9 -m pip install --upgrade pip tox virtualenv
|
||||
RUN pip install setuptools wheel
|
||||
RUN pip install --upgrade pip tox virtualenv
|
||||
|
||||
ADD . .
|
||||
|
||||
CMD .buildbot/ubuntu-jammy/test.sh
|
||||
|
|
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
.git
|
||||
.tox
|
||||
dist
|
20
.github/workflows/test.yaml
vendored
Normal file
20
.github/workflows/test.yaml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: Testing
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
default:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
python3-dev python3-pip python3-venv python-is-python3
|
||||
pip install setuptools wheel
|
||||
pip install --upgrade pip tox virtualenv
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Quick lint
|
||||
run: tox -e lint-basic
|
||||
- name: Run tests
|
||||
run: tox
|
44
.github/workflows/test.yml
vendored
44
.github/workflows/test.yml
vendored
|
@ -1,44 +0,0 @@
|
|||
name: Blind Test
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
default:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
python-version: [3.8]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
python-version: 3.9
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install python dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install wheel
|
||||
pip install bandit flake8 pylint
|
||||
pip install -r requirements.txt
|
||||
python setup.py install
|
||||
- name: Lint
|
||||
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 minode --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
flake8 minode --count --statistics
|
||||
pylint minode --exit-zero --rcfile=tox.ini
|
||||
bandit -r --exit-zero -x tests minode
|
||||
- name: Test
|
||||
run: |
|
||||
export PYTHONWARNINGS=all
|
||||
coverage run -a -m tests
|
||||
- name: Summary
|
||||
run: coverage report
|
|
@ -266,11 +266,11 @@ class Connection(threading.Thread):
|
|||
if len(shared.node_pool) > 10:
|
||||
addr.update({
|
||||
structure.NetAddr(1, a[0], a[1])
|
||||
for a in random.sample(shared.node_pool, 10)})
|
||||
for a in random.sample(tuple(shared.node_pool), 10)})
|
||||
if len(shared.unchecked_node_pool) > 10:
|
||||
addr.update({
|
||||
structure.NetAddr(1, a[0], a[1])
|
||||
for a in random.sample(shared.unchecked_node_pool, 10)})
|
||||
for a in random.sample(tuple(shared.unchecked_node_pool), 10)})
|
||||
if len(addr) != 0:
|
||||
self.send_queue.put(message.Addr(addr))
|
||||
|
||||
|
@ -284,7 +284,7 @@ class Connection(threading.Thread):
|
|||
# We limit size of inv messaged to 10000 entries
|
||||
# because they might time out
|
||||
# in very slow networks (I2P)
|
||||
pack = random.sample(to_send, 10000)
|
||||
pack = random.sample(tuple(to_send), 10000)
|
||||
self.send_queue.put(message.Inv(pack))
|
||||
to_send.difference_update(pack)
|
||||
else:
|
||||
|
@ -456,7 +456,7 @@ class Connection(threading.Thread):
|
|||
logging.info(
|
||||
'Queued %s vectors to get', len(self.vectors_to_get))
|
||||
if len(self.vectors_to_get) > 64:
|
||||
pack = random.sample(self.vectors_to_get, 64)
|
||||
pack = random.sample(tuple(self.vectors_to_get), 64)
|
||||
self.send_queue.put(message.GetData(pack))
|
||||
self.vectors_requested.update({
|
||||
vector: time.time() for vector in pack
|
||||
|
@ -486,7 +486,7 @@ class Connection(threading.Thread):
|
|||
logging.info(
|
||||
'Preparing to send %s objects', len(self.vectors_to_send))
|
||||
if len(self.vectors_to_send) > 16:
|
||||
to_send = random.sample(self.vectors_to_send, 16)
|
||||
to_send = random.sample(tuple(self.vectors_to_send), 16)
|
||||
self.vectors_to_send.difference_update(to_send)
|
||||
else:
|
||||
to_send = self.vectors_to_send.copy()
|
||||
|
|
|
@ -98,24 +98,26 @@ class Manager(threading.Thread):
|
|||
if shared.ip_enabled:
|
||||
if len(shared.unchecked_node_pool) > 16:
|
||||
to_connect.update(random.sample(
|
||||
shared.unchecked_node_pool, 16))
|
||||
tuple(shared.unchecked_node_pool), 16))
|
||||
else:
|
||||
to_connect.update(shared.unchecked_node_pool)
|
||||
shared.unchecked_node_pool.difference_update(to_connect)
|
||||
if len(shared.node_pool) > 8:
|
||||
to_connect.update(random.sample(shared.node_pool, 8))
|
||||
to_connect.update(random.sample(
|
||||
tuple(shared.node_pool), 8))
|
||||
else:
|
||||
to_connect.update(shared.node_pool)
|
||||
|
||||
if shared.i2p_enabled:
|
||||
if len(shared.i2p_unchecked_node_pool) > 16:
|
||||
to_connect.update(
|
||||
random.sample(shared.i2p_unchecked_node_pool, 16))
|
||||
to_connect.update(random.sample(
|
||||
tuple(shared.i2p_unchecked_node_pool), 16))
|
||||
else:
|
||||
to_connect.update(shared.i2p_unchecked_node_pool)
|
||||
shared.i2p_unchecked_node_pool.difference_update(to_connect)
|
||||
if len(shared.i2p_node_pool) > 8:
|
||||
to_connect.update(random.sample(shared.i2p_node_pool, 8))
|
||||
to_connect.update(random.sample(
|
||||
tuple(shared.i2p_node_pool), 8))
|
||||
else:
|
||||
to_connect.update(shared.i2p_node_pool)
|
||||
|
||||
|
@ -214,17 +216,18 @@ class Manager(threading.Thread):
|
|||
@staticmethod
|
||||
def pickle_nodes():
|
||||
if len(shared.node_pool) > 10000:
|
||||
shared.node_pool = set(random.sample(shared.node_pool, 10000))
|
||||
shared.node_pool = set(random.sample(
|
||||
tuple(shared.node_pool), 10000))
|
||||
if len(shared.unchecked_node_pool) > 1000:
|
||||
shared.unchecked_node_pool = set(
|
||||
random.sample(shared.unchecked_node_pool, 1000))
|
||||
shared.unchecked_node_pool = set(random.sample(
|
||||
tuple(shared.unchecked_node_pool), 1000))
|
||||
|
||||
if len(shared.i2p_node_pool) > 1000:
|
||||
shared.i2p_node_pool = set(
|
||||
random.sample(shared.i2p_node_pool, 1000))
|
||||
shared.i2p_node_pool = set(random.sample(
|
||||
tuple(shared.i2p_node_pool), 1000))
|
||||
if len(shared.i2p_unchecked_node_pool) > 100:
|
||||
shared.i2p_unchecked_node_pool = set(
|
||||
random.sample(shared.i2p_unchecked_node_pool, 100))
|
||||
shared.i2p_unchecked_node_pool = set(random.sample(
|
||||
tuple(shared.i2p_unchecked_node_pool), 100))
|
||||
|
||||
try:
|
||||
with open(
|
||||
|
|
Loading…
Reference in New Issue
Block a user