From 8627f1d904ff51c43d2183666834a6dcd3ff9598 Mon Sep 17 00:00:00 2001 From: Im-Beast Date: Tue, 15 Oct 2024 15:20:09 +0200 Subject: [PATCH] ci: test wownero regressions as well --- .github/workflows/full_check.yaml | 13 ++---- tests/regression.test.ts | 17 +++++--- tests/utils.ts | 67 ++++++++++++++++++++----------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/.github/workflows/full_check.yaml b/.github/workflows/full_check.yaml index fa4d9f1e..eaec8600 100644 --- a/.github/workflows/full_check.yaml +++ b/.github/workflows/full_check.yaml @@ -589,17 +589,12 @@ jobs: regression_check: strategy: matrix: - coin: [monero] + coin: [monero, wownero] needs: [ lib_linux ] runs-on: ubuntu-24.04 steps: - - name: Install dependencies - run: | - sudo apt update - sudo apt install -y build-essential pkg-config autoconf libtool ccache make cmake gcc g++ git curl lbzip2 gperf gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gcc-mingw-w64-i686 g++-mingw-w64-i686 wget xz-utils - - uses: denoland/setup-deno@v2 with: deno-version: v2.x @@ -611,11 +606,11 @@ jobs: - uses: actions/download-artifact@v4 with: - name: linux monero - path: release/monero + name: linux ${{ matrix.coin }} + path: release/${{ matrix.coin }} - name: Run regression tests - run: deno test -A tests/ + run: COIN="${{ matrix.coin }}" deno test -A tests/ comment_pr: name: comment on pr diff --git a/tests/regression.test.ts b/tests/regression.test.ts index 677f9b69..2a0d3697 100755 --- a/tests/regression.test.ts +++ b/tests/regression.test.ts @@ -1,15 +1,20 @@ -import { $, createWalletViaCli, downloadMoneroCli, getMoneroC, getMoneroCTags } from "./utils.ts"; +import { $, createWalletViaCli, downloadCli, getMoneroC, getMoneroCTags } from "./utils.ts"; -Deno.test("Regression tests", async (t) => { +const coin = Deno.env.get("COIN"); +if (coin !== "monero" && coin !== "wownero") { + throw new Error("COIN env var invalid or missing"); +} + +Deno.test(`Regression tests (${coin})`, async (t) => { await Deno.remove("./tests/wallets", { recursive: true }).catch(() => {}); await Deno.mkdir("./tests/wallets", { recursive: true }); const tags = await getMoneroCTags(); const latestTag = tags[0]; - await Promise.all([getMoneroC("next"), await getMoneroC(latestTag), downloadMoneroCli()]); + await Promise.all([getMoneroC(coin, "next"), await getMoneroC(coin, latestTag), downloadCli(coin)]); await t.step("Simple (next, latest, next)", async () => { - const walletInfo = await createWalletViaCli("dog", "sobaka"); + const walletInfo = await createWalletViaCli(coin, "dog", "sobaka"); for (const version of ["next", latestTag, "next"]) { await $`deno run -A ./tests/compare.ts ${version} ${JSON.stringify(walletInfo)}`; @@ -19,10 +24,10 @@ Deno.test("Regression tests", async (t) => { await t.step("All releases sequentially (all tags in the release order, next)", async () => { tags.unshift("next"); - const walletInfo = await createWalletViaCli("cat", "koshka"); + const walletInfo = await createWalletViaCli(coin, "cat", "koshka"); for (const version of tags.toReversed()) { - if (version !== "next" && version !== tags[0]) await getMoneroC(version); + if (version !== "next" && version !== tags[0]) await getMoneroC(coin, version); await $`deno run -A ./tests/compare.ts ${version} ${JSON.stringify(walletInfo)}`; } diff --git a/tests/utils.ts b/tests/utils.ts index 78584a73..ed82a38b 100755 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -8,15 +8,34 @@ export const $ = build$({ .stderr("inherit"), }); +type Coin = "monero" | "wownero"; + export async function downloadMoneroCli() { - const MONERO_CLI_VERSION = "monero-linux-x64-v0.18.3.4"; - const MONERO_WALLET_CLI = - `https://downloads.getmonero.org/cli/${MONERO_CLI_VERSION}.tar.bz2`; + const MONERO_CLI_FILE_NAME = "monero-linux-x64-v0.18.3.4"; + const MONERO_WALLET_CLI_URL = `https://downloads.getmonero.org/cli/${MONERO_CLI_FILE_NAME}.tar.bz2`; + + await $`wget ${MONERO_WALLET_CLI_URL}`; + await $ + .raw`tar -xvf ${MONERO_CLI_FILE_NAME}.tar.bz2 --one-top-level=monero-cli --strip-components=1 -C tests`; + await $.raw`rm ${MONERO_CLI_FILE_NAME}.tar.bz2`; +} + +export async function downloadWowneroCli() { + const WOWNERO_CLI_FILE_NAME = "wownero-x86_64-linux-gnu-59db3fe8d"; + const WOWNERO_WALLET_CLI_URL = + `https://codeberg.org/wownero/wownero/releases/download/v0.11.2.0/wownero-x86_64-linux-gnu-59db3fe8d.tar.bz2`; - await $`wget ${MONERO_WALLET_CLI}`; + await $`wget ${WOWNERO_WALLET_CLI_URL}`; await $ - .raw`tar -xvf ${MONERO_CLI_VERSION}.tar.bz2 --one-top-level=monero-cli --strip-components=1 -C tests`; - await $.raw`rm ${MONERO_CLI_VERSION}.tar.bz2`; + .raw`tar -xvf ${WOWNERO_CLI_FILE_NAME}.tar.bz2 --one-top-level=monero-cli --strip-components=1 -C tests`; + await $.raw`rm ${WOWNERO_CLI_FILE_NAME}.tar.bz2`; +} + +export function downloadCli(coin: Coin) { + if (coin === "wownero") { + return downloadWowneroCli(); + } + return downloadMoneroCli(); } interface WalletInfo { @@ -30,33 +49,35 @@ interface WalletInfo { } export async function createWalletViaCli( + coin: Coin, name: string, password: string, ): Promise { const path = `./tests/wallets/${name}`; + const cliPath = `./tests/${coin}-cli/${coin}-wallet-cli`; - await $`./tests/monero-cli/monero-wallet-cli --generate-new-wallet ${path} --password ${password} --mnemonic-language English --command exit` + await $ + .raw`${cliPath} --generate-new-wallet ${path} --password ${password} --mnemonic-language English --command exit` .stdout("null"); - const address = - (await $`./tests/monero-cli/monero-wallet-cli --wallet-file ${path} --password ${password} --command address` - .stdinText(`${password}\n`) - .lines()) - .at(-1)! - .split(/\s+/)[1]; + const address = (await $.raw`${cliPath} --wallet-file ${path} --password ${password} --command address` + .stdinText(`${password}\n`) + .lines()) + .at(-1)! + .split(/\s+/)[1]; const retrieveKeys = (lines: string[]) => lines.slice(-2) .map((line) => line.split(": ")[1]); const [secretSpendKey, publicSpendKey] = retrieveKeys( - await $`./tests/monero-cli/monero-wallet-cli --wallet-file ${path} --password ${password} --command spendkey` + await $.raw`${cliPath} --wallet-file ${path} --password ${password} --command spendkey` .stdinText(`${password}\n`) .lines(), ); const [secretViewKey, publicViewKey] = retrieveKeys( - await $`./tests/monero-cli/monero-wallet-cli --wallet-file ${path} --password ${password} --command viewkey` + await $.raw`${cliPath} --wallet-file ${path} --password ${password} --command viewkey` .stdinText(`${password}\n`) .lines(), ); @@ -83,19 +104,17 @@ export async function getMoneroCTags(): Promise { ) as { tag_name: string }[]) .map(({ tag_name }) => tag_name); } -export async function getMoneroC(version: MoneroCVersion) { - const triple = "x86_64-linux-gnu"; - const dylibName = "monero_x86_64-linux-gnu_libwallet2_api_c.so"; - const endpointDylibName = "monero_libwallet2_api_c.so"; - const releaseDylibName = dylibName.slice("monero_".length); +export async function getMoneroC(coin: Coin, version: MoneroCVersion) { + const dylibName = `${coin}_x86_64-linux-gnu_libwallet2_api_c.so`; + const endpointDylibName = `${coin}_libwallet2_api_c.so`; + const releaseDylibName = dylibName.slice(`${coin}_`.length); if (version === "next") { - await $.raw`xz -kd release/monero/${releaseDylibName}.xz`; + await $.raw`xz -kd release/${coin}/${releaseDylibName}.xz`; await $`mkdir -p tests/libs/next`; - await $`mv release/monero/${releaseDylibName} tests/libs/next/${endpointDylibName}`; + await $`mv release/${coin}/${releaseDylibName} tests/libs/next/${endpointDylibName}`; } else { - const downloadUrl = - `https://github.com/MrCyjaneK/monero_c/releases/download/${version}/${dylibName}.xz`; + const downloadUrl = `https://github.com/MrCyjaneK/monero_c/releases/download/${version}/${dylibName}.xz`; const file = await Deno.open(`./tests/${dylibName}.xz`, { create: true,