Skip to content

Commit

Permalink
ci: fix docker (#153)
Browse files Browse the repository at this point in the history
## High Level Overview of Change

This PR fixes tests for both native-built servers and Docker containers,
and fixes CI.

### Context of Change

CI has been broken for months.

### Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] Tests (You added tests for code that already exists, or your new
feature included in this PR)

## Test Plan

CI passes (finally).
  • Loading branch information
mvadari authored Oct 25, 2023
1 parent 18f6a1e commit 85113fc
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 48 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/lint_type_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,36 @@ on:
pull_request:
workflow_dispatch:

env:
POETRY_VERSION: 1.4.2
PYTHON_VERSION: "3.8"

jobs:
lint-and-type-check:
name: Lint and type-check
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Load cached .local
id: cache-poetry
uses: actions/cache@v3
with:
path: /home/runner/.local
key: dotlocal-3.11-${{ hashFiles('.github/workflows') }}
key: dotlocal-${{ env.POETRY_VERSION }}

- name: Install poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org/ | python -
curl -sSL https://install.python-poetry.org/ | python - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Python + Retrieve Poetry dependencies from cache
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- name: Display Python version
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ on:
branches: [main]
pull_request:
paths-ignore:
- "docs/**"
- "scripts/**"
- "**.md"
- ".vscode/**"
workflow_dispatch:

env:
POETRY_VERSION: 1.4.2

jobs:
test:
name: Test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
# we have to use 3.7.1 to get around openssl issues
# TODO: add 3.7 once xrpl-py has been updated
python-version: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false

Expand All @@ -27,20 +28,22 @@ jobs:
uses: actions/checkout@v3

- name: Load cached .local
id: cache-poetry
uses: actions/cache@v3
with:
path: /home/runner/.local
key: dotlocal-${{ matrix.python-version }}-${{ hashFiles('.github/workflows') }}
key: dotlocal-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}

- name: Install poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org/ | python -
curl -sSL https://install.python-poetry.org/ | python - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Python + Retrieve Poetry dependencies from cache
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Display Python version
Expand All @@ -52,8 +55,8 @@ jobs:

- name: Pull images from docker
run: |
docker pull legleux/rippled-xbridge-test
docker pull legleux/xbridge_witnessd-test
docker pull rippleci/rippled:2.0.0-b4
docker pull rippleci/xbwd
- name: Run tests
id: runTests
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.formatting.provider": "black",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [[Unreleased]]

### Fixed

- Throw an error if a transaction fails instead of continuing

### Changed

- Switched to Docker containers with the latest versions of rippled and the witness server

## [0.3.3] - 2023-10-10

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ xbridge-cli server start-all --docker
xbridge-cli server list
xbridge-cli explorer
xbridge-cli bridge build --name=bridge --fund-locking
xbridge-cli fund locking_chain raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym
xbridge-cli bridge create-account --from-locking --bridge bridge --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi --amount 10
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to snyEJjY2Xi5Dxdh81Jy9Mj3AiYRQM
xbridge-cli fund locking_chain rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV
xbridge-cli bridge create-account --from-locking --bridge bridge --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV --amount 100
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to sEdTSHsMvrzomUN9uYgVEd64CEQqwo2
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ xbridge-cli server list
xbridge-cli explorer
xbridge-cli bridge build --name=bridge --fund-locking
xbridge-cli fund locking_chain rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV
xbridge-cli bridge create-account --from-locking --bridge bridge --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV --amount 10
xbridge-cli bridge create-account --from-locking --bridge bridge --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV --amount 100
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to sEdTSHsMvrzomUN9uYgVEd64CEQqwo2
6 changes: 3 additions & 3 deletions scripts/tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ xbridge-cli server list
read -p "Pausing... (hit enter to continue)"
xbridge-cli explorer
xbridge-cli bridge build --name=bridge --fund-locking
xbridge-cli fund locking_chain raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym
xbridge-cli bridge create-account --from-locking --bridge bridge --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi --amount 10
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to snyEJjY2Xi5Dxdh81Jy9Mj3AiYRQM --tutorial
xbridge-cli fund locking_chain rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV
xbridge-cli bridge create-account --from-locking --bridge bridge --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV --amount 100
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --tutorial
4 changes: 2 additions & 2 deletions tests/bridge/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_bridge_build(self):
],
"xchain_currencies": [{"currency": "XRP"}, {"currency": "XRP"}],
"signature_reward": "100",
"create_account_amounts": ["5000000", "5000000"],
"create_account_amounts": ["10000000", "10000000"],
}

assert config_result["bridges"][0] == expected_result
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_bridge_prod_build_xrp(self):
],
"xchain_currencies": [{"currency": "XRP"}, {"currency": "XRP"}],
"signature_reward": "100",
"create_account_amounts": ["5000000", "5000000"],
"create_account_amounts": ["10000000", "10000000"],
}

assert config_result["bridges"][0] == expected_result
Expand Down
4 changes: 2 additions & 2 deletions tests/bridge/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_bridge_transfer(self):
"--to",
receive_wallet.classic_address,
"--amount",
"10",
"100",
"--verbose",
],
)
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_bridge_transfer_prod(self):
"--to",
receive_wallet.classic_address,
"--amount",
"10",
"100",
"--verbose",
],
)
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def _base_fixture():
assert stop_result.exit_code == 0, stop_result.output


@pytest.fixture(scope="class")
def basic():
_reset_cli_config()
_create_config_files()


@pytest.fixture(scope="class")
def runner():
with _base_fixture() as cli_runner:
Expand Down
2 changes: 2 additions & 0 deletions tests/server/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest
from click.testing import CliRunner

from xbridge_cli.main import main


@pytest.mark.usefixtures("basic")
class TestBasicCreation:
def test_start_stop(self):
runner = CliRunner()
Expand Down
4 changes: 2 additions & 2 deletions xbridge_cli/bridge/transfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""CLI command for setting up a bridge."""

from typing import Any, Dict, cast
from typing import Any, Dict, Union, cast

import click
from xrpl.clients import JsonRpcClient
Expand Down Expand Up @@ -109,7 +109,7 @@ def _submit_tx(
def send_transfer(
bridge: str,
from_locking: bool,
amount: int | float,
amount: Union[int, float],
from_account: str,
to_account: str,
close_ledgers: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion xbridge_cli/misc/fund.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
help="Whether or not to print more verbose information.",
)
def fund_account(
chain: str, accounts: List[str], amount: int = 1000, verbose: bool = False
chain: str, accounts: List[str], amount: int = 10000, verbose: bool = False
) -> None:
"""
Of the form `xbridge-cli fund CHAIN ACCOUNT1 [ACCOUNT2 ...].
Expand Down
35 changes: 21 additions & 14 deletions xbridge_cli/server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ services:

locking_chain:
container_name: locking_chain
image: legleux/rippled-xbridge-test
command: "--conf /etc/opt/ripple/rippled.cfg -a"
image: rippleci/rippled:2.0.0-b4
platform: linux/amd64
command: "/opt/ripple/bin/rippled --conf /etc/opt/ripple/rippled.cfg -a"
volumes:
- ${XCHAIN_CONFIG_DIR}/locking_chain:/etc/opt/ripple/
ports:
Expand All @@ -17,8 +18,9 @@ services:

issuing_chain:
container_name: issuing_chain
image: legleux/rippled-xbridge-test
command: "--conf /etc/opt/ripple/rippled.cfg -a"
image: rippleci/rippled:2.0.0-b4
platform: linux/amd64
command: "/opt/ripple/bin/rippled --conf /etc/opt/ripple/rippled.cfg -a"
volumes:
- ${XCHAIN_CONFIG_DIR}/issuing_chain:/etc/opt/ripple/
ports:
Expand All @@ -31,8 +33,9 @@ services:

witness0:
container_name: witness0
image: legleux/xbridge_witnessd-test
command: "/opt/witness/witness.json"
image: rippleci/xbwd
platform: linux/amd64
command: "/opt/xbwd/bin/xbridge_witnessd --conf /opt/witness/witness.json"
volumes:
- ${XCHAIN_CONFIG_DIR}/witness0:/opt/witness/
ports:
Expand All @@ -43,8 +46,9 @@ services:

witness1:
container_name: witness1
image: legleux/xbridge_witnessd-test
command: "/opt/witness/witness.json"
image: rippleci/xbwd
platform: linux/amd64
command: "/opt/xbwd/bin/xbridge_witnessd --conf /opt/witness/witness.json"
volumes:
- ${XCHAIN_CONFIG_DIR}/witness1:/opt/witness/
ports:
Expand All @@ -55,8 +59,9 @@ services:

witness2:
container_name: witness2
image: legleux/xbridge_witnessd-test
command: "/opt/witness/witness.json"
image: rippleci/xbwd
platform: linux/amd64
command: "/opt/xbwd/bin/xbridge_witnessd --conf /opt/witness/witness.json"
volumes:
- ${XCHAIN_CONFIG_DIR}/witness2:/opt/witness/
ports:
Expand All @@ -67,8 +72,9 @@ services:

witness3:
container_name: witness3
image: legleux/xbridge_witnessd-test
command: "/opt/witness/witness.json"
image: rippleci/xbwd
platform: linux/amd64
command: "/opt/xbwd/bin/xbridge_witnessd --conf /opt/witness/witness.json"
volumes:
- ${XCHAIN_CONFIG_DIR}/witness3:/opt/witness/
ports:
Expand All @@ -79,8 +85,9 @@ services:

witness4:
container_name: witness4
image: legleux/xbridge_witnessd-test
command: "/opt/witness/witness.json"
image: rippleci/xbwd
platform: linux/amd64
command: "/opt/xbwd/bin/xbridge_witnessd --conf /opt/witness/witness.json"
volumes:
- ${XCHAIN_CONFIG_DIR}/witness4:/opt/witness/
ports:
Expand Down
2 changes: 1 addition & 1 deletion xbridge_cli/server/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def request_server(

if isinstance(server, ChainConfig): # is a rippled node
if server.is_docker():
to_run = ["docker", "exec", name, "/opt/rippled/bin/rippled"]
to_run = ["docker", "exec", name, "/opt/ripple/bin/rippled"]
else:
to_run = [server.rippled, "--conf", server.config]
to_run.extend([command, *args])
Expand Down
4 changes: 3 additions & 1 deletion xbridge_cli/server/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def start_server(
config_json = json.load(f)
is_rippled = False
if check_server_exists(name, config):
raise XBridgeCLIException("Server already running with that name or config.")
raise XBridgeCLIException(
f"Server already running with the name {name} or config {config}."
)

server_type = "rippled" if is_rippled else "witness"
if verbose:
Expand Down
Loading

0 comments on commit 85113fc

Please sign in to comment.