From 53247ea50ea679dbb00718b8bc9f8547bcb26687 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Thu, 4 Apr 2024 09:27:47 +0900 Subject: [PATCH 1/3] Fix sample and bitcoinrpc provider --- .github/workflows/rust.yml | 9 ++++++++- bitcoin-rpc-provider/src/lib.rs | 10 +++++----- docker-compose.yml | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b23d41ed..29f3f349 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -93,5 +93,12 @@ jobs: run: ./scripts/wait_for_container.sh oracle-server - name: Wait for electrs to be ready run: ./scripts/wait_for_electrs.sh + - name: Create wallets + run: docker exec bitcoin-node /scripts/create_wallets.sh - name: Run test - run: cargo test -- --ignored sample + run: | + if ! cargo test -- --ignored sample; then + cat sample/dlc_sample_alice/.dlc/logs/logs.txt + cat sample/dlc_sample_bob/.dlc/logs/logs.txt + exit 1 + fi diff --git a/bitcoin-rpc-provider/src/lib.rs b/bitcoin-rpc-provider/src/lib.rs index 43b2e217..1b5db407 100644 --- a/bitcoin-rpc-provider/src/lib.rs +++ b/bitcoin-rpc-provider/src/lib.rs @@ -183,12 +183,12 @@ impl ContractSignerProvider for BitcoinCoreProvider { "getaddressesbylabel", &[Value::String(keys_id.to_lower_hex_string())], ) - .map_err(rpc_err_to_manager_err)?; + .unwrap_or_default(); if let Some(address) = label_map.keys().next() { - // we should only have one address per keys_id - // if not something has gone wrong - assert_eq!(label_map.len(), 1); + // note: importing a private key seem to generate three different addresses, we thus + // check that we have exactly three addresses for a single `keys_id`. + assert_eq!(label_map.len(), 3); let sk = self .client @@ -274,7 +274,7 @@ impl Wallet for BitcoinCoreProvider { .unwrap() .call::>( "getrawchangeaddress", - &[Value::Null, opt_into_json(Some(AddressType::Bech32))?], + &[opt_into_json(Some(AddressType::Bech32))?], ) .map_err(rpc_err_to_manager_err)? .assume_checked()) diff --git a/docker-compose.yml b/docker-compose.yml index 565fe9e5..a4301603 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: volumes: - bitcoind-data:/home/bitcoin/.bitcoin - ./testconfig/config:/config + - ./scripts:/scripts electrs: image: ghcr.io/cryptogarageinc/electrs:v0.4.12-bitcoin command: | From 52b7af32583fc0104d2c37e5ba3fab5287b43479 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Thu, 4 Apr 2024 09:28:09 +0900 Subject: [PATCH 2/3] Format --- bitcoin-rpc-provider/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bitcoin-rpc-provider/src/lib.rs b/bitcoin-rpc-provider/src/lib.rs index 1b5db407..9f44be59 100644 --- a/bitcoin-rpc-provider/src/lib.rs +++ b/bitcoin-rpc-provider/src/lib.rs @@ -391,11 +391,18 @@ impl Wallet for BitcoinCoreProvider { } fn unreserve_utxos(&self, outpoints: &[OutPoint]) -> Result<(), ManagerError> { - match self.client.lock().unwrap().unlock_unspent(outpoints).map_err(rpc_err_to_manager_err)? { + match self + .client + .lock() + .unwrap() + .unlock_unspent(outpoints) + .map_err(rpc_err_to_manager_err)? + { true => Ok(()), - false => Err(ManagerError::StorageError(format!("Failed to unlock utxos: {outpoints:?}"))) + false => Err(ManagerError::StorageError(format!( + "Failed to unlock utxos: {outpoints:?}" + ))), } - } } From 3b48432acb6de90b4fe09e57cecbad833bbff6b4 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Thu, 4 Apr 2024 09:28:23 +0900 Subject: [PATCH 3/3] CI fixes and udpates --- .github/workflows/rust.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 29f3f349..3d17132f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,9 @@ -on: [push, pull_request] +on: + push: + branches: + - master + - 'testci/**' + pull_request: name: Continuous integration @@ -8,7 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install clippy run: rustup component add clippy - name: Run clippy @@ -18,7 +23,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install clippy run: rustup component add clippy - name: Run clippy dlc @@ -32,7 +37,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build run: cargo build --verbose - name: Test @@ -44,13 +49,13 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/cache@v2 + - uses: actions/cache@v3 env: cache-name: test-cache with: path: target/debug/deps key: test-cache-${{ github.run_id }}-${{ github.run_number }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - id: set-matrix run: cargo test --no-run && echo "::set-output name=matrix::$(scripts/get_test_list.sh execution manager channel_execution)" integration_tests: @@ -62,15 +67,15 @@ jobs: matrix: tests: ${{ fromJson(needs.integration_tests_prepare.outputs.matrix) }} steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v3 env: cache-name: test-cache with: path: target/debug/deps key: test-cache-${{ github.run_id }}-${{ github.run_number }} - name: Start bitcoin node - run: docker-compose up -d + run: docker compose up -d - name: Wait for container to run run: ./scripts/wait_for_container.sh bitcoin-node - name: Wait for electrs to be ready @@ -84,11 +89,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v2 - - name: Set permission - run: docker-compose run oracle-db bash -c "chown postgres:postgres /certs/db.key && chgrp postgres /certs/db.key && chmod 600 /certs/db.key" + - uses: actions/checkout@v4 - name: Start environment - run: docker-compose --profile oracle up -d + run: docker compose --profile oracle up -d - name: Wait for container to run run: ./scripts/wait_for_container.sh oracle-server - name: Wait for electrs to be ready