xmr-btc-swap/.github/workflows/ci.yml
Daniel Karzel c976358c37
Multiple swaps with the same peer
- Swap-id is exchanged during execution setup. CLI (Bob) sends the swap-id to be used in his first message.
- Transfer poof and encryption signature messages include the swap-id so it can be properly associated with the correct swap.
- ASB: Encryption signatures are associated with swaps by swap-id, not peer-id.
- ASB: Transfer proofs are still associated to peer-ids (because they have to be sent to the respective peer), but the ASB can buffer multiple
- CLI: Incoming transfer proofs are checked for matching swap-id. If a transfer proof with a different swap-id than the current executing swap is received it will be ignored. We can change this to saving into the database.

Includes concurrent swap tests with the same Bob.

- One test that pauses and starts an additional swap after the transfer proof was received. Results in both swaps being redeemed after resuming the first swap.
- One test that pauses and starts an additional swap before the transfer proof is sent (just after BTC locked). Results in the second swap redeeming and the first swap being refunded (because the transfer proof on Bob's side is lost). Once we store transfer proofs that we receive during executing a different swap into the database both swaps should redeem.

Note that the monero harness was adapted to allow creating wallets with multiple outputs, which is needed for Alice.
2021-04-13 18:16:19 +10:00

136 lines
4.0 KiB
YAML

name: CI
on:
pull_request: # Need to run on pull-requests, otherwise PRs from forks don't run
push:
branches:
- 'staging' # Bors uses this branch
- 'trying' # Bors uses this branch
- 'master' # Always build head of master for the badge in the README
jobs:
static_analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1.2.0
id: cache
- name: Install tomlfmt
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install cargo-tomlfmt
- name: Check Cargo.toml formatting
run: |
cargo tomlfmt -d -p Cargo.toml
cargo tomlfmt -d -p monero-harness/Cargo.toml
cargo tomlfmt -d -p swap/Cargo.toml
- name: Check code formatting
run: cargo fmt --all -- --check
- name: Check markdown formatting
uses: dprint/check@v1.2
- name: Run clippy with default features
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Run clippy with all features enabled
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
build:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1.2.0
- name: Install compiler for armhf arch
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Build binary
run: |
cargo build -p swap --target ${{ matrix.target }}
- name: Upload swap binary
uses: actions/upload-artifact@v2-preview
with:
name: swap-${{ matrix.target }}
path: target/${{ matrix.target }}/debug/swap
- name: Upload asb binary
uses: actions/upload-artifact@v2-preview
with:
name: asb-${{ matrix.target }}
path: target/${{ matrix.target }}/debug/asb
test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1.2.0
- name: Build tests
run: cargo build --tests --workspace --all-features
- name: Run monero-harness tests
if: matrix.os == 'ubuntu-latest'
run: cargo test --package monero-harness --all-features
- name: Run library tests for swap
run: cargo test --package swap --lib --all-features
docker_tests:
strategy:
matrix:
test_name: [
happy_path,
happy_path_restart_bob_after_xmr_locked,
happy_path_restart_bob_before_xmr_locked,
happy_path_restart_alice_after_xmr_locked,
bob_refunds_using_cancel_and_refund_command,
bob_refunds_using_cancel_and_refund_command_timelock_not_expired,
bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force,
punish,
alice_punishes_after_restart_punish_timelock_expired,
alice_refunds_after_restart_bob_refunded,
ensure_same_swap_id,
concurrent_bobs_after_xmr_lock_proof_sent,
concurrent_bobs_before_xmr_lock_proof_sent
]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1.2.0
- name: Run test ${{ matrix.test_name }}
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} ""
env:
MONERO_ADDITIONAL_SLEEP_PERIOD: 60000