Skip to content

Commit

Permalink
tests: use the new download_deps script, run tests on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Im-Beast committed Dec 7, 2024
1 parent 093c0ab commit 7d424a9
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 122 deletions.
65 changes: 63 additions & 2 deletions .github/workflows/full_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ jobs:
cd impls/monero.ts
deno run --unstable-ffi --allow-ffi checksum.ts
regression_check:
regression_tests_linux:
name: linux regression tests
strategy:
matrix:
coin: [monero, wownero]
Expand All @@ -611,7 +612,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: v2.x

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

- uses: actions/download-artifact@v4
with:
name: linux ${{ 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 @@ -642,6 +671,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: linux ${{ 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
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
46 changes: 12 additions & 34 deletions tests/deno.lock

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

28 changes: 6 additions & 22 deletions tests/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import {
CoinsInfo,
type Dylib,
loadMoneroDylib,
loadWowneroDylib,
moneroSymbols,
Wallet,
WalletManager,
wowneroSymbols,
} from "../impls/monero.ts/mod.ts";
import { CoinsInfo, Wallet, WalletManager } from "../impls/monero.ts/mod.ts";

import { assert, assertEquals } from "jsr:@std/assert";
import { $, downloadCli, getMoneroC } from "./utils.ts";
import { $, loadDylib, prepareCli, prepareMoneroC } from "./utils.ts";

const coin = Deno.env.get("COIN");
if (coin !== "monero" && coin !== "wownero") {
Expand Down Expand Up @@ -53,7 +44,7 @@ const DESTINATION_ADDRESS = coin === "monero" ? MONERO_DESTINATION_ADDRESS : WOW

const BILLION = 10n ** 9n;

await getMoneroC(coin, "next");
await prepareMoneroC(coin, "next");

interface WalletInfo {
name: string;
Expand All @@ -74,14 +65,7 @@ async function clearWallets() {
await Deno.mkdir("tests/wallets/");
}

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

Deno.test("0001-polyseed.patch", async (t) => {
const WALLETS: Record<"monero" | "wownero", WalletInfo[]> = {
Expand Down Expand Up @@ -487,7 +471,7 @@ Deno.test("0004-coin-control.patch", {

Deno.test("0009-Add-recoverDeterministicWalletFromSpendKey.patch", async () => {
await Promise.all([
downloadCli(coin),
prepareCli(coin),
clearWallets(),
]);

Expand All @@ -498,7 +482,7 @@ Deno.test("0009-Add-recoverDeterministicWalletFromSpendKey.patch", async () => {

await Deno.remove("./tests/wallets/stoat");

const cliPath = `./tests/${coin}-cli/${coin}-wallet-cli`;
const cliPath = `./tests/dependencies/${coin}-cli/${coin}-wallet-cli`;
const moneroCliSeed = (await $.raw`${cliPath} --wallet-file ./tests/wallets/stoat --password gornostay --command seed`
.stdinText(`gornostay\n`)
.lines()).slice(-3).join(" ");
Expand Down
6 changes: 3 additions & 3 deletions tests/regression.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $, createWalletViaCli, downloadCli, getMoneroC, getMoneroCTags } from "./utils.ts";
import { $, createWalletViaCli, getMoneroCTags, prepareCli, prepareMoneroC } from "./utils.ts";

const coin = Deno.env.get("COIN");
if (coin !== "monero" && coin !== "wownero") {
Expand All @@ -11,7 +11,7 @@ Deno.test(`Regression tests (${coin})`, async (t) => {

const tags = await getMoneroCTags();
const latestTag = tags[0];
await Promise.all([getMoneroC(coin, "next"), await getMoneroC(coin, latestTag), downloadCli(coin)]);
await Promise.all([prepareMoneroC(coin, "next"), await prepareMoneroC(coin, latestTag), prepareCli(coin)]);

await t.step("Simple (next, latest, next)", async () => {
const walletInfo = await createWalletViaCli(coin, "dog", "sobaka");
Expand All @@ -27,7 +27,7 @@ Deno.test(`Regression tests (${coin})`, async (t) => {
const walletInfo = await createWalletViaCli(coin, "cat", "koshka");

for (const version of tags.toReversed()) {
if (version !== "next" && version !== tags[0]) await getMoneroC(coin, version);
if (version !== "next" && version !== tags[0]) await prepareMoneroC(coin, version);
await $`deno run -A ./tests/compare.ts ${coin} ${version} ${JSON.stringify(walletInfo)}`;
}

Expand Down
Loading

0 comments on commit 7d424a9

Please sign in to comment.