Skip to content

Commit

Permalink
ci: test wownero regressions as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Im-Beast committed Oct 15, 2024
1 parent 19d5722 commit 8627f1d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 39 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/full_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 11 additions & 6 deletions tests/regression.test.ts
Original file line number Diff line number Diff line change
@@ -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)}`;
Expand All @@ -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)}`;
}

Expand Down
67 changes: 43 additions & 24 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -30,33 +49,35 @@ interface WalletInfo {
}

export async function createWalletViaCli(
coin: Coin,
name: string,
password: string,
): Promise<WalletInfo> {
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(),
);
Expand All @@ -83,19 +104,17 @@ export async function getMoneroCTags(): Promise<string[]> {
) 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,
Expand Down

0 comments on commit 8627f1d

Please sign in to comment.