summaryrefslogtreecommitdiff
path: root/tests/utils.ts
diff options
context:
space:
mode:
authorIm-Beast <franik.mateusz@gmail.com>2024-10-15 15:20:09 +0200
committerIm-Beast <franik.mateusz@gmail.com>2024-10-15 15:20:09 +0200
commit8627f1d904ff51c43d2183666834a6dcd3ff9598 (patch)
treedbb46efc2fbc09aeb39155b5b9aa12265f43faa4 /tests/utils.ts
parent19d5722aeabdb5e42bb14a340cc30854083bb795 (diff)
ci: test wownero regressions as well
Diffstat (limited to 'tests/utils.ts')
-rwxr-xr-xtests/utils.ts67
1 files changed, 43 insertions, 24 deletions
diff --git a/tests/utils.ts b/tests/utils.ts
index 78584a7..ed82a38 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<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(),
);
@@ -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,