Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Statemachine #4

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on: [push, pull_request]

jobs:
tests:
strategy:
matrix:
toolchain:
- 1.43
- nightly
os:
- ubuntu-latest
- macOS-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust ${{ matrix.toolchain }} toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: minimal
- name: Build on Rust ${{ matrix.toolchain }}
run: cargo build --verbose --color always
- name: Test on Rust ${{ matrix.toolchain }}
run: cargo test --verbose --color always --all-features
- name: Functional tests
if: matrix.os == 'ubuntu-latest' && matrix.toolchain == 'nightly'
run: ./contrib/ci-functional-tests.sh
env:
RUST_BACKTRACE: 1

rustfmt_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
override: true
- run: cargo fmt -- --check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
target/
__pycache__
93 changes: 55 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
revault_tx = { version = "0.3.0", features = ["use-serde"] }
revault_net = { version = "0.1.0", branch = "update_tx" }
revault_net = "0.1.0"

# Don't reinvent the wheel
dirs = "3.0"
Expand All @@ -31,4 +31,7 @@ rusqlite = { version = "0.25.3", features = ["bundled", "unlock_notify"] }

# We want to have a backtrace on panic, and the stdlib doesn't have a programmatic
# interface yet to work with our custom panic hook.
backtrace = "0.3.60"
backtrace = "0.3"

[dev-dependencies]
fastrand = "1.4.0"
22 changes: 22 additions & 0 deletions contrib/ci-functional-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -xe

# Do the linter check early for quicker feedback
pip install black
black --check tests/

# Build the miradord binary
cargo build --release

# Download the bitcoind binary
BITCOIND_VERSION="22.0"
DIR_NAME="bitcoin-$BITCOIND_VERSION"
ARCHIVE_NAME="$DIR_NAME.tar.gz"
curl https://bitcoincore.org/bin/bitcoin-core-$BITCOIND_VERSION/bitcoin-$BITCOIND_VERSION-x86_64-linux-gnu.tar.gz -o $ARCHIVE_NAME
tar -xzf $ARCHIVE_NAME
sudo mv $DIR_NAME/bin/bitcoind /usr/local/bin/

# Run the functional tests
python3 -m venv venv
. venv/bin/activate
pip install -r tests/requirements.txt
VERBOSE=1 LOG_LEVEL=debug TIMEOUT=60 pytest -n2 -vvv --log-cli-level=DEBUG tests/
23 changes: 23 additions & 0 deletions contrib/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Assumes:
# - you have a postgres DB set up with credentials revault:revault
# - you have functional tests dependencies installed (likely you are in a venv)

set -ex

if [ -z "$JOBS" ]; then JOBS=1; fi

if ! command -v grcov &>/dev/null; then
cargo install grcov
fi

cargo clean

rm -f "revaultd_coverage_*.profraw"
LLVM_PROFILE_FILE="miradord_coverage_%m.profraw" RUSTFLAGS="-Zinstrument-coverage" RUSTDOCFLAGS="$RUSTFLAGS -Z unstable-options --persist-doctests target/debug/doctestbins" cargo +nightly build --all-features
LLVM_PROFILE_FILE="miradord_coverage_%m.profraw" RUSTFLAGS="-Zinstrument-coverage" RUSTDOCFLAGS="$RUSTFLAGS -Z unstable-options --persist-doctests target/debug/doctestbins" cargo +nightly test --all-features --jobs $JOBS
pytest -n $JOBS

grcov . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --llvm -o ./target/grcov/
firefox target/grcov/index.html

set +ex
Loading