diff --git a/.gitmodules b/.gitmodules
index 8fdebd0c2..60a8f52ae 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "deps/csredis"]
path = deps/csredis
url = https://github.com/CoiniumServ/csredis.git
+[submodule "deps/json-rpc"]
+ path = deps/json-rpc
+ url = https://github.com/CoiniumServ/JSON-RPC.NET.git
diff --git a/README.md b/README.md
index c60d4d4cb..dc8cc4bde 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,16 @@ Even better multi-pool & auto-exchange module is being developed which once comp
CoiniumServ was created to be used for [Coinium.org](http://www.coinium.org) mining pool network at first hand. You can check [some of pools](https://github.com/CoiniumServ/CoiniumServ/wiki/Pools) of the pools running CoiniumServ.
+### Screenshots
+
+##### Console
+
![CoiniumServ running over mono & ubuntu](http://i.imgur.com/HvaPVrZ.png)
+##### Embedded web frontend
+
+![Embedded web frontend](http://i.imgur.com/oOF8lQ0.png)
+
### Status
Latest release: [v0.2.0 alpha](https://github.com/CoiniumServ/CoiniumServ/releases/tag/v0.2.0-beta)
diff --git a/build/CoiniumServ.sln b/build/CoiniumServ.sln
index 12145daa3..b2c3815e8 100644
--- a/build/CoiniumServ.sln
+++ b/build/CoiniumServ.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.30501.0
+VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{02E410C9-83C5-4D63-8902-5AD041EBEB6C}"
ProjectSection(SolutionItems) = preProject
@@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSRedis", "..\deps\csredis\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libCoiniumServ", "..\src\libCoiniumServ\libCoiniumServ.csproj", "{F908636C-BC75-4B93-A774-E4878F3D39AF}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AustinHarris.JsonRpc", "..\deps\json-rpc\Json-Rpc\AustinHarris.JsonRpc.csproj", "{24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -107,6 +109,24 @@ Global
{F908636C-BC75-4B93-A774-E4878F3D39AF}.Testing|Mixed Platforms.ActiveCfg = Release|Any CPU
{F908636C-BC75-4B93-A774-E4878F3D39AF}.Testing|Mixed Platforms.Build.0 = Release|Any CPU
{F908636C-BC75-4B93-A774-E4878F3D39AF}.Testing|x86.ActiveCfg = Release|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|x86.ActiveCfg = Debug|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Debug|x86.Build.0 = Debug|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|Any CPU.Build.0 = Release|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|Mixed Platforms.Build.0 = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|x86.ActiveCfg = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Release|x86.Build.0 = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|Any CPU.ActiveCfg = Release|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|Any CPU.Build.0 = Release|Any CPU
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|Mixed Platforms.ActiveCfg = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|Mixed Platforms.Build.0 = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|x86.ActiveCfg = Release|x86
+ {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}.Testing|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/deps/json-rpc b/deps/json-rpc
new file mode 160000
index 000000000..6669face8
--- /dev/null
+++ b/deps/json-rpc
@@ -0,0 +1 @@
+Subproject commit 6669face8648d2a22ce369bb466834d95a556827
diff --git a/src/CoiniumServ/CoiniumServ.csproj b/src/CoiniumServ/CoiniumServ.csproj
index 9acac47ef..5d54d42f7 100644
--- a/src/CoiniumServ/CoiniumServ.csproj
+++ b/src/CoiniumServ/CoiniumServ.csproj
@@ -46,10 +46,6 @@
Coinium.ico
-
- False
- ..\..\build\packages\AustinHarris.JsonRpc.1.0.4.18\lib\net40\AustinHarris.JsonRpc.dll
-
False
..\..\build\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll
@@ -120,11 +116,11 @@
False
- ..\..\build\packages\Serilog.1.4.9\lib\net45\Serilog.dll
+ ..\..\build\packages\Serilog.1.4.10\lib\net45\Serilog.dll
False
- ..\..\build\packages\Serilog.1.4.9\lib\net45\Serilog.FullNetFx.dll
+ ..\..\build\packages\Serilog.1.4.10\lib\net45\Serilog.FullNetFx.dll
@@ -440,18 +436,18 @@
-
+
-
+
-
+
-
+
@@ -957,6 +953,10 @@
{d35e185e-a7e1-41e1-846c-21944f56074f}
CSRedis
+
+ {24fc1a2a-0bc3-43a7-9bfe-b628c2c4a307}
+ AustinHarris.JsonRpc
+
{f908636c-bc75-4b93-a774-e4878f3d39af}
libCoiniumServ
diff --git a/src/CoiniumServ/Container/Registries/ServerRegistry.cs b/src/CoiniumServ/Container/Registries/ServerRegistry.cs
index cbb670807..bd698b711 100644
--- a/src/CoiniumServ/Container/Registries/ServerRegistry.cs
+++ b/src/CoiniumServ/Container/Registries/ServerRegistry.cs
@@ -24,10 +24,8 @@
using CoiniumServ.Container.Context;
using CoiniumServ.Server.Mining;
using CoiniumServ.Server.Mining.Getwork;
-using CoiniumServ.Server.Mining.Getwork.Service;
using CoiniumServ.Server.Mining.Service;
using CoiniumServ.Server.Mining.Stratum;
-using CoiniumServ.Server.Mining.Stratum.Service;
using CoiniumServ.Server.Web;
namespace CoiniumServ.Container.Registries
diff --git a/src/CoiniumServ/Server/Mining/Getwork/Service/HttpServiceContext.cs b/src/CoiniumServ/Server/Mining/Getwork/GetworkContext.cs
similarity index 83%
rename from src/CoiniumServ/Server/Mining/Getwork/Service/HttpServiceContext.cs
rename to src/CoiniumServ/Server/Mining/Getwork/GetworkContext.cs
index 6b12ddbf3..999e2fb40 100644
--- a/src/CoiniumServ/Server/Mining/Getwork/Service/HttpServiceContext.cs
+++ b/src/CoiniumServ/Server/Mining/Getwork/GetworkContext.cs
@@ -22,17 +22,16 @@
#endregion
using System.Net;
-using CoiniumServ.Mining;
-namespace CoiniumServ.Server.Mining.Getwork.Service
+namespace CoiniumServ.Server.Mining.Getwork
{
- public class HttpServiceContext
+ public class GetworkContext
{
- public IMiner Miner { get; private set; }
+ public IGetworkMiner Miner { get; private set; }
public HttpListenerResponse Response { get; private set; }
- public HttpServiceContext(IMiner miner, HttpListenerContext context)
+ public GetworkContext(IGetworkMiner miner, HttpListenerContext context)
{
Miner = miner;
Response = context.Response;
diff --git a/src/CoiniumServ/Server/Mining/Getwork/GetworkMiner.cs b/src/CoiniumServ/Server/Mining/Getwork/GetworkMiner.cs
index 775de3e19..7c27fe59e 100644
--- a/src/CoiniumServ/Server/Mining/Getwork/GetworkMiner.cs
+++ b/src/CoiniumServ/Server/Mining/Getwork/GetworkMiner.cs
@@ -30,7 +30,6 @@
using CoiniumServ.Logging;
using CoiniumServ.Mining;
using CoiniumServ.Pools;
-using CoiniumServ.Server.Mining.Getwork.Service;
using CoiniumServ.Utils.Extensions;
using Newtonsoft.Json;
using Serilog;
@@ -97,7 +96,7 @@ public GetworkMiner(int id, IPool pool, IMinerManager minerManager)
var asyncData = ((JsonRpcStateAsync) callback);
var result = asyncData.Result;
var response = Encoding.UTF8.GetBytes(result);
- var context = (HttpServiceContext) asyncData.AsyncState;
+ var context = (GetworkContext) asyncData.AsyncState;
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
@@ -125,7 +124,7 @@ public void Parse(HttpListenerContext httpContext)
using (var reader = new StreamReader(httpRequest.InputStream, Encoding.UTF8))
{
var line = reader.ReadToEnd();
- var rpcContext = new HttpServiceContext(this, httpContext);
+ var rpcContext = new GetworkContext(this, httpContext);
_packetLogger.Verbose("rx: {0}", line.PrettifyJson());
diff --git a/src/CoiniumServ/Server/Mining/Getwork/Service/GetworkService.cs b/src/CoiniumServ/Server/Mining/Getwork/GetworkService.cs
similarity index 93%
rename from src/CoiniumServ/Server/Mining/Getwork/Service/GetworkService.cs
rename to src/CoiniumServ/Server/Mining/Getwork/GetworkService.cs
index bf93fc646..56791601b 100644
--- a/src/CoiniumServ/Server/Mining/Getwork/Service/GetworkService.cs
+++ b/src/CoiniumServ/Server/Mining/Getwork/GetworkService.cs
@@ -28,7 +28,7 @@
using CoiniumServ.Shares;
using Serilog;
-namespace CoiniumServ.Server.Mining.Getwork.Service
+namespace CoiniumServ.Server.Mining.Getwork
{
///
/// Getwork protocol implementation.
@@ -56,9 +56,6 @@ public GetworkService(IPoolConfig poolConfig, IShareManager shareManager, IDaemo
[JsonRpcMethod("getwork")]
public Daemon.Responses.Getwork Getwork(string data = null)
{
- var context = (HttpServiceContext) JsonRpcContext.Current().Value;
- var miner = (IGetworkMiner) (context.Miner);
-
// TODO: fixme! instead use jobmanager and sharemanager.
if (data == null) // if miner supplied no data
diff --git a/src/CoiniumServ/Server/Mining/Stratum/Service/SocketServiceContext.cs b/src/CoiniumServ/Server/Mining/Stratum/StratumContext.cs
similarity index 83%
rename from src/CoiniumServ/Server/Mining/Stratum/Service/SocketServiceContext.cs
rename to src/CoiniumServ/Server/Mining/Stratum/StratumContext.cs
index b08a2512b..80e2856e1 100644
--- a/src/CoiniumServ/Server/Mining/Stratum/Service/SocketServiceContext.cs
+++ b/src/CoiniumServ/Server/Mining/Stratum/StratumContext.cs
@@ -21,15 +21,13 @@
//
#endregion
-using CoiniumServ.Mining;
-
-namespace CoiniumServ.Server.Mining.Stratum.Service
+namespace CoiniumServ.Server.Mining.Stratum
{
- public class SocketServiceContext
+ public class StratumContext
{
- public IMiner Miner { get; private set; }
+ public IStratumMiner Miner { get; private set; }
- public SocketServiceContext(IMiner miner)
+ public StratumContext(IStratumMiner miner)
{
Miner = miner;
}
diff --git a/src/CoiniumServ/Server/Mining/Stratum/StratumMiner.cs b/src/CoiniumServ/Server/Mining/Stratum/StratumMiner.cs
index 1d8058655..185819f76 100644
--- a/src/CoiniumServ/Server/Mining/Stratum/StratumMiner.cs
+++ b/src/CoiniumServ/Server/Mining/Stratum/StratumMiner.cs
@@ -34,7 +34,6 @@
using CoiniumServ.Persistance.Layers;
using CoiniumServ.Pools;
using CoiniumServ.Server.Mining.Stratum.Errors;
-using CoiniumServ.Server.Mining.Stratum.Service;
using CoiniumServ.Server.Mining.Stratum.Sockets;
using CoiniumServ.Utils.Buffers;
using CoiniumServ.Utils.Extensions;
@@ -227,7 +226,7 @@ private void ProcessRequest(string line)
{
try
{
- var rpcContext = new SocketServiceContext(this); // set the context.
+ var rpcContext = new StratumContext(this); // set the context.
_packetLogger.Verbose("rx: {0}", line.PrettifyJson());
diff --git a/src/CoiniumServ/Server/Mining/Stratum/Service/StratumService.cs b/src/CoiniumServ/Server/Mining/Stratum/StratumService.cs
similarity index 78%
rename from src/CoiniumServ/Server/Mining/Stratum/Service/StratumService.cs
rename to src/CoiniumServ/Server/Mining/Stratum/StratumService.cs
index fa6ef8be4..c90db5c7f 100644
--- a/src/CoiniumServ/Server/Mining/Stratum/Service/StratumService.cs
+++ b/src/CoiniumServ/Server/Mining/Stratum/StratumService.cs
@@ -28,7 +28,7 @@
using CoiniumServ.Server.Mining.Stratum.Responses;
using CoiniumServ.Shares;
-namespace CoiniumServ.Server.Mining.Stratum.Service
+namespace CoiniumServ.Server.Mining.Stratum
{
///
/// Stratum protocol implementation.
@@ -46,20 +46,20 @@ public StratumService(IPoolConfig poolConfig, IShareManager shareManager):
///
/// Subscribes a Miner to allow it to recieve work to begin hashing and submitting shares.
///
- /// Miner Connection
+ /// software signature
+ /// optional parameter supplied by miners whom wants to reconnect and continue their old session
[JsonRpcMethod("mining.subscribe")]
- public SubscribeResponse SubscribeMiner(string signature)
+ public SubscribeResponse SubscribeMiner(string signature = null, string sessionId = null)
{
- var context = (SocketServiceContext) JsonRpcContext.Current().Value;
- var miner = (IStratumMiner)(context.Miner);
+ var context = (StratumContext) JsonRpcContext.Current().Value;
var response = new SubscribeResponse
{
- ExtraNonce1 = miner.ExtraNonce.ToString("x8"), // Hex-encoded, per-connection unique string which will be used for coinbase serialization later. (http://mining.bitcoin.cz/stratum-mining)
+ ExtraNonce1 = context.Miner.ExtraNonce.ToString("x8"), // Hex-encoded, per-connection unique string which will be used for coinbase serialization later. (http://mining.bitcoin.cz/stratum-mining)
ExtraNonce2Size = ExtraNonce.ExpectedExtraNonce2Size // Represents expected length of extranonce2 which will be generated by the miner. (http://mining.bitcoin.cz/stratum-mining)
};
- miner.Subscribe(signature);
+ context.Miner.Subscribe(signature);
return response;
}
@@ -72,10 +72,8 @@ public SubscribeResponse SubscribeMiner(string signature)
[JsonRpcMethod("mining.authorize")]
public bool AuthorizeMiner(string user, string password)
{
- var context = (SocketServiceContext)JsonRpcContext.Current().Value;
- var miner = (IStratumMiner)(context.Miner);
-
- return miner.Authenticate(user, password);
+ var context = (StratumContext)JsonRpcContext.Current().Value;
+ return context.Miner.Authenticate(user, password);
}
///
@@ -89,10 +87,8 @@ public bool AuthorizeMiner(string user, string password)
[JsonRpcMethod("mining.submit")]
public bool SubmitWork(string user, string jobId, string extraNonce2, string nTime, string nonce)
{
- var context = (SocketServiceContext)JsonRpcContext.Current().Value;
- var miner = (IStratumMiner)(context.Miner);
-
- return _shareManager.ProcessShare(miner, jobId, extraNonce2, nTime, nonce).IsValid;
+ var context = (StratumContext)JsonRpcContext.Current().Value;
+ return _shareManager.ProcessShare(context.Miner, jobId, extraNonce2, nTime, nonce).IsValid;
}
}
}
diff --git a/src/CoiniumServ/config/coins/mooncoin.json b/src/CoiniumServ/config/coins/mooncoin.json
new file mode 100644
index 000000000..a0a448606
--- /dev/null
+++ b/src/CoiniumServ/config/coins/mooncoin.json
@@ -0,0 +1,10 @@
+{
+ "name": "Mooncoin",
+ "symbol": "MOON",
+ "algorithm": "scrypt",
+ "site": "https://bitcointalk.org/index.php?topic=389403.0",
+ "blockExplorer": {
+ "block": "http://moonchain.net/block/",
+ "tx": "http://moonchain.net/tx/"
+ }
+}
\ No newline at end of file
diff --git a/src/CoiniumServ/config/coins/noblecoin.json b/src/CoiniumServ/config/coins/noblecoin.json
new file mode 100644
index 000000000..864074c06
--- /dev/null
+++ b/src/CoiniumServ/config/coins/noblecoin.json
@@ -0,0 +1,10 @@
+{
+ "name": "Noblecoin",
+ "symbol": "NOBL",
+ "algorithm": "scrypt",
+ "site": "https://www.noblemovement.com/",
+ "blockExplorer": {
+ "block": "https://chainz.cryptoid.info/nobl/block.dws?",
+ "tx": "https://chainz.cryptoid.info/nobl/tx.dws?"
+ }
+}
\ No newline at end of file
diff --git a/src/CoiniumServ/config/coins/usde.json b/src/CoiniumServ/config/coins/usde.json
new file mode 100644
index 000000000..eba7fe107
--- /dev/null
+++ b/src/CoiniumServ/config/coins/usde.json
@@ -0,0 +1,10 @@
+{
+ "name": "USDE",
+ "symbol": "USDE",
+ "algorithm": "scrypt",
+ "site": "http://usd-e.com/",
+ "blockExplorer": {
+ "block": "https://altexplorer.net/block/",
+ "tx": "https://altexplorer.net/tx/"
+ }
+}
\ No newline at end of file
diff --git a/src/CoiniumServ/packages.config b/src/CoiniumServ/packages.config
index e1c4a4e79..6a3f6cdd8 100644
--- a/src/CoiniumServ/packages.config
+++ b/src/CoiniumServ/packages.config
@@ -1,6 +1,5 @@
-
@@ -19,5 +18,5 @@
-
+
\ No newline at end of file
diff --git a/src/Tests/Banning/BanConfigTests.cs b/src/Tests/Banning/BanConfigTests.cs
index b86d46284..76ab92112 100644
--- a/src/Tests/Banning/BanConfigTests.cs
+++ b/src/Tests/Banning/BanConfigTests.cs
@@ -32,15 +32,14 @@ namespace CoiniumServ.Tests.Banning
{
public class BanConfigTests
{
- private readonly IConfigFactory _configFactory;
private readonly IJsonConfigReader _jsonConfigReader;
public BanConfigTests()
{
var kernel = TinyIoCContainer.Current;
new Bootstrapper(kernel);
- _configFactory = kernel.Resolve();
- _jsonConfigReader = _configFactory.GetJsonConfigReader();
+ var configFactory = kernel.Resolve();
+ _jsonConfigReader = configFactory.GetJsonConfigReader();
}
///
diff --git a/src/Tests/CoiniumServ.Tests.csproj b/src/Tests/CoiniumServ.Tests.csproj
index 399eef30f..34ed1ef34 100644
--- a/src/Tests/CoiniumServ.Tests.csproj
+++ b/src/Tests/CoiniumServ.Tests.csproj
@@ -72,6 +72,7 @@
+
@@ -101,6 +102,10 @@
+
+ {24fc1a2a-0bc3-43a7-9bfe-b628c2c4a307}
+ AustinHarris.JsonRpc
+
{5fca1e48-0751-4625-9532-cb804df55db5}
CoiniumServ
diff --git a/src/Tests/Server/Mining/Stratum/StratumServiceTests.cs b/src/Tests/Server/Mining/Stratum/StratumServiceTests.cs
new file mode 100644
index 000000000..a0571ef6f
--- /dev/null
+++ b/src/Tests/Server/Mining/Stratum/StratumServiceTests.cs
@@ -0,0 +1,94 @@
+#region License
+//
+// CoiniumServ - Crypto Currency Mining Pool Server Software
+// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org
+// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ
+//
+// This software is dual-licensed: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// For the terms of this license, see licenses/gpl_v3.txt.
+//
+// Alternatively, you can license this software under a commercial
+// license or white-label it as set out in licenses/commercial.txt.
+//
+#endregion
+
+using AustinHarris.JsonRpc;
+using CoiniumServ.Pools;
+using CoiniumServ.Server.Mining.Stratum;
+using CoiniumServ.Shares;
+using NSubstitute;
+using Should.Fluent;
+using Xunit;
+
+namespace CoiniumServ.Tests.Server.Mining.Stratum
+{
+ public class StratumServiceTests
+ {
+ private readonly IShareManager _shareManager;
+ private readonly IPoolConfig _poolConfig;
+ private readonly StratumContext _stratumContext;
+
+ public StratumServiceTests()
+ {
+ _shareManager = Substitute.For();
+ _poolConfig = Substitute.For();
+
+ var miner = Substitute.For();
+ _stratumContext = Substitute.For(miner);
+ }
+
+ [Fact]
+ public void MiningSubscribe_WithOutParameters_ShouldEqual()
+ {
+ _poolConfig.Coin.Name.Returns("zero-params");
+ var service = new StratumService(_poolConfig, _shareManager);
+
+ const string request = @"{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [] }";
+ const string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[[\"mining.set_difficulty\",\"0\",\"mining.notify\",\"0\"],\"00000000\",4],\"id\":1}";
+
+ var task = JsonRpcProcessor.Process(_poolConfig.Coin.Name, request,_stratumContext);
+ task.Wait();
+
+ task.Result.Should().Equal(expectedResult);
+ }
+
+ [Fact]
+ public void MiningSubscribe_WithSignature_ShouldEqual()
+ {
+ _poolConfig.Coin.Name.Returns("signature");
+ var service = new StratumService(_poolConfig, _shareManager);
+
+ const string request = @"{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [ 'cgminer/3.7.2' ] }";
+ const string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[[\"mining.set_difficulty\",\"0\",\"mining.notify\",\"0\"],\"00000000\",4],\"id\":1}";
+
+ var task = JsonRpcProcessor.Process(_poolConfig.Coin.Name, request, _stratumContext);
+ task.Wait();
+
+ task.Result.Should().Equal(expectedResult);
+ }
+
+ [Fact]
+ public void MiningSubscribe_WithSessionId_ShouldEqual()
+ {
+ _poolConfig.Coin.Name.Returns("session");
+ var service = new StratumService(_poolConfig, _shareManager);
+
+ const string request = @"{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [ 'cgminer/3.7.2', '02000000b507a8fd1ea2b7d9cdec867086f6935228aba1540154f83930377ea5a2e37108' ] }";
+ const string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[[\"mining.set_difficulty\",\"0\",\"mining.notify\",\"0\"],\"00000000\",4],\"id\":1}";
+
+ var task = JsonRpcProcessor.Process(_poolConfig.Coin.Name, request, _stratumContext);
+ task.Wait();
+
+ task.Result.Should().Equal(expectedResult);
+ }
+ }
+}