Added RX switch tester

This commit is contained in:
MoneroOcean 2019-07-26 11:22:49 -07:00
parent b3c867a8ce
commit 8253b1c4f3
3 changed files with 107 additions and 0 deletions

18
misc/build.bat Normal file
View file

@ -0,0 +1,18 @@
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
rmdir /S /Q build
del %~dp0\xmrig-%1-win64.zip
mkdir build &&^
cd build &&^
git clone https://github.com/MoneroOcean/xmrig.git &&^
git clone https://github.com/xmrig/xmrig-deps.git &&^
mkdir xmrig\build &&^
cd xmrig\build &&^
git checkout %1 &&^
cmake .. -G "Visual Studio 15 2017 Win64" -DXMRIG_DEPS=%~dp0\build\xmrig-deps\msvc2017\x64 &&^
msbuild /p:Configuration=Release xmrig.sln &&^
cd Release &&^
copy ..\..\src\config.json . &&^
7z a -tzip -mx %~dp0\xmrig-%1-win64.zip xmrig.exe config.json &&^
cd %~dp0 &&^
rmdir /S /Q build

22
misc/build_rh6.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
yum update -y
yum upgrade -y
yum install -y git
yum install -y cmake make openssl-devel libmicrohttpd-devel centos-release-scl-rh
yum install -y --nogpgcheck devtoolset-6-gcc devtoolset-6-binutils devtoolset-6-gcc-c++
rpm -i https://github.com/sipcapture/captagent/raw/master/dependency/centos/6/libuv-1.8.0-1.el6.x86_64.rpm
rpm -i https://github.com/sipcapture/captagent/raw/master/dependency/centos/6/libuv-devel-1.8.0-1.el6.x86_64.rpm
rm -rf build xmrig-$1-lin64.tar.gz
mkdir build &&\
cd build &&\
git clone https://github.com/MoneroOcean/xmrig.git &&\
cd xmrig &&\
git checkout $1 &&\
scl enable devtoolset-6 "cmake . -DWITH_TLS=OFF -DWITH_HTTPD=OFF" &&\
scl enable devtoolset-6 "make" &&\
cp src/config.json . &&\
mv xmrig-notls xmrig &&\
tar cfz ../../xmrig-$1-lin64.tar.gz xmrig config.json &&\
cd ../.. &&\
rm -rf build &&\
echo OK

107
misc/switch_test.js Normal file
View file

@ -0,0 +1,107 @@
#!/usr/bin/env node
// Miner Tester: testing miner algo switch stability
"use strict";
// *****************************************************************************
// *** DEPENDECIES ***
// *****************************************************************************
const net = require('net');
// *****************************************************************************
// *** CONSTS ***
// *****************************************************************************
const algos = [ "rx/wow", "rx/loki" ];
// *****************************************************************************
// *** WORKING STATE ***
// *****************************************************************************
let curr_miner_socket = null;
// *****************************************************************************
// *** FUNCTIONS ***
// *****************************************************************************
// *** Console/log output
function log(msg) {
console.log(">>> " + msg);
}
function err(msg) {
console.error("!!! " + msg);
}
// *** Miner socket processing
const test_blob_str = "7f7ffeeaa0db054f15eca39c843cb82c15e5c5a7743e06536cb541d4e96e90ffd31120b7703aa90000000076a6f6e34a9977c982629d8fe6c8b45024cafca109eef92198784891e0df41bc03";
let miner_server = net.createServer(function (miner_socket) {
if (curr_miner_socket) {
err("Miner server on localhost:3333 port is already connected (please make sure you do not have other miner running)");
return;
}
log("Miner server on localhost:3333 port connected from " + miner_socket.remoteAddress);
let miner_data_buff = "";
miner_socket.on('data', function (msg) {
miner_data_buff += msg;
if (miner_data_buff.indexOf('\n') === -1) return;
let messages = miner_data_buff.split('\n');
let incomplete_line = miner_data_buff.slice(-1) === '\n' ? '' : messages.pop();
for (let i = 0; i < messages.length; i++) {
let message = messages[i];
if (message.trim() === '') continue;
let json;
try {
json = JSON.parse(message);
} catch (e) {
err("Can't parse message from the miner: " + message);
continue;
}
const is_keepalived = "method" in json && json.method === "keepalived";
if ("method" in json && json.method === "login") {
miner_socket.write(
'{"id":1,"jsonrpc":"2.0","error":null,"result":{"id":"benchmark","job":{"blob":"' + test_blob_str +
'","algo":"cn/1","job_id":"benchmark1","target":"10000000","seed_hash":"0000000000000000000000000000000000000000000000000000000000000001","id":"benchmark"},"status":"OK"}}\n'
);
curr_miner_socket = miner_socket;
}
}
miner_data_buff = incomplete_line;
});
miner_socket.on('end', function() {
log("Miner socket was closed");
curr_miner_socket = null;
});
miner_socket.on('error', function() {
err("Miner socket error");
miner_socket.destroy();
curr_miner_socket = null;
});
});
let job_num = 1;
function change_algo() {
if (curr_miner_socket) {
const algo = algos[Math.floor(Math.random() * algos.length)];
log("Switching to " + algo);
curr_miner_socket.write(
'{"jsonrpc":"2.0","method":"job","params":{"blob":"' + test_blob_str + '","algo":"' + algo +
'","job_id":"benchmark' + ++job_num + '","height":0,"seed_hash":"0000000000000000000000000000000000000000000000000000000000000000","target":"10000000","id":"benchmark"}}\n'
);
}
const sleep = Math.floor(Math.random() * 5);
log("Waiting " + sleep + "s");
setTimeout(change_algo, sleep * 1000);
}
miner_server.listen(3333, "localhost", function() {
log("Local miner server on localhost:3333 port started");
change_algo();
});