Skip to content

Commit

Permalink
tests: run integration and regression tests on other platforms (#93)
Browse files Browse the repository at this point in the history
* tests: add script to download test dependencies from fallback mirrors

* tests: use the new download_deps script, run tests on macos

* ci: download proper artifact for macos

* chore: make download_deps script download everything to dir named `monero_c` when ran directly

* tests: await downloading deps

* tests download  proper monero_c version in prepareMoneroC

* tests: fix typos

* tests: add file data for more targets

* tests: print why retrieving tags failed

* chore: change mirror url endpoint from `monero_c` to `download_mirror`

* tests: use cached releases endpoint to prevent ratelimits

* ci: remove [email protected] dependency

* tests: fix macos dylib path

* feat!(monero.ts): make `createTransactionMultDest` optionally return `null`

* feat(monero.ts): make `Wallet_reconnectDevice` symbol optional

* tests: don't try to extract file if out already exists

* tests: remove unnecesary directory rm calls

* ci: set regression tests to use canary
  • Loading branch information
Im-Beast authored Dec 30, 2024
1 parent 2a38bf2 commit 85770ea
Show file tree
Hide file tree
Showing 11 changed files with 451 additions and 125 deletions.
67 changes: 64 additions & 3 deletions .github/workflows/full_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ jobs:
xcode-version: '15.4'
- name: install dependencies
run: |
brew install ccache unbound [email protected] zmq autoconf automake libtool && brew link [email protected]
brew install ccache unbound zmq autoconf automake libtool
- name: Patch sources
run: |
git config --global --add safe.directory '*'
Expand Down Expand Up @@ -404,7 +404,8 @@ jobs:
cd impls/monero.ts
deno run --unstable-ffi --allow-ffi checksum.ts
regression_check:
regression_tests_linux:
name: linux regression tests
strategy:
fail-fast: false
matrix:
Expand All @@ -431,7 +432,35 @@ jobs:
- name: Run regression tests
run: COIN="${{ matrix.coin }}" deno test -A tests/regression.test.ts

integration_check:
regression_tests_macos:
name: macos regression tests
strategy:
matrix:
coin: [monero, wownero]
needs: [
lib_macos
]
runs-on: macos-14
steps:
- uses: denoland/setup-deno@v2
with:
deno-version: canary

- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: actions/download-artifact@v4
with:
name: macos ${{ matrix.coin }}
path: release/${{ matrix.coin }}

- name: Run regression tests
run: COIN="${{ matrix.coin }}" deno test -A tests/regression.test.ts

integration_tests_linux:
name: linux integration tests
strategy:
matrix:
coin: [monero, wownero]
Expand Down Expand Up @@ -462,6 +491,38 @@ jobs:
SECRET_WALLET_RESTORE_HEIGHT: ${{ secrets.SECRET_WALLET_RESTORE_HEIGHT }}


integration_tests_macos:
name: macos integration tests
strategy:
matrix:
coin: [monero, wownero]
needs: [
lib_macos
]
runs-on: macos-14
steps:
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: actions/download-artifact@v4
with:
name: macos ${{ matrix.coin }}
path: release/${{ matrix.coin }}

- name: Run integration tests
run: COIN="${{ matrix.coin }}" deno test -A tests/integration.test.ts
env:
SECRET_WALLET_PASSWORD: ${{ secrets.SECRET_WALLET_PASSWORD }}
SECRET_WALLET_MNEMONIC: ${{ secrets.SECRET_WALLET_MNEMONIC }}
SECRET_WALLET_RESTORE_HEIGHT: ${{ secrets.SECRET_WALLET_RESTORE_HEIGHT }}


comment_pr:
name: comment on pr
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
release/
build/
tests/monero-cli
tests/wownero-cli
tests/libs
tests/dependencies
tests/wallets
12 changes: 5 additions & 7 deletions docs/Writerside/topics/macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ Building on linux has been tested on
<tab title="Native">
<code-block>
$ # install xcode 15.4 (or current latest)
$ brew install ccache unbound [email protected] zmq autoconf automake libtool
$ brew link [email protected]
$ brew install ccache unbound zmq autoconf automake libtool
</code-block>
</tab>
<tab title="Native (Rosetta2)">
<code-block>
$ # install xcode 15.4 (or current latest)
$ brew install ccache unbound [email protected] zmq autoconf automake libtool
$ brew link [email protected]
$ arch -x86_64 brew install ccache unbound [email protected] zmq autoconf automake libtool
$ arch -x86_64 brew link [email protected]
$ brew install ccache unbound zmq autoconf automake libtool
$ arch -x86_64 brew install ccache unbound zmq autoconf automake libtool
$ arch -x86_64 brew link
</code-block>
</tab>
<tab title="Linux">
Expand Down Expand Up @@ -83,4 +81,4 @@ $ ./build_single.sh monero aarch64-apple-darwin-11 -j$(nproc)

### Creating fat library

[Check cake_wallet solution](https://github.com/cake-tech/cake_wallet/blob/main/scripts/macos/build_monero_all.sh)
[Check cake_wallet solution](https://github.com/cake-tech/cake_wallet/blob/main/scripts/macos/build_monero_all.sh)
2 changes: 2 additions & 0 deletions impls/monero.ts/src/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,7 @@ export const moneroSymbols = {
],
},
MONERO_Wallet_createTransactionMultDest: {
optional: true,
nonblocking: true,
result: "pointer",
parameters: [
Expand Down Expand Up @@ -1956,6 +1957,7 @@ export const moneroSymbols = {
],
},
MONERO_Wallet_reconnectDevice: {
optional: true,
nonblocking: true,
result: "bool",
parameters: ["pointer"] as [
Expand Down
6 changes: 4 additions & 2 deletions impls/monero.ts/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ export class Wallet {
preferredInputs: string[] = [],
mixinCount = 0,
paymentId = "",
): Promise<PendingTransaction> {
const pendingTxPtr = await fns.Wallet_createTransactionMultDest(
): Promise<PendingTransaction | null> {
const pendingTxPtr = await fns.Wallet_createTransactionMultDest?.(
this.#ptr,
CString(destinationAddresses.join(SEPARATOR)),
C_SEPARATOR,
Expand All @@ -301,6 +301,8 @@ export class Wallet {
CString(preferredInputs.join(SEPARATOR)),
C_SEPARATOR,
);

if (!pendingTxPtr) return null;
return PendingTransaction.new(pendingTxPtr as PendingTransactionPtr);
}

Expand Down
17 changes: 3 additions & 14 deletions tests/compare.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import { assertEquals } from "jsr:@std/assert";

import {
loadMoneroDylib,
loadWowneroDylib,
moneroSymbols,
WalletManager,
wowneroSymbols,
} from "../impls/monero.ts/mod.ts";
import { WalletManager } from "../impls/monero.ts/mod.ts";
import { loadDylib } from "./utils.ts";

const coin = Deno.args[0] as "monero" | "wownero";
const version = Deno.args[1];
const walletInfo = JSON.parse(Deno.args[2]);

if (coin === "monero") {
const dylib = Deno.dlopen(`tests/libs/${version}/monero_libwallet2_api_c.so`, moneroSymbols);
loadMoneroDylib(dylib);
} else {
const dylib = Deno.dlopen(`tests/libs/${version}/wownero_libwallet2_api_c.so`, wowneroSymbols);
loadWowneroDylib(dylib);
}
loadDylib(coin, version);

const walletManager = await WalletManager.new();
const wallet = await walletManager.openWallet(walletInfo.path, walletInfo.password);
Expand Down
32 changes: 9 additions & 23 deletions tests/deno.lock

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

Loading

0 comments on commit 85770ea

Please sign in to comment.