test monerod3 with proper connection

This commit is contained in:
woodser 2024-01-17 11:22:12 -05:00
parent da79f15a5a
commit 24f6ce227a
4 changed files with 178 additions and 102 deletions

View File

@ -6349,6 +6349,9 @@ export class ProcessModel extends jspb.Message {
getPaymentSentMessageState(): string;
setPaymentSentMessageState(value: string): ProcessModel;
getPaymentSentMessageStateArbitrator(): string;
setPaymentSentMessageStateArbitrator(value: string): ProcessModel;
getMakerSignature(): Uint8Array | string;
getMakerSignature_asU8(): Uint8Array;
getMakerSignature_asB64(): string;
@ -6388,6 +6391,9 @@ export class ProcessModel extends jspb.Message {
getSellerPayoutAmountFromMediation(): number;
setSellerPayoutAmountFromMediation(value: number): ProcessModel;
getDeleteBackupsHeight(): number;
setDeleteBackupsHeight(value: number): ProcessModel;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ProcessModel.AsObject;
static toObject(includeInstance: boolean, msg: ProcessModel): ProcessModel.AsObject;
@ -6405,6 +6411,7 @@ export namespace ProcessModel {
useSavingsWallet: boolean,
fundsNeededForTrade: number,
paymentSentMessageState: string,
paymentSentMessageStateArbitrator: string,
makerSignature: Uint8Array | string,
maker?: TradePeer.AsObject,
taker?: TradePeer.AsObject,
@ -6414,6 +6421,7 @@ export namespace ProcessModel {
mediatedPayoutTxSignature: Uint8Array | string,
buyerPayoutAmountFromMediation: number,
sellerPayoutAmountFromMediation: number,
deleteBackupsHeight: number,
}
}

190
dist/protobuf/pb_pb.js vendored
View File

@ -51192,15 +51192,17 @@ proto.io.haveno.protobuffer.ProcessModel.toObject = function(includeInstance, ms
useSavingsWallet: jspb.Message.getBooleanFieldWithDefault(msg, 5, false),
fundsNeededForTrade: jspb.Message.getFieldWithDefault(msg, 6, 0),
paymentSentMessageState: jspb.Message.getFieldWithDefault(msg, 7, ""),
paymentSentMessageStateArbitrator: jspb.Message.getFieldWithDefault(msg, 8, ""),
makerSignature: msg.getMakerSignature_asB64(),
maker: (f = msg.getMaker()) && proto.io.haveno.protobuffer.TradePeer.toObject(includeInstance, f),
taker: (f = msg.getTaker()) && proto.io.haveno.protobuffer.TradePeer.toObject(includeInstance, f),
arbitrator: (f = msg.getArbitrator()) && proto.io.haveno.protobuffer.TradePeer.toObject(includeInstance, f),
tempTradePeerNodeAddress: (f = msg.getTempTradePeerNodeAddress()) && proto.io.haveno.protobuffer.NodeAddress.toObject(includeInstance, f),
multisigAddress: jspb.Message.getFieldWithDefault(msg, 13, ""),
multisigAddress: jspb.Message.getFieldWithDefault(msg, 14, ""),
mediatedPayoutTxSignature: msg.getMediatedPayoutTxSignature_asB64(),
buyerPayoutAmountFromMediation: jspb.Message.getFieldWithDefault(msg, 18, 0),
sellerPayoutAmountFromMediation: jspb.Message.getFieldWithDefault(msg, 19, 0)
buyerPayoutAmountFromMediation: jspb.Message.getFieldWithDefault(msg, 16, 0),
sellerPayoutAmountFromMediation: jspb.Message.getFieldWithDefault(msg, 17, 0),
deleteBackupsHeight: jspb.Message.getFieldWithDefault(msg, 18, 0)
};
if (includeInstance) {
@ -51267,45 +51269,53 @@ proto.io.haveno.protobuffer.ProcessModel.deserializeBinaryFromReader = function(
msg.setPaymentSentMessageState(value);
break;
case 8:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setMakerSignature(value);
var value = /** @type {string} */ (reader.readString());
msg.setPaymentSentMessageStateArbitrator(value);
break;
case 9:
var value = new proto.io.haveno.protobuffer.TradePeer;
reader.readMessage(value,proto.io.haveno.protobuffer.TradePeer.deserializeBinaryFromReader);
msg.setMaker(value);
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setMakerSignature(value);
break;
case 10:
var value = new proto.io.haveno.protobuffer.TradePeer;
reader.readMessage(value,proto.io.haveno.protobuffer.TradePeer.deserializeBinaryFromReader);
msg.setTaker(value);
msg.setMaker(value);
break;
case 11:
var value = new proto.io.haveno.protobuffer.TradePeer;
reader.readMessage(value,proto.io.haveno.protobuffer.TradePeer.deserializeBinaryFromReader);
msg.setArbitrator(value);
msg.setTaker(value);
break;
case 12:
var value = new proto.io.haveno.protobuffer.TradePeer;
reader.readMessage(value,proto.io.haveno.protobuffer.TradePeer.deserializeBinaryFromReader);
msg.setArbitrator(value);
break;
case 13:
var value = new proto.io.haveno.protobuffer.NodeAddress;
reader.readMessage(value,proto.io.haveno.protobuffer.NodeAddress.deserializeBinaryFromReader);
msg.setTempTradePeerNodeAddress(value);
break;
case 13:
case 14:
var value = /** @type {string} */ (reader.readString());
msg.setMultisigAddress(value);
break;
case 17:
case 15:
var value = /** @type {!Uint8Array} */ (reader.readBytes());
msg.setMediatedPayoutTxSignature(value);
break;
case 18:
case 16:
var value = /** @type {number} */ (reader.readInt64());
msg.setBuyerPayoutAmountFromMediation(value);
break;
case 19:
case 17:
var value = /** @type {number} */ (reader.readInt64());
msg.setSellerPayoutAmountFromMediation(value);
break;
case 18:
var value = /** @type {number} */ (reader.readInt64());
msg.setDeleteBackupsHeight(value);
break;
default:
reader.skipField();
break;
@ -51385,22 +51395,21 @@ proto.io.haveno.protobuffer.ProcessModel.serializeBinaryToWriter = function(mess
f
);
}
f = message.getMakerSignature_asU8();
f = message.getPaymentSentMessageStateArbitrator();
if (f.length > 0) {
writer.writeBytes(
writer.writeString(
8,
f
);
}
f = message.getMaker();
if (f != null) {
writer.writeMessage(
f = message.getMakerSignature_asU8();
if (f.length > 0) {
writer.writeBytes(
9,
f,
proto.io.haveno.protobuffer.TradePeer.serializeBinaryToWriter
f
);
}
f = message.getTaker();
f = message.getMaker();
if (f != null) {
writer.writeMessage(
10,
@ -51408,7 +51417,7 @@ proto.io.haveno.protobuffer.ProcessModel.serializeBinaryToWriter = function(mess
proto.io.haveno.protobuffer.TradePeer.serializeBinaryToWriter
);
}
f = message.getArbitrator();
f = message.getTaker();
if (f != null) {
writer.writeMessage(
11,
@ -51416,39 +51425,54 @@ proto.io.haveno.protobuffer.ProcessModel.serializeBinaryToWriter = function(mess
proto.io.haveno.protobuffer.TradePeer.serializeBinaryToWriter
);
}
f = message.getTempTradePeerNodeAddress();
f = message.getArbitrator();
if (f != null) {
writer.writeMessage(
12,
f,
proto.io.haveno.protobuffer.TradePeer.serializeBinaryToWriter
);
}
f = message.getTempTradePeerNodeAddress();
if (f != null) {
writer.writeMessage(
13,
f,
proto.io.haveno.protobuffer.NodeAddress.serializeBinaryToWriter
);
}
f = message.getMultisigAddress();
if (f.length > 0) {
writer.writeString(
13,
14,
f
);
}
f = message.getMediatedPayoutTxSignature_asU8();
if (f.length > 0) {
writer.writeBytes(
17,
15,
f
);
}
f = message.getBuyerPayoutAmountFromMediation();
if (f !== 0) {
writer.writeInt64(
18,
16,
f
);
}
f = message.getSellerPayoutAmountFromMediation();
if (f !== 0) {
writer.writeInt64(
19,
17,
f
);
}
f = message.getDeleteBackupsHeight();
if (f !== 0) {
writer.writeInt64(
18,
f
);
}
@ -51625,16 +51649,34 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.setPaymentSentMessageState =
/**
* optional bytes maker_signature = 8;
* @return {!(string|Uint8Array)}
* optional string payment_sent_message_state_arbitrator = 8;
* @return {string}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getMakerSignature = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 8, ""));
proto.io.haveno.protobuffer.ProcessModel.prototype.getPaymentSentMessageStateArbitrator = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, ""));
};
/**
* optional bytes maker_signature = 8;
* @param {string} value
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setPaymentSentMessageStateArbitrator = function(value) {
return jspb.Message.setProto3StringField(this, 8, value);
};
/**
* optional bytes maker_signature = 9;
* @return {!(string|Uint8Array)}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getMakerSignature = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 9, ""));
};
/**
* optional bytes maker_signature = 9;
* This is a type-conversion wrapper around `getMakerSignature()`
* @return {string}
*/
@ -51645,7 +51687,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMakerSignature_asB64 = fun
/**
* optional bytes maker_signature = 8;
* optional bytes maker_signature = 9;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getMakerSignature()`
@ -51662,17 +51704,17 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMakerSignature_asU8 = func
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setMakerSignature = function(value) {
return jspb.Message.setProto3BytesField(this, 8, value);
return jspb.Message.setProto3BytesField(this, 9, value);
};
/**
* optional TradePeer maker = 9;
* optional TradePeer maker = 10;
* @return {?proto.io.haveno.protobuffer.TradePeer}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getMaker = function() {
return /** @type{?proto.io.haveno.protobuffer.TradePeer} */ (
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 9));
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 10));
};
@ -51681,7 +51723,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMaker = function() {
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setMaker = function(value) {
return jspb.Message.setWrapperField(this, 9, value);
return jspb.Message.setWrapperField(this, 10, value);
};
@ -51699,17 +51741,17 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.clearMaker = function() {
* @return {boolean}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.hasMaker = function() {
return jspb.Message.getField(this, 9) != null;
return jspb.Message.getField(this, 10) != null;
};
/**
* optional TradePeer taker = 10;
* optional TradePeer taker = 11;
* @return {?proto.io.haveno.protobuffer.TradePeer}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getTaker = function() {
return /** @type{?proto.io.haveno.protobuffer.TradePeer} */ (
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 10));
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 11));
};
@ -51718,7 +51760,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getTaker = function() {
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setTaker = function(value) {
return jspb.Message.setWrapperField(this, 10, value);
return jspb.Message.setWrapperField(this, 11, value);
};
@ -51736,17 +51778,17 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.clearTaker = function() {
* @return {boolean}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.hasTaker = function() {
return jspb.Message.getField(this, 10) != null;
return jspb.Message.getField(this, 11) != null;
};
/**
* optional TradePeer arbitrator = 11;
* optional TradePeer arbitrator = 12;
* @return {?proto.io.haveno.protobuffer.TradePeer}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getArbitrator = function() {
return /** @type{?proto.io.haveno.protobuffer.TradePeer} */ (
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 11));
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.TradePeer, 12));
};
@ -51755,7 +51797,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getArbitrator = function() {
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setArbitrator = function(value) {
return jspb.Message.setWrapperField(this, 11, value);
return jspb.Message.setWrapperField(this, 12, value);
};
@ -51773,17 +51815,17 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.clearArbitrator = function()
* @return {boolean}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.hasArbitrator = function() {
return jspb.Message.getField(this, 11) != null;
return jspb.Message.getField(this, 12) != null;
};
/**
* optional NodeAddress temp_trade_peer_node_address = 12;
* optional NodeAddress temp_trade_peer_node_address = 13;
* @return {?proto.io.haveno.protobuffer.NodeAddress}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getTempTradePeerNodeAddress = function() {
return /** @type{?proto.io.haveno.protobuffer.NodeAddress} */ (
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.NodeAddress, 12));
jspb.Message.getWrapperField(this, proto.io.haveno.protobuffer.NodeAddress, 13));
};
@ -51792,7 +51834,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getTempTradePeerNodeAddress =
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setTempTradePeerNodeAddress = function(value) {
return jspb.Message.setWrapperField(this, 12, value);
return jspb.Message.setWrapperField(this, 13, value);
};
@ -51810,16 +51852,16 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.clearTempTradePeerNodeAddress
* @return {boolean}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.hasTempTradePeerNodeAddress = function() {
return jspb.Message.getField(this, 12) != null;
return jspb.Message.getField(this, 13) != null;
};
/**
* optional string multisig_address = 13;
* optional string multisig_address = 14;
* @return {string}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getMultisigAddress = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 13, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 14, ""));
};
@ -51828,21 +51870,21 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMultisigAddress = function
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setMultisigAddress = function(value) {
return jspb.Message.setProto3StringField(this, 13, value);
return jspb.Message.setProto3StringField(this, 14, value);
};
/**
* optional bytes mediated_payout_tx_signature = 17;
* optional bytes mediated_payout_tx_signature = 15;
* @return {!(string|Uint8Array)}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getMediatedPayoutTxSignature = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 17, ""));
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 15, ""));
};
/**
* optional bytes mediated_payout_tx_signature = 17;
* optional bytes mediated_payout_tx_signature = 15;
* This is a type-conversion wrapper around `getMediatedPayoutTxSignature()`
* @return {string}
*/
@ -51853,7 +51895,7 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMediatedPayoutTxSignature_
/**
* optional bytes mediated_payout_tx_signature = 17;
* optional bytes mediated_payout_tx_signature = 15;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getMediatedPayoutTxSignature()`
@ -51870,16 +51912,16 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getMediatedPayoutTxSignature_
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setMediatedPayoutTxSignature = function(value) {
return jspb.Message.setProto3BytesField(this, 17, value);
return jspb.Message.setProto3BytesField(this, 15, value);
};
/**
* optional int64 buyer_payout_amount_from_mediation = 18;
* optional int64 buyer_payout_amount_from_mediation = 16;
* @return {number}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getBuyerPayoutAmountFromMediation = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 18, 0));
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 16, 0));
};
@ -51888,16 +51930,16 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getBuyerPayoutAmountFromMedia
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setBuyerPayoutAmountFromMediation = function(value) {
return jspb.Message.setProto3IntField(this, 18, value);
return jspb.Message.setProto3IntField(this, 16, value);
};
/**
* optional int64 seller_payout_amount_from_mediation = 19;
* optional int64 seller_payout_amount_from_mediation = 17;
* @return {number}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getSellerPayoutAmountFromMediation = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 19, 0));
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 17, 0));
};
@ -51906,7 +51948,25 @@ proto.io.haveno.protobuffer.ProcessModel.prototype.getSellerPayoutAmountFromMedi
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setSellerPayoutAmountFromMediation = function(value) {
return jspb.Message.setProto3IntField(this, 19, value);
return jspb.Message.setProto3IntField(this, 17, value);
};
/**
* optional int64 delete_backups_height = 18;
* @return {number}
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.getDeleteBackupsHeight = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 18, 0));
};
/**
* @param {number} value
* @return {!proto.io.haveno.protobuffer.ProcessModel} returns this
*/
proto.io.haveno.protobuffer.ProcessModel.prototype.setDeleteBackupsHeight = function(value) {
return jspb.Message.setProto3IntField(this, 18, value);
};

File diff suppressed because one or more lines are too long

View File

@ -337,11 +337,11 @@ const TestConfig = {
version: "1.0.17"
},
monerod: {
url: "http://localhost:" + (getBaseCurrencyNetwork() == BaseCurrencyNetwork.XMR_LOCAL ? "4" : getNetworkStartPort()) + "8081", // 18081, 28081, 48081 for mainnet, stagenet, and local testnet, respectively
url: "http://localhost:" + getNetworkStartPort() + "8081", // 18081, 28081, 38081 for mainnet, testnet, and stagenet, respectively
username: "",
password: ""
},
monerod2: {
monerod3: { // corresponds to monerod3-local in Makefile
url: "http://localhost:58081",
username: "superuser",
password: "abctesting123",
@ -693,7 +693,7 @@ test("Can manage an account (CI)", async () => {
});
test("Can manage Monero daemon connections (CI)", async () => {
let monerod2: moneroTs.MoneroDaemonRpc | undefined = undefined;
let monerod3: moneroTs.MoneroDaemonRpc | undefined = undefined;
let user3: HavenoClient|undefined;
let err: any;
try {
@ -720,48 +720,54 @@ test("Can manage Monero daemon connections (CI)", async () => {
// set prioritized connection without credentials
await user3.setMoneroConnection(new UrlConnection()
.setUrl(TestConfig.monerod2.url)
.setUrl(TestConfig.monerod3.url)
.setPriority(1));
connection = await user3.getMoneroConnection();
testConnection(connection!, TestConfig.monerod2.url, undefined, undefined, 1); // status may or may not be known due to periodic connection checking
testConnection(connection!, TestConfig.monerod3.url, undefined, undefined, 1); // status may or may not be known due to periodic connection checking
// connection is offline
connection = await user3.checkMoneroConnection();
assert(!await user3.isConnectedToMonero());
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.OFFLINE, AuthenticationStatus.NO_AUTHENTICATION, 1);
testConnection(connection!, TestConfig.monerod3.url, OnlineStatus.OFFLINE, AuthenticationStatus.NO_AUTHENTICATION, 1);
// start monerod2
// start monerod3
const cmd = [
TestConfig.moneroBinsDir + "/monerod",
"--no-igd",
"--hide-my-port",
"--data-dir", TestConfig.moneroBinsDir + "/" + TestConfig.baseCurrencyNetwork.toLowerCase() + "/testnode",
"--p2p-bind-port", TestConfig.monerod2.p2pBindPort,
"--rpc-bind-port", TestConfig.monerod2.rpcBindPort,
"--no-zmq"
"--data-dir", TestConfig.moneroBinsDir + "/" + TestConfig.baseCurrencyNetwork.toLowerCase() + "/node3",
"--p2p-bind-ip", "127.0.0.1",
"--p2p-bind-port", TestConfig.monerod3.p2pBindPort,
"--rpc-bind-port", TestConfig.monerod3.rpcBindPort,
"--zmq-rpc-bind-port", TestConfig.monerod3.zmqRpcBindPort,
"--log-level", "0",
"--confirm-external-bind",
"--rpc-access-control-origins", "http://localhost:8080",
"--fixed-difficulty", "500",
"--disable-rpc-ban"
];
if (getBaseCurrencyNetwork() !== BaseCurrencyNetwork.XMR_MAINNET) cmd.push("--" + moneroTs.MoneroNetworkType.toString(TestConfig.networkType).toLowerCase());
if (TestConfig.monerod2.username) cmd.push("--rpc-login", TestConfig.monerod2.username + ":" + TestConfig.monerod2.password);
monerod2 = await moneroTs.connectToDaemonRpc(cmd);
if (TestConfig.monerod3.username) cmd.push("--rpc-login", TestConfig.monerod3.username + ":" + TestConfig.monerod3.password);
monerod3 = await moneroTs.connectToDaemonRpc(cmd);
// connection is online and not authenticated
connection = await user3.checkMoneroConnection();
assert(!await user3.isConnectedToMonero());
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.ONLINE, AuthenticationStatus.NOT_AUTHENTICATED, 1);
testConnection(connection!, TestConfig.monerod3.url, OnlineStatus.ONLINE, AuthenticationStatus.NOT_AUTHENTICATED, 1);
// set connection credentials
await user3.setMoneroConnection(new UrlConnection()
.setUrl(TestConfig.monerod2.url)
.setUsername(TestConfig.monerod2.username)
.setPassword(TestConfig.monerod2.password)
.setUrl(TestConfig.monerod3.url)
.setUsername(TestConfig.monerod3.username)
.setPassword(TestConfig.monerod3.password)
.setPriority(1));
connection = await user3.getMoneroConnection();
testConnection(connection!, TestConfig.monerod2.url, undefined, undefined, 1);
testConnection(connection!, TestConfig.monerod3.url, undefined, undefined, 1);
// connection is online and authenticated
connection = await user3.checkMoneroConnection();
assert(await user3.isConnectedToMonero());
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
testConnection(connection!, TestConfig.monerod3.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
// change account password
const newPassword = "newPassword";
@ -774,7 +780,7 @@ test("Can manage Monero daemon connections (CI)", async () => {
// connection is restored, online, and authenticated
connection = await user3.getMoneroConnection();
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
testConnection(connection!, TestConfig.monerod3.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
// priority connections are polled
await wait(TestConfig.daemonPollPeriodMs * 2);
@ -785,8 +791,8 @@ test("Can manage Monero daemon connections (CI)", async () => {
await user3.setAutoSwitch(true);
// stop monerod
//await monerod2.stopProcess(); // TODO (monero-ts): monerod remains available after await monerod.stopProcess() for up to 40 seconds
await moneroTs.GenUtils.killProcess(monerod2.getProcess(), "SIGKILL");
//await monerod3.stopProcess(); // TODO (monero-ts): monerod remains available after await monerod.stopProcess() for up to 40 seconds
await moneroTs.GenUtils.killProcess(monerod3.getProcess(), "SIGKILL");
// test auto switch after periodic connection check
await wait(TestConfig.daemonPollPeriodMs * 2);
@ -843,10 +849,14 @@ test("Can manage Monero daemon connections (CI)", async () => {
// stop processes
if (user3) await releaseHavenoProcess(user3, true);
if (monerod2) await monerod2.stopProcess();
if (monerod3) await monerod3.stopProcess();
if (err) throw err;
});
// NOTE: To run full test, the following conditions must be met:
// - monerod1-local must be stopped
// - monerod2-local must be running
// - user1-daemon-local must be running and own its monerod process (so it can be stopped)
test("Can start and stop a local Monero node (CI)", async() => {
// expect error stopping local node
@ -890,12 +900,10 @@ test("Can start and stop a local Monero node (CI)", async() => {
// expect successful start with custom settings
const connectionsBefore = await user1.getMoneroConnections();
const settings: XmrNodeSettings = new XmrNodeSettings();
const dataDir = TestConfig.moneroBinsDir + "/" + TestConfig.baseCurrencyNetwork + "/node1";
const dataDir = TestConfig.moneroBinsDir + "/" + TestConfig.baseCurrencyNetwork.toLowerCase() + "/node1";
const logFile = dataDir + "/test.log";
const p2pPort = 38086;
const rpcPort = 38087;
settings.setBlockchainPath(dataDir);
settings.setStartupFlagsList(["--log-file", logFile, "--p2p-bind-port", p2pPort.toString(), "--rpc-bind-port", rpcPort.toString(), "--no-zmq"]);
settings.setStartupFlagsList(["--log-file", logFile, "--no-zmq"]);
await user1.startMoneroNode(settings);
isMoneroNodeOnline = await user1.isMoneroNodeOnline();
assert(isMoneroNodeOnline);
@ -905,10 +913,9 @@ test("Can start and stop a local Monero node (CI)", async() => {
testMoneroNodeSettingsEqual(settings, settingsAfter!);
// expect connection to local monero node to succeed
const rpcUrl = "http://127.0.0.1:" + rpcPort.toString();
let daemon = await moneroTs.connectToDaemonRpc(rpcUrl, "superuser", "abctesting123");
let daemon = await moneroTs.connectToDaemonRpc(TestConfig.monerod.url, "superuser", "abctesting123");
let height = await daemon.getHeight();
assert(height >= 0);
assert(height > 0);
// expect error due to existing running node
const newSettings = new XmrNodeSettings();
@ -924,11 +931,12 @@ test("Can start and stop a local Monero node (CI)", async() => {
isMoneroNodeOnline = await user1.isMoneroNodeOnline();
assert(!isMoneroNodeOnline);
try {
daemon = await moneroTs.connectToDaemonRpc(rpcUrl);
daemon = await moneroTs.connectToDaemonRpc(TestConfig.monerod.url);
height = await daemon.getHeight();
throw new Error("should have thrown");
console.log("GOT HEIGHT: " + height);
throw new Error("should have thrown");
} catch (err: any) {
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:28081") throw new Error("Unexpected error: " + err.message);
}
}
});
@ -3822,9 +3830,9 @@ function testOffer(offer: OfferInfo, ctx?: Partial<TradeContext>) {
}
function testMoneroNodeSettingsEqual(settingsBefore: XmrNodeSettings, settingsAfter: XmrNodeSettings) {
expect(settingsBefore.getBlockchainPath()).toEqual(settingsAfter.getBlockchainPath());
expect(settingsBefore.getBootstrapUrl()).toEqual(settingsAfter.getBootstrapUrl());
expect(settingsBefore.getStartupFlagsList()).toEqual(settingsAfter.getStartupFlagsList());
expect(settingsAfter.getBlockchainPath()).toEqual(settingsBefore.getBlockchainPath());
expect(settingsAfter.getBootstrapUrl()).toEqual(settingsBefore.getBootstrapUrl());
expect(settingsAfter.getStartupFlagsList()).toEqual(settingsBefore.getStartupFlagsList());
}
function getFormField(form: PaymentAccountForm, fieldId: PaymentAccountFormField.FieldId): PaymentAccountFormField {