mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-08-07 05:52:23 -04:00
use current blockchain path to start/stop node, logging
This commit is contained in:
parent
9eea85265a
commit
8ed5eb82a9
1 changed files with 13 additions and 15 deletions
|
@ -29,6 +29,7 @@ const console = require('console'); // import console because jest swallows mess
|
||||||
const TestConfig = {
|
const TestConfig = {
|
||||||
logLevel: 0,
|
logLevel: 0,
|
||||||
moneroBinsDir: "../haveno/.localnet",
|
moneroBinsDir: "../haveno/.localnet",
|
||||||
|
testDataDir: "./testdata",
|
||||||
networkType: monerojs.MoneroNetworkType.STAGENET,
|
networkType: monerojs.MoneroNetworkType.STAGENET,
|
||||||
haveno: {
|
haveno: {
|
||||||
path: "../haveno",
|
path: "../haveno",
|
||||||
|
@ -215,7 +216,7 @@ test("Can manage an account", async () => {
|
||||||
// create account
|
// create account
|
||||||
let password = "testPassword";
|
let password = "testPassword";
|
||||||
await charlie.createAccount(password);
|
await charlie.createAccount(password);
|
||||||
await charlie.getBalances();
|
if (await charlie.isConnectedToMonero()) await charlie.getBalances(); // only connected if local node running
|
||||||
assert(await charlie.accountExists());
|
assert(await charlie.accountExists());
|
||||||
assert(await charlie.isAccountOpen());
|
assert(await charlie.isAccountOpen());
|
||||||
|
|
||||||
|
@ -267,8 +268,7 @@ test("Can manage an account", async () => {
|
||||||
assert(await charlie.isAccountOpen());
|
assert(await charlie.isAccountOpen());
|
||||||
|
|
||||||
// backup account to zip file
|
// backup account to zip file
|
||||||
let rootDir = process.cwd();
|
let zipFile = TestConfig.testDataDir + "/backup.zip";
|
||||||
let zipFile = rootDir + "/backup.zip";
|
|
||||||
let stream = fs.createWriteStream(zipFile);
|
let stream = fs.createWriteStream(zipFile);
|
||||||
let size = await charlie.backupAccount(stream);
|
let size = await charlie.backupAccount(stream);
|
||||||
stream.end();
|
stream.end();
|
||||||
|
@ -357,7 +357,7 @@ test("Can manage Monero daemon connections", async () => {
|
||||||
"--" + monerojs.MoneroNetworkType.toString(TestConfig.networkType).toLowerCase(),
|
"--" + monerojs.MoneroNetworkType.toString(TestConfig.networkType).toLowerCase(),
|
||||||
"--no-igd",
|
"--no-igd",
|
||||||
"--hide-my-port",
|
"--hide-my-port",
|
||||||
"--data-dir", TestConfig.moneroBinsDir + "/node1",
|
"--data-dir", TestConfig.moneroBinsDir + "/stagenet/testnode",
|
||||||
"--p2p-bind-port", "58080",
|
"--p2p-bind-port", "58080",
|
||||||
"--rpc-bind-port", "58081",
|
"--rpc-bind-port", "58081",
|
||||||
"--rpc-login", "superuser:abctesting123",
|
"--rpc-login", "superuser:abctesting123",
|
||||||
|
@ -465,25 +465,24 @@ test("Can manage Monero daemon connections", async () => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Can start and stop local Monero node", async() => {
|
test("Can start and stop a local Monero node", async() => {
|
||||||
let rootDir = process.cwd();
|
|
||||||
|
|
||||||
// expect error stopping local node
|
// expect error stopping local node
|
||||||
try {
|
try {
|
||||||
await alice.stopMoneroNode();
|
await alice.stopMoneroNode();
|
||||||
console.log("Running Monero local node stopped");
|
HavenoUtils.log(1, "Running local Monero node stopped");
|
||||||
await alice.stopMoneroNode(); // stop 2nd time to force error
|
await alice.stopMoneroNode(); // stop 2nd time to force error
|
||||||
throw new Error("should have thrown");
|
throw new Error("should have thrown");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.message !== "Monero node is not running" &&
|
if (err.message !== "Local Monero node is not running" &&
|
||||||
err.message !== "MoneroDaemonRpc instance not created from new process") { // daemon doesn't own the local monero node process
|
err.message !== "Cannot stop local Monero node because we don't own its process") {
|
||||||
throw new Error("Unexpected error: " + err.message);
|
throw new Error("Unexpected error: " + err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let isMoneroNodeRunning = await alice.isMoneroNodeRunning();
|
let isMoneroNodeRunning = await alice.isMoneroNodeRunning();
|
||||||
if (isMoneroNodeRunning) {
|
if (isMoneroNodeRunning) {
|
||||||
console.log("Warning: local Monero node is already running, skipping start and stop local Monero node test");
|
HavenoUtils.log(0, "Warning: local Monero node is already running, skipping start and stop local Monero node tests");
|
||||||
|
|
||||||
// expect error due to existing running node
|
// expect error due to existing running node
|
||||||
let newSettings = new MoneroNodeSettings();
|
let newSettings = new MoneroNodeSettings();
|
||||||
|
@ -491,7 +490,7 @@ test("Can start and stop local Monero node", async() => {
|
||||||
await alice.startMoneroNode(newSettings);
|
await alice.startMoneroNode(newSettings);
|
||||||
throw new Error("should have thrown");
|
throw new Error("should have thrown");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.message !== "Monero node already running") throw new Error("Unexpected error: " + err.message);
|
if (err.message !== "Local Monero node already running") throw new Error("Unexpected error: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -509,8 +508,8 @@ test("Can start and stop local Monero node", async() => {
|
||||||
// expect successful start with custom settings
|
// expect successful start with custom settings
|
||||||
let connectionsBefore = await alice.getMoneroConnections();
|
let connectionsBefore = await alice.getMoneroConnections();
|
||||||
let settings: MoneroNodeSettings = new MoneroNodeSettings();
|
let settings: MoneroNodeSettings = new MoneroNodeSettings();
|
||||||
let dataDir = rootDir + "/testdata";
|
let dataDir = TestConfig.moneroBinsDir + "/stagenet/node1";
|
||||||
let logFile = rootDir + "/testdata/test.log";
|
let logFile = dataDir + "/test.log";
|
||||||
let p2pPort = 38080;
|
let p2pPort = 38080;
|
||||||
let rpcPort = 38081;
|
let rpcPort = 38081;
|
||||||
settings.setBlockchainPath(dataDir);
|
settings.setBlockchainPath(dataDir);
|
||||||
|
@ -539,7 +538,7 @@ test("Can start and stop local Monero node", async() => {
|
||||||
await alice.startMoneroNode(newSettings);
|
await alice.startMoneroNode(newSettings);
|
||||||
throw new Error("should have thrown");
|
throw new Error("should have thrown");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.message !== "Monero node already running") throw new Error("Unexpected error: " + err.message);
|
if (err.message !== "Local Monero node already running") throw new Error("Unexpected error: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// expect stopped node
|
// expect stopped node
|
||||||
|
@ -554,7 +553,6 @@ test("Can start and stop local Monero node", async() => {
|
||||||
if (err.message !== "RequestError: Error: connect ECONNREFUSED 127.0.0.1:" + rpcPort.toString()) throw new Error("Unexpected error: " + err.message);
|
if (err.message !== "RequestError: Error: connect ECONNREFUSED 127.0.0.1:" + rpcPort.toString()) throw new Error("Unexpected error: " + err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// test wallet balances, transactions, deposit addresses, create and relay txs
|
// test wallet balances, transactions, deposit addresses, create and relay txs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue