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

Test against multiple versions of monero #75

Merged
merged 5 commits into from
Aug 2, 2022
Merged
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
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on: [push, pull_request]

name: Build

jobs:
check:
strategy:
matrix:
rust: [
1.56.1,
stable,
]
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
32 changes: 32 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on: [push, pull_request]

name: Format

jobs:
fmt:
name: Rust format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

mdtomlfmt:
name: Generic format (md,toml)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Run dprint
run: |
curl -fsSL https://dprint.dev/install.sh | sh
/home/runner/.dprint/bin/dprint check
88 changes: 0 additions & 88 deletions .github/workflows/main.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on: [push, pull_request]

name: Test

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
monero: [ 0.17.3.0, 0.17.3.2, 0.18.0.0 ]

services:
monerod:
image: ghcr.io/farcaster-project/containers/monerod:${{ matrix.monero }}
env:
NETWORK: regtest
MONEROD_RPC_PORT: 18081
MONEROD_ZMQ_PORT: 18082
OFFLINE: --offline
DIFFICULTY: 1
ports:
- 18081:18081
- 18082:18082
monero-wallet-rpc:
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:${{ matrix.monero }}
env:
MONERO_DAEMON_ADDRESS: monerod:18081
MONERO_DAEMON_HOST: monerod:18081
WALLET_RPC_PORT: 18083
ports:
- 18083:18083

steps:
- uses: actions/checkout@v3

- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Cargo test
uses: actions-rs/cargo@v1
with:
command: test
2 changes: 1 addition & 1 deletion tests/clients_tests/basic_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn run() {
// where errors could happen.
// Note that the wallets created in this step are created "from scratch", i.e.
// they are not created from known spend/view keys.
let expected_wallet_version = (1, 25);
let expected_wallet_version = (1, 22..26);
helpers::wallet::get_version_assert_version(&wallet, expected_wallet_version).await;

let (wallet_with_pwd, wallet_with_no_pwd, wallet_with_empty_pwd) = tokio::join!(
Expand Down
2 changes: 0 additions & 2 deletions tests/clients_tests/helpers/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ fn test_get_block_header_assert_block_header(
difficulty: u64,
hash: BlockHash,
height: u64,
major_version: u64,
minor_version: u64,
nonce: u32,
num_txes: u64,
orphan_status: bool,
Expand Down
9 changes: 7 additions & 2 deletions tests/clients_tests/helpers/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::ops::Range;

use monero::{
cryptonote::subaddress::Index, util::address::PaymentId, Address, Amount, Hash, PrivateKey,
Expand All @@ -21,9 +22,13 @@ fn get_random_name() -> String {
.collect()
}

pub async fn get_version_assert_version(wallet: &WalletClient, expected_version: (u16, u16)) {
pub async fn get_version_assert_version(
wallet: &WalletClient,
expected_version: (u16, Range<u16>),
) {
let version = wallet.get_version().await.unwrap();
assert_eq!(version, expected_version);
assert_eq!(version.0, expected_version.0);
assert!(expected_version.1.contains(&version.1));
}

async fn create_wallet(
Expand Down
1 change: 1 addition & 0 deletions tests/clients_tests/non_empty_blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub async fn run() {
difficulty: 1,
hash: last_added_block_hash,
height: regtest.get_block_count().await.unwrap().get() - 1,
// `*_version` are not tested inside the test functions below because they varies
major_version: 16,
minor_version: 16,
nonce: 0,
Expand Down
1 change: 1 addition & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
DIFFICULTY: 1
ports:
- 18081:18081

monero-wallet-rpc:
image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:0.18.0.0
environment:
Expand Down