@@ -86,11 +86,12 @@
Block |
Status |
+ Time |
Amount |
- @foreach (var block in Model.Pool.Statistics.Blocks.Latest)
+ @foreach (var block in Model.Pool.BlocksCache)
{
@block.Height |
@@ -101,13 +102,14 @@
@block.Status
break;
case BlockStatus.Orphaned:
- @block.Status
+ @block.Status
break;
case BlockStatus.Confirmed:
- @block.Status
+ @block.Status
break;
}
+ @block.Time |
@block.Amount |
}
diff --git a/src/CoiniumServ/web/default/workers.cshtml b/src/CoiniumServ/web/default/workers.cshtml
index 2a99276eb..dbb3479fc 100644
--- a/src/CoiniumServ/web/default/workers.cshtml
+++ b/src/CoiniumServ/web/default/workers.cshtml
@@ -20,8 +20,8 @@
@foreach (var worker in Model.Workers)
{
- @worker.Key |
- @worker.Value |
+ @worker.Username |
+ @worker.ValidShares |
}
diff --git a/src/CoiniumServGui/app.config b/src/CoiniumServGui/app.config
index c7b49a455..314600649 100644
--- a/src/CoiniumServGui/app.config
+++ b/src/CoiniumServGui/app.config
@@ -1,7 +1,8 @@
-
-
+
+
+
diff --git a/src/Tests/App.config b/src/Tests/App.config
index 80a4170e2..43c04df14 100644
--- a/src/Tests/App.config
+++ b/src/Tests/App.config
@@ -1,27 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Tests/Banning/BanConfigTests.cs b/src/Tests/Banning/BanConfigTests.cs
new file mode 100644
index 000000000..eb4ff8ad9
--- /dev/null
+++ b/src/Tests/Banning/BanConfigTests.cs
@@ -0,0 +1,99 @@
+#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 CoiniumServ.Banning;
+using CoiniumServ.Configuration;
+using CoiniumServ.Container;
+using CoiniumServ.Factories;
+using Nancy.TinyIoc;
+using Should.Fluent;
+using Xunit;
+
+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();
+ }
+
+ ///
+ /// Tests a json file with valid configuration.
+ ///
+ [Fact]
+ public void ValidConfig_ShouldSuccess()
+ {
+ // read a valid json config sample.
+ var data = _jsonConfigReader.Read("Banning/valid-config.json");
+ var config = new BanConfig(data);
+
+ // make sure our expected values are set.
+ config.Enabled.Should().Equal(true);
+ config.Duration.Should().Equal(1);
+ config.InvalidPercent.Should().Equal(2);
+ config.CheckThreshold.Should().Equal(3);
+ config.PurgeInterval.Should().Equal(4);
+ config.Valid.Should().Equal(true);
+ }
+
+ ///
+ /// Tests a json file with valid configuration.
+ ///
+ [Fact]
+ public void InvalidConfig_ShouldReturnDefaults()
+ {
+ // read a valid json config sample.
+ var data = _jsonConfigReader.Read("invalid-config.json");
+ var config = new BanConfig(data);
+
+ // as we have just supplied an invalid config, we should get a valid config object with default values
+ config.Enabled.Should().Equal(false);
+ config.Duration.Should().Equal(600);
+ config.InvalidPercent.Should().Equal(50);
+ config.CheckThreshold.Should().Equal(100);
+ config.PurgeInterval.Should().Equal(300);
+ config.Valid.Should().Equal(true);
+ }
+
+ ///
+ /// Tests a json file with valid configuration.
+ ///
+ [Fact]
+ public void InvalidJson_ShouldBeInvalid()
+ {
+ // read a valid json config sample.
+ var data = _jsonConfigReader.Read("invalid-json.json");
+ var config = new BanConfig(data);
+
+ // as we have just supplied an invalid json, config should be just marked as invalid.
+ config.Valid.Should().Equal(false);
+ }
+ }
+}
diff --git a/src/Tests/Banning/valid-config.json b/src/Tests/Banning/valid-config.json
new file mode 100644
index 000000000..20e50dd3a
--- /dev/null
+++ b/src/Tests/Banning/valid-config.json
@@ -0,0 +1,7 @@
+{
+ "enabled": true,
+ "duration": 1,
+ "invalidPercent": 2,
+ "checkThreshold": 3,
+ "purgeInterval": 4
+}
\ No newline at end of file
diff --git a/src/Tests/Coin/Base58Test.cs b/src/Tests/Coin/Base58Test.cs
index ed44f27ee..362a02b73 100644
--- a/src/Tests/Coin/Base58Test.cs
+++ b/src/Tests/Coin/Base58Test.cs
@@ -54,7 +54,7 @@ public void TestDecode()
[Fact]
public void TestInvalidAddress()
{
- Exception ex = Assert.Throws(() => Base58.Decode("This isn't valid base58"));
+ Assert.Throws(() => Base58.Decode("This isn't valid base58"));
}
}
}
diff --git a/src/Tests/Coin/Coinbase/SerializersTests.cs b/src/Tests/Coin/Coinbase/SerializersTests.cs
index 08e161ea8..95480114d 100644
--- a/src/Tests/Coin/Coinbase/SerializersTests.cs
+++ b/src/Tests/Coin/Coinbase/SerializersTests.cs
@@ -25,12 +25,13 @@
using System.Collections.Generic;
using System.Linq;
using CoiniumServ.Coin.Coinbase;
+using CoiniumServ.Coin.Config;
using CoiniumServ.Cryptology.Algorithms;
using CoiniumServ.Daemon;
using CoiniumServ.Daemon.Responses;
using CoiniumServ.Jobs;
-using CoiniumServ.Miners;
using CoiniumServ.Payments;
+using CoiniumServ.Pools;
using CoiniumServ.Transactions;
using CoiniumServ.Transactions.Script;
using CoiniumServ.Utils.Extensions;
@@ -137,8 +138,20 @@ public SerializerTests()
_outputs = Substitute.For(_daemonClient);
double blockReward = 5000000000; // the amount rewarded by the block.
- // sample reward recipient
+ // pool config
+ var poolConfig = Substitute.For();
+
+ // create coin config.
+ var coinConfig = Substitute.For();
+ coinConfig.SupportsTxMessages.Returns(false);
+ coinConfig.IsPOS.Returns(false);
+ poolConfig.Coin.Returns(coinConfig);
+
+ // create rewards config.
var rewardsConfig = Substitute.For();
+ poolConfig.Rewards.Returns(rewardsConfig);
+
+ // create sample reward
var amount = blockReward * 0.01;
blockReward -= amount;
var rewards = new Dictionary { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } };
@@ -149,15 +162,16 @@ public SerializerTests()
_outputs.AddRecipient(pair.Key, pair.Value);
}
- // sample pool wallet
+ // create wallet config.
var walletConfig = Substitute.For();
+ poolConfig.Wallet.Returns(walletConfig);
+
+ // create sample pool central wallet output.
walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq");
_outputs.AddPoolWallet(walletConfig.Adress, blockReward);
-
- var metaConfig = Substitute.For();
// generation transaction.
- _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, walletConfig, rewardsConfig, metaConfig, false);
+ _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, poolConfig);
_generationTransaction.Inputs.First().SignatureScript = _signatureScript;
_generationTransaction.Outputs = _outputs;
_generationTransaction.Create();
diff --git a/src/Tests/Jobs/JobTests.cs b/src/Tests/Jobs/JobTests.cs
index a54049914..345289e5f 100644
--- a/src/Tests/Jobs/JobTests.cs
+++ b/src/Tests/Jobs/JobTests.cs
@@ -24,12 +24,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using CoiniumServ.Coin.Config;
using CoiniumServ.Cryptology.Algorithms;
using CoiniumServ.Daemon;
using CoiniumServ.Daemon.Responses;
using CoiniumServ.Jobs;
-using CoiniumServ.Miners;
using CoiniumServ.Payments;
+using CoiniumServ.Pools;
using CoiniumServ.Transactions;
using CoiniumServ.Transactions.Script;
using Newtonsoft.Json;
@@ -96,6 +97,7 @@ public class JobTests
private readonly IJobCounter _jobCounter;
private readonly IHashAlgorithm _hashAlgorithm;
private readonly IGenerationTransaction _generationTransaction;
+ private readonly IPoolConfig _poolConfig;
public JobTests()
{
@@ -123,8 +125,20 @@ public JobTests()
_outputs = Substitute.For(_daemonClient);
double blockReward = 5000000000; // the amount rewarded by the block.
- // sample reward recipient
+ // pool config
+ _poolConfig = Substitute.For();
+
+ // create coin config.
+ var coinConfig = Substitute.For();
+ coinConfig.SupportsTxMessages.Returns(false);
+ coinConfig.IsPOS.Returns(false);
+ _poolConfig.Coin.Returns(coinConfig);
+
+ // create rewards config.
var rewardsConfig = Substitute.For();
+ _poolConfig.Rewards.Returns(rewardsConfig);
+
+ // create sample reward
var amount = blockReward * 0.01;
blockReward -= amount;
var rewards = new Dictionary { {"mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float) amount} };
@@ -135,25 +149,25 @@ public JobTests()
_outputs.AddRecipient(pair.Key, pair.Value);
}
- // sample pool wallet
+ // create wallet config.
var walletConfig = Substitute.For();
+ _poolConfig.Wallet.Returns(walletConfig);
+
+ // create sample pool central wallet output.
walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq");
_outputs.AddPoolWallet(walletConfig.Adress, blockReward);
- // meta config.
- var metaConfig = Substitute.For();
-
// job counter
_jobCounter = Substitute.For();
// generation transaction.
- _generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, walletConfig, rewardsConfig, metaConfig, false);
+ _generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, _poolConfig);
_generationTransaction.Inputs.First().SignatureScript = _signatureScript;
_generationTransaction.Outputs = _outputs;
_generationTransaction.Create();
// hash algorithm
- _hashAlgorithm = Substitute.For();
+ _hashAlgorithm = new Scrypt();
}
[Fact]
diff --git a/src/Tests/Pools/PoolTests.cs b/src/Tests/Pools/PoolTests.cs
index c8cb5ee39..fe99d5a82 100644
--- a/src/Tests/Pools/PoolTests.cs
+++ b/src/Tests/Pools/PoolTests.cs
@@ -26,7 +26,6 @@
using CoiniumServ.Daemon.Responses;
using CoiniumServ.Factories;
using CoiniumServ.Pools;
-using CoiniumServ.Pools.Config;
using NSubstitute;
using Should.Fluent;
using Xunit;
@@ -77,19 +76,15 @@ public void ConstructorTest_NonNullParams_ShouldSuccess()
[Fact]
public void ConstructorTest_NullParams_ShouldThrowException()
{
- var configException = Assert.Throws(() =>
+ Assert.Throws(() =>
{
- var pool = new Pool(null, _objectFactory);
- });
+ new Pool(null, _objectFactory);
+ }).Message.Should().Contain("poolConfig");
- configException.Message.Should().Contain("poolConfig");
-
- var factoryException = Assert.Throws(() =>
+ Assert.Throws(() =>
{
- var pool = new Pool(_config, null);
- });
-
- factoryException.Message.Should().Contain("objectFactory");
+ new Pool(_config, null);
+ }).Message.Should().Contain("objectFactory");
}
}
}
diff --git a/src/Tests/Shares/ShareTests.cs b/src/Tests/Shares/ShareTests.cs
index 4ffd66088..9d4b47248 100644
--- a/src/Tests/Shares/ShareTests.cs
+++ b/src/Tests/Shares/ShareTests.cs
@@ -24,14 +24,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using CoiniumServ.Coin.Config;
using CoiniumServ.Cryptology.Algorithms;
using CoiniumServ.Daemon;
using CoiniumServ.Daemon.Responses;
using CoiniumServ.Jobs;
using CoiniumServ.Jobs.Manager;
using CoiniumServ.Jobs.Tracker;
-using CoiniumServ.Miners;
using CoiniumServ.Payments;
+using CoiniumServ.Pools;
using CoiniumServ.Server.Mining.Stratum;
using CoiniumServ.Shares;
using CoiniumServ.Transactions;
@@ -122,8 +123,19 @@ public ShareTests()
_outputs = Substitute.For(_daemonClient);
double blockReward = 5000000000; // the amount rewarded by the block.
- // sample reward recipient
+ // pool config
+ var poolConfig = Substitute.For();
+
+ // create coin config.
+ var coinConfig = Substitute.For();
+ coinConfig.SupportsTxMessages.Returns(false);
+ coinConfig.IsPOS.Returns(false);
+ poolConfig.Coin.Returns(coinConfig);
+
+ // create rewards config.
var rewardsConfig = Substitute.For();
+ poolConfig.Rewards.Returns(rewardsConfig);
+
var amount = blockReward * 0.01;
blockReward -= amount;
var rewards = new Dictionary { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } };
@@ -134,21 +146,22 @@ public ShareTests()
_outputs.AddRecipient(pair.Key, pair.Value);
}
- // sample pool wallet
+ // create wallet config.
var walletConfig = Substitute.For();
+ poolConfig.Wallet.Returns(walletConfig);
+
+ // create sample pool central wallet output.
walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq");
_outputs.AddPoolWallet(walletConfig.Adress, blockReward);
- var metaConfig = Substitute.For();
-
// generation transaction
- _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, walletConfig, rewardsConfig, metaConfig, false);
+ _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, poolConfig);
_generationTransaction.Inputs.First().SignatureScript = _signatureScript;
_generationTransaction.Outputs = _outputs;
_generationTransaction.Create();
// hash algorithm
- _hashAlgorithm = Substitute.For();
+ _hashAlgorithm = new Scrypt();
// the job.
_job = new Job(2,_hashAlgorithm, _blockTemplate, _generationTransaction)
diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj
index dcc7b929a..fc029d403 100644
--- a/src/Tests/Tests.csproj
+++ b/src/Tests/Tests.csproj
@@ -39,6 +39,10 @@
False
..\..\build\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll
+
+ False
+ ..\..\build\packages\Nancy.0.23.2\lib\net40\Nancy.dll
+
False
..\..\build\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll
@@ -61,6 +65,7 @@
+
@@ -80,13 +85,18 @@
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
-
- {047857ba-daa3-4ca7-afb8-a1b082b28c6a}
- Gibbed.IO
-
{5fca1e48-0751-4625-9532-cb804df55db5}
CoiniumServ
diff --git a/src/Tests/Transactions/GenerationTransactionTests.cs b/src/Tests/Transactions/GenerationTransactionTests.cs
index 94ae2e2ac..469e1a0ed 100644
--- a/src/Tests/Transactions/GenerationTransactionTests.cs
+++ b/src/Tests/Transactions/GenerationTransactionTests.cs
@@ -24,11 +24,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using CoiniumServ.Coin.Config;
using CoiniumServ.Daemon;
using CoiniumServ.Daemon.Responses;
using CoiniumServ.Jobs;
-using CoiniumServ.Miners;
using CoiniumServ.Payments;
+using CoiniumServ.Pools;
using CoiniumServ.Transactions;
using CoiniumServ.Transactions.Script;
using CoiniumServ.Utils.Extensions;
@@ -72,6 +73,8 @@
namespace CoiniumServ.Tests.Transactions
{
+ // TODO: tests below target non-POS coins with no txMessage support. Implement tests for those specific conditions too.
+
public class GenerationTransactionTests
{
// object mocks.
@@ -80,9 +83,7 @@ public class GenerationTransactionTests
private readonly IExtraNonce _extraNonce;
private readonly ISignatureScript _signatureScript;
private readonly IOutputs _outputs;
- private readonly IWalletConfig _walletConfig;
- private readonly IRewardsConfig _rewardsConfig;
- private readonly IMetaConfig _metaConfig;
+ private readonly IPoolConfig _poolConfig;
public GenerationTransactionTests()
{
@@ -110,32 +111,44 @@ public GenerationTransactionTests()
_outputs = Substitute.For(_daemonClient);
double blockReward = 5000000000; // the amount rewarded by the block.
- // sample reward recipient
- _rewardsConfig = Substitute.For();
+ // pool config
+ _poolConfig = Substitute.For();
+
+ // create coin config.
+ var coinConfig = Substitute.For();
+ coinConfig.SupportsTxMessages.Returns(false);
+ coinConfig.IsPOS.Returns(false);
+ _poolConfig.Coin.Returns(coinConfig);
+
+ // create rewards config.
+ var rewardsConfig = Substitute.For();
+ _poolConfig.Rewards.Returns(rewardsConfig);
+
+ // create sample reward
var amount = blockReward * 0.01;
blockReward -= amount;
var rewards = new Dictionary { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } };
- _rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator());
+ rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator());
foreach (var pair in rewards)
{
_outputs.AddRecipient(pair.Key, pair.Value);
}
- // sample pool wallet
- _walletConfig = Substitute.For();
- _walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq");
- _outputs.AddPoolWallet(_walletConfig.Adress, blockReward);
+ // create wallet config.
+ var walletConfig = Substitute.For();
+ _poolConfig.Wallet.Returns(walletConfig);
- // sample meta config
- _metaConfig = Substitute.For();
+ // create sample pool central wallet output.
+ walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq");
+ _outputs.AddPoolWallet(walletConfig.Adress, blockReward);
}
[Fact]
public void CreateGenerationTransactionTest()
{
// create the test object.
- var generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, _walletConfig, _rewardsConfig, _metaConfig, false);
+ var generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, _poolConfig);
// use the exactly same input script data within our sample data.
generationTransaction.Inputs.First().SignatureScript = _signatureScript;
diff --git a/src/Tests/invalid-config.json b/src/Tests/invalid-config.json
new file mode 100644
index 000000000..8593c62d9
--- /dev/null
+++ b/src/Tests/invalid-config.json
@@ -0,0 +1,2 @@
+{
+}
\ No newline at end of file
diff --git a/src/Tests/invalid-json.json b/src/Tests/invalid-json.json
new file mode 100644
index 000000000..b7cf0b223
--- /dev/null
+++ b/src/Tests/invalid-json.json
@@ -0,0 +1 @@
+this is an invalid json file used for test
\ No newline at end of file
diff --git a/src/Tests/packages.config b/src/Tests/packages.config
index f615f09fa..b692ddcf5 100644
--- a/src/Tests/packages.config
+++ b/src/Tests/packages.config
@@ -1,6 +1,7 @@
+