Commit d853238b authored by Sergei Zubov's avatar Sergei Zubov

Fix tests

parent 07ea7d89
...@@ -17,14 +17,6 @@ namespace DeStream.Stratis.Bitcoin.Configuration ...@@ -17,14 +17,6 @@ namespace DeStream.Stratis.Bitcoin.Configuration
/// </summary> /// </summary>
public class DeStreamNodeSettings : NodeSettings public class DeStreamNodeSettings : NodeSettings
{ {
/// <summary>
/// Returns default data root directory name
/// </summary>
protected override string DataRootDirName
{
get { return "DeStreamNode"; }
}
/// <summary> /// <summary>
/// Initializes a new instance of the object. /// Initializes a new instance of the object.
/// </summary> /// </summary>
...@@ -33,8 +25,8 @@ namespace DeStream.Stratis.Bitcoin.Configuration ...@@ -33,8 +25,8 @@ namespace DeStream.Stratis.Bitcoin.Configuration
/// <param name="agent">The nodes user agent that will be shared with peers.</param> /// <param name="agent">The nodes user agent that will be shared with peers.</param>
public DeStreamNodeSettings(Network innerNetwork = null, ProtocolVersion protocolVersion = SupportedProtocolVersion, public DeStreamNodeSettings(Network innerNetwork = null, ProtocolVersion protocolVersion = SupportedProtocolVersion,
string agent = "DeStream", string[] args = null, bool loadConfiguration = true) string agent = "DeStream", string[] args = null, bool loadConfiguration = true)
: base (innerNetwork, protocolVersion, agent, args) : base ("DeStreamNode", innerNetwork, protocolVersion, agent, args)
{ {
} }
} }
} }
\ No newline at end of file
...@@ -181,11 +181,11 @@ namespace NBitcoin.Networks ...@@ -181,11 +181,11 @@ namespace NBitcoin.Networks
this.DNSSeeds = new List<DNSSeedData> this.DNSSeeds = new List<DNSSeedData>
{ {
new DNSSeedData("seed1.destream.io", "seed1.destream.io"), // new DNSSeedData("seed1.destream.io", "seed1.destream.io"),
new DNSSeedData("seed2.destream.io", "seed2.destream.io") // new DNSSeedData("seed2.destream.io", "seed2.destream.io")
}; };
string[] seedNodes = {"13.68.198.162", "13.70.18.104"}; string[] seedNodes = {/*"13.68.198.162", "13.70.18.104"*/};
this.SeedNodes = this.ConvertToNetworkAddresses(seedNodes, this.DefaultPort).ToList(); this.SeedNodes = this.ConvertToNetworkAddresses(seedNodes, this.DefaultPort).ToList();
// Create the genesis block. // Create the genesis block.
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Api.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Api.Tests</AssemblyName>
...@@ -7,27 +6,23 @@ ...@@ -7,27 +6,23 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
......
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
using NBitcoin; using NBitcoin;
using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Configuration.Settings;
using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus;
using Xunit; using Xunit;
namespace Stratis.Bitcoin.Features.Consensus.Tests namespace Stratis.Bitcoin.Tests.Consensus
{ {
public class CheckPointsTest public class CheckPointsTest
{ {
...@@ -19,7 +17,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -19,7 +17,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(); var checkpoints = new Checkpoints();
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(0, result); Assert.Equal(0, result);
} }
...@@ -29,7 +27,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -29,7 +27,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = false }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = false });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(0, result); Assert.Equal(0, result);
} }
...@@ -39,7 +37,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -39,7 +37,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(491800, result); Assert.Equal(491800, result);
} }
...@@ -49,7 +47,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -49,7 +47,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.TestNet, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.TestNet, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(1210000, result); Assert.Equal(1210000, result);
} }
...@@ -59,7 +57,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -59,7 +57,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.RegTest, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.RegTest, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(0, result); Assert.Equal(0, result);
} }
...@@ -69,9 +67,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -69,9 +67,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(576000, result); Assert.Equal(850000, result);
} }
[Fact] [Fact]
...@@ -79,9 +77,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -79,9 +77,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.StratisTest, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisTest, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(163000, result); Assert.Equal(400000, result);
} }
[Fact] [Fact]
...@@ -89,7 +87,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -89,7 +87,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.StratisRegTest, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisRegTest, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(0, result); Assert.Equal(0, result);
} }
...@@ -100,7 +98,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -100,7 +98,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
var consensusSettings = new ConsensusSettings() { UseCheckpoints = false }; var consensusSettings = new ConsensusSettings() { UseCheckpoints = false };
var checkpoints = new Checkpoints(Network.Main, consensusSettings); var checkpoints = new Checkpoints(Network.Main, consensusSettings);
var result = checkpoints.GetLastCheckpointHeight(); int result = checkpoints.GetLastCheckpointHeight();
Assert.Equal(0, result); Assert.Equal(0, result);
consensusSettings.UseCheckpoints = true; consensusSettings.UseCheckpoints = true;
...@@ -114,7 +112,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -114,7 +112,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(); var checkpoints = new Checkpoints();
var result = checkpoints.GetCheckpoint(11111); CheckpointInfo result = checkpoints.GetCheckpoint(11111);
Assert.Null(result); Assert.Null(result);
} }
...@@ -124,7 +122,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -124,7 +122,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetCheckpoint(11111); CheckpointInfo result = checkpoints.GetCheckpoint(11111);
Assert.Equal(new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"), result.Hash); Assert.Equal(new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"), result.Hash);
Assert.Null(result.StakeModifierV2); Assert.Null(result.StakeModifierV2);
...@@ -135,7 +133,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -135,7 +133,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetCheckpoint(2); CheckpointInfo result = checkpoints.GetCheckpoint(2);
Assert.Equal(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), result.Hash); Assert.Equal(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), result.Hash);
Assert.Equal(new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e"), result.StakeModifierV2); Assert.Equal(new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e"), result.StakeModifierV2);
...@@ -146,7 +144,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -146,7 +144,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.GetCheckpoint(11112); CheckpointInfo result = checkpoints.GetCheckpoint(11112);
Assert.Null(result); Assert.Null(result);
} }
...@@ -157,7 +155,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -157,7 +155,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
var consensusSettings = new ConsensusSettings() { UseCheckpoints = false }; var consensusSettings = new ConsensusSettings() { UseCheckpoints = false };
var checkpoints = new Checkpoints(Network.Main, consensusSettings); var checkpoints = new Checkpoints(Network.Main, consensusSettings);
var result = checkpoints.GetCheckpoint(11112); CheckpointInfo result = checkpoints.GetCheckpoint(11112);
Assert.Null(result); Assert.Null(result);
consensusSettings.UseCheckpoints = true; consensusSettings.UseCheckpoints = true;
...@@ -173,7 +171,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -173,7 +171,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
var consensusSettings = new ConsensusSettings() { UseCheckpoints = false }; var consensusSettings = new ConsensusSettings() { UseCheckpoints = false };
var checkpoints = new Checkpoints(Network.Main, consensusSettings); var checkpoints = new Checkpoints(Network.Main, consensusSettings);
var result = checkpoints.CheckHardened(11111, new uint256("0x0000000059e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1e")); // invalid hash bool result = checkpoints.CheckHardened(11111, new uint256("0x0000000059e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1e")); // invalid hash
Assert.True(result); Assert.True(result);
consensusSettings.UseCheckpoints = true; consensusSettings.UseCheckpoints = true;
...@@ -187,7 +185,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -187,7 +185,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.CheckHardened(11111, new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")); bool result = checkpoints.CheckHardened(11111, new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"));
Assert.True(result); Assert.True(result);
} }
...@@ -197,7 +195,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -197,7 +195,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.CheckHardened(11111, new uint256("0x0000000059e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1e")); bool result = checkpoints.CheckHardened(11111, new uint256("0x0000000059e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1e"));
Assert.False(result); Assert.False(result);
} }
...@@ -207,7 +205,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -207,7 +205,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.Main, new ConsensusSettings() { UseCheckpoints = true });
var result = checkpoints.CheckHardened(11112, new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e")); bool result = checkpoints.CheckHardened(11112, new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e"));
Assert.True(result); Assert.True(result);
} }
...@@ -217,7 +215,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -217,7 +215,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ {
var checkpoints = new Checkpoints(); var checkpoints = new Checkpoints();
var result = checkpoints.CheckHardened(11111, new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")); bool result = checkpoints.CheckHardened(11111, new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"));
Assert.True(result); Assert.True(result);
} }
...@@ -225,7 +223,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -225,7 +223,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
[Fact] [Fact]
public void VerifyCheckpoints_BitcoinMainnet() public void VerifyCheckpoints_BitcoinMainnet()
{ {
Dictionary<int, CheckpointInfo> verifyableCheckpoints = new Dictionary<int, CheckpointInfo> var verifyableCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 11111, new CheckpointInfo(new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) }, { 11111, new CheckpointInfo(new uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) },
{ 33333, new CheckpointInfo(new uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) }, { 33333, new CheckpointInfo(new uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) },
...@@ -252,7 +250,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -252,7 +250,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
[Fact] [Fact]
public void VerifyCheckpoints_BitcoinTestnet() public void VerifyCheckpoints_BitcoinTestnet()
{ {
Dictionary<int, CheckpointInfo> verifyableCheckpoints = new Dictionary<int, CheckpointInfo> var verifyableCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 546, new CheckpointInfo(new uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")) }, { 546, new CheckpointInfo(new uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")) },
{ 1210000, new CheckpointInfo(new uint256("00000000461201277cf8c635fc10d042d6f0a7eaa57f6c9e8c099b9e0dbc46dc")) }, { 1210000, new CheckpointInfo(new uint256("00000000461201277cf8c635fc10d042d6f0a7eaa57f6c9e8c099b9e0dbc46dc")) },
...@@ -266,16 +264,16 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -266,16 +264,16 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
[Fact] [Fact]
public void VerifyCheckpoints_StratisMainnet() public void VerifyCheckpoints_StratisMainnet()
{ {
Dictionary<int, CheckpointInfo> verifyableCheckpoints = new Dictionary<int, CheckpointInfo> var verifyableCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 0, new CheckpointInfo(new uint256("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, { 0, new CheckpointInfo(new uint256("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) },
{ 2, new CheckpointInfo(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e")) }, { 2, new CheckpointInfo(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e")) }, // Premine
{ 50, new CheckpointInfo(new uint256("0x0353b43f4ce80bf24578e7c0141d90d7962fb3a4b4b4e5a17925ca95e943b816"), new uint256("0x7c2af3b10d13f9d2bc6063baaf7f0860d90d870c994378144f9bf85d0d555061")) }, { 50, new CheckpointInfo(new uint256("0x0353b43f4ce80bf24578e7c0141d90d7962fb3a4b4b4e5a17925ca95e943b816"), new uint256("0x7c2af3b10d13f9d2bc6063baaf7f0860d90d870c994378144f9bf85d0d555061")) },
{ 100, new CheckpointInfo(new uint256("0x688468a8aa48cd1c2197e42e7d8acd42760b7e2ac4bcab9d18ac149a673e16f6"), new uint256("0xcf2b1e9e76aaa3d96f255783eb2d907bf6ccb9c1deeb3617149278f0e4a1ab1b")) }, { 100, new CheckpointInfo(new uint256("0x688468a8aa48cd1c2197e42e7d8acd42760b7e2ac4bcab9d18ac149a673e16f6"), new uint256("0xcf2b1e9e76aaa3d96f255783eb2d907bf6ccb9c1deeb3617149278f0e4a1ab1b")) },
{ 150, new CheckpointInfo(new uint256("0xe4ae9663519abec15e28f68bdb2cb89a739aee22f53d1573048d69141db6ee5d"), new uint256("0xa6c17173e958dc716cc0892ce33dad8bc327963d78a16c436264ceae43d584ce")) }, { 150, new CheckpointInfo(new uint256("0xe4ae9663519abec15e28f68bdb2cb89a739aee22f53d1573048d69141db6ee5d"), new uint256("0xa6c17173e958dc716cc0892ce33dad8bc327963d78a16c436264ceae43d584ce")) },
{ 127500, new CheckpointInfo(new uint256("0x4773ca7512489df22de03aa03938412fab5b46154b05df004b97bcbeaa184078"), new uint256("0x619743c02ebaff06b90fcc5c60c52dba8aa3fdb6ba3800aae697cbb3c5483f17")) }, { 127500, new CheckpointInfo(new uint256("0x4773ca7512489df22de03aa03938412fab5b46154b05df004b97bcbeaa184078"), new uint256("0x619743c02ebaff06b90fcc5c60c52dba8aa3fdb6ba3800aae697cbb3c5483f17")) },
{ 128943, new CheckpointInfo(new uint256("0x36bcaa27a53d3adf22b2064150a297adb02ac39c24263a5ceb73856832d49679"), new uint256("0xa3a6fd04e41fcaae411a3990aaabcf5e086d2d06c72c849182b27b4de8c2c42a")) }, { 128943, new CheckpointInfo(new uint256("0x36bcaa27a53d3adf22b2064150a297adb02ac39c24263a5ceb73856832d49679"), new uint256("0xa3a6fd04e41fcaae411a3990aaabcf5e086d2d06c72c849182b27b4de8c2c42a")) },
{ 136601, new CheckpointInfo(new uint256("0xf5c5210c55ff1ef9c04715420a82728e1647f3473e31dc478b3745a97b4a6d10"), new uint256("0x42058fabe21f7b118a9e358eaf9ef574dadefd024244899e71f2f6d618161e16")) }, { 136601, new CheckpointInfo(new uint256("0xf5c5210c55ff1ef9c04715420a82728e1647f3473e31dc478b3745a97b4a6d10"), new uint256("0x42058fabe21f7b118a9e358eaf9ef574dadefd024244899e71f2f6d618161e16")) }, // Hardfork to V2 - Drifting Bug Fix
{ 170000, new CheckpointInfo(new uint256("0x22b10952e0cf7e85bfc81c38f1490708f195bff34d2951d193cc20e9ca1fc9d5"), new uint256("0xa4942a6c99cba397cf2b18e4b912930fe1e64a7413c3d97c5a926c2af9073091")) }, { 170000, new CheckpointInfo(new uint256("0x22b10952e0cf7e85bfc81c38f1490708f195bff34d2951d193cc20e9ca1fc9d5"), new uint256("0xa4942a6c99cba397cf2b18e4b912930fe1e64a7413c3d97c5a926c2af9073091")) },
{ 200000, new CheckpointInfo(new uint256("0x2391dd493be5d0ff0ef57c3b08c73eefeecc2701b80f983054bb262f7a146989"), new uint256("0x253152d129e82c30c584197deb6833502eff3ec2f30014008f75842d7bb48453")) }, { 200000, new CheckpointInfo(new uint256("0x2391dd493be5d0ff0ef57c3b08c73eefeecc2701b80f983054bb262f7a146989"), new uint256("0x253152d129e82c30c584197deb6833502eff3ec2f30014008f75842d7bb48453")) },
{ 250000, new CheckpointInfo(new uint256("0x681c70fab7c1527246138f0cf937f0eb013838b929fbe9a831af02a60fc4bf55"), new uint256("0x24eed95e00c90618aa9d137d2ee273267285c444c9cde62a25a3e880c98a3685")) }, { 250000, new CheckpointInfo(new uint256("0x681c70fab7c1527246138f0cf937f0eb013838b929fbe9a831af02a60fc4bf55"), new uint256("0x24eed95e00c90618aa9d137d2ee273267285c444c9cde62a25a3e880c98a3685")) },
...@@ -283,8 +281,16 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -283,8 +281,16 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
{ 350000, new CheckpointInfo(new uint256("0xe2b76d1a068c4342f91db7b89b66e0f2146d3a4706c21f3a262737bb7339253a"), new uint256("0xd1dd94985eaaa028c893687a7ddf89143dcf0176918f958c2d01f33d64910399")) }, { 350000, new CheckpointInfo(new uint256("0xe2b76d1a068c4342f91db7b89b66e0f2146d3a4706c21f3a262737bb7339253a"), new uint256("0xd1dd94985eaaa028c893687a7ddf89143dcf0176918f958c2d01f33d64910399")) },
{ 390000, new CheckpointInfo(new uint256("0x4682737abc2a3257fdf4c3c119deb09cbac75981969e2ffa998b4f76b7c657bb"), new uint256("0xd84b204ee94499ff65262328a428851fb4f4d2741e928cdd088fdf1deb5413b8")) }, { 390000, new CheckpointInfo(new uint256("0x4682737abc2a3257fdf4c3c119deb09cbac75981969e2ffa998b4f76b7c657bb"), new uint256("0xd84b204ee94499ff65262328a428851fb4f4d2741e928cdd088fdf1deb5413b8")) },
{ 394000, new CheckpointInfo(new uint256("0x42857fa2bc15d45cdcaae83411f755b95985da1cb464ee23f6d40936df523e9f"), new uint256("0x2314b336906a2ed2a39cbdf6fc0622530709c62dbb3a3729de17154fc9d1a7c4")) }, { 394000, new CheckpointInfo(new uint256("0x42857fa2bc15d45cdcaae83411f755b95985da1cb464ee23f6d40936df523e9f"), new uint256("0x2314b336906a2ed2a39cbdf6fc0622530709c62dbb3a3729de17154fc9d1a7c4")) },
{ 528000, new CheckpointInfo(new uint256("0x7aff2c48b398446595d01e27b5cd898087cec63f94ff73f9ad695c6c9bcee33a"), new uint256("0x3bdc865661390c7681b078e52ed3ad3c53ec7cff97b8c45b74abed3ace289fcc")) }, { 400000, new CheckpointInfo(new uint256("0x4938d5cf450b4e2d9072558971223555055aa3987b634a8bb2e97f95d1a3c501"), new uint256("0x1756c127f0ac7029cf095a6c3ed9b7d206d0e36744d8b3cef306002f9f901a31")) },
{ 576000, new CheckpointInfo(new uint256("0xe705476b940e332098d1d5b475d7977312ff8c08cbc8256ce46a3e2c6d5408b8"), new uint256("0x10e31bb5e245ea19650280cfd3ac1a76259fa0002d02e861d2ab5df290534b56")) }, { 450000, new CheckpointInfo(new uint256("0x7699e07ac18c25ac042deb6b985e2decfd6034cb6361de2152a2d704ef785bac"), new uint256("0xa140a86a03c4f852d8a651f6386a02a0262e7bbf841ede8b54541c011c51ba0e")) },
{ 500000, new CheckpointInfo(new uint256("0x558700d99239e64017d10910466719fe1edc6f863bd3de254b89ba828818ea47"), new uint256("0x6a0b7dab4a7aa9ea2477cddffe5a976c9423454835054a39c19d37613002638f")) },
{ 550000, new CheckpointInfo(new uint256("0x83d074957f509772b1fbbfaeb7bdc52932c540d54e205b92a7d4e92f68957eb4"), new uint256("0x012b63ad7d50606f2cafb1a7806ea90f4981c56b5407725aeeff34e3c584433c")) },
{ 600000, new CheckpointInfo(new uint256("0xcd05c75c0c47060d78508095c0766452f80e2defb6a4641ac603742a2ccf2207"), new uint256("0x1f25507e09b199a71d5879811376856e5fb3da1da3d522204c017eec3b6c4dad")) },
{ 650000, new CheckpointInfo(new uint256("0xa2814a439b33662f43bdbc8ab089d368524975bb53a08326395e57456cba8d39"), new uint256("0x192a2ef70e2280cf05aa5655f496a109b2445d0ddda62531e9bce9aaced1fe54")) },
{ 700000, new CheckpointInfo(new uint256("0x782b2506bb67bb448ff56aa946f7aad6b63a6b27d8c5818725a56b568f25b9ce"), new uint256("0xf23dc64b130d80790a83a86913f619afaeef10e1fd24e4b42af9387ec935edd6")) },
{ 750000, new CheckpointInfo(new uint256("0x4db98bd41a2f9ee845cc89ac03109686f615f4d0dcd81e0488005c1616fa692c"), new uint256("0x9f620af75bc27a0e4b503deaf7f052ba112a49bb74fb6446350642bc2ac9d93b")) },
{ 800000, new CheckpointInfo(new uint256("0x161da1d97d35d6897dbdae110617bb839805f8b02d33ac23d227a87cacbfac78"), new uint256("0xe95049a313345f26bfa90094ceb6400f43359fc43fc5f1471918d98bc4ab3bac")) },
{ 850000, new CheckpointInfo(new uint256("0xc3a249b01795b22858aa00fd0973471fcd769a14f4f9cf0abe6651ac3e6ade19"), new uint256("0x5de8766ed4cfcc3ce9d74f38196596c6f91b9ff62cbd20abbfa991dca54d2bd4")) }
}; };
var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisMain, new ConsensusSettings() { UseCheckpoints = true });
...@@ -295,14 +301,18 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -295,14 +301,18 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
[Fact] [Fact]
public void VerifyCheckpoints_StratisTestnet() public void VerifyCheckpoints_StratisTestnet()
{ {
Dictionary<int, CheckpointInfo> verifyableCheckpoints = new Dictionary<int, CheckpointInfo> var verifyableCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 0, new CheckpointInfo(new uint256("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, { 0, new CheckpointInfo(new uint256("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) },
{ 2, new CheckpointInfo(new uint256("0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"), new uint256("0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02")) }, { 2, new CheckpointInfo(new uint256("0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"), new uint256("0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02")) },
{ 50000, new CheckpointInfo(new uint256("0xb42c18eacf8fb5ed94eac31943bd364451d88da0fd44cc49616ffea34d530ad4"), new uint256("0x824934ddc5f935e854ac59ae7f5ed25f2d29a7c3914cac851f3eddb4baf96d78")) }, { 50000, new CheckpointInfo(new uint256("0xb42c18eacf8fb5ed94eac31943bd364451d88da0fd44cc49616ffea34d530ad4"), new uint256("0x824934ddc5f935e854ac59ae7f5ed25f2d29a7c3914cac851f3eddb4baf96d78")) },
{ 100000, new CheckpointInfo(new uint256("0xf9e2f7561ee4b92d3bde400d251363a0e8924204c326da7f4ad9ccc8863aad79"), new uint256("0xdef8d92d20becc71f662ee1c32252aca129f1bf4744026b116d45d9bfe67e9fb")) }, { 100000, new CheckpointInfo(new uint256("0xf9e2f7561ee4b92d3bde400d251363a0e8924204c326da7f4ad9ccc8863aad79"), new uint256("0xdef8d92d20becc71f662ee1c32252aca129f1bf4744026b116d45d9bfe67e9fb")) },
{ 115000, new CheckpointInfo(new uint256("0x8496c77060c8a2b5c9a888ade991f25aa33c232b4413594d556daf9043fad400"), new uint256("0x1886430484a9a36b56a7eb8bd25e9ebe4fc8eec8f9a84f5073f71e08f2feac90")) }, { 150000, new CheckpointInfo(new uint256("0x08b7c20a450252ddf9ce41dbeb92ecf54932beac9090dc8250e933ad3a175381"), new uint256("0xf05dad15f733ae0acbd34adc449be9429099dbee5fa9ecd8e524cf28e9153adb")) },
{ 163000, new CheckpointInfo(new uint256("0x4e44a9e0119a2e7cbf15e570a3c649a5605baa601d953a465b5ebd1c1982212a"), new uint256("0x0646fc7db8f3426eb209e1228c7d82724faa46a060f5bbbd546683ef30be245c")) }, { 200000, new CheckpointInfo(new uint256("0x8609cc873222a0573615788dc32e377b88bfd6a0015791f627d969ee3a415115"), new uint256("0xfa28c1f20a8162d133607c6a1c8997833befac3efd9076567258a7683ac181fa")) },
{ 250000, new CheckpointInfo(new uint256("0xdd664e15ac679a6f3b96a7176303956661998174a697ad8231f154f1e32ff4a3"), new uint256("0x19fc0fa29418f8b19cbb6557c1c79dfd0eff6779c0eaaec5d245c5cdf3c96d78")) },
{ 300000, new CheckpointInfo(new uint256("0x2409eb5ae72c80d5b37c77903d75a8e742a33843ab633935ce6e5264db962e23"), new uint256("0xf5ec7af55516b8e264ed280e9a5dba0180a4a9d3713351bfea275b18f3f1514e")) },
{ 350000, new CheckpointInfo(new uint256("0x36811041e9060f4b4c26dc20e0850dca5efaabb60618e3456992e9c0b1b2120e"), new uint256("0xbfda55ef0756bcee8485e15527a2b8ca27ca877aa09c88e363ef8d3253cdfd1c")) },
{ 400000, new CheckpointInfo(new uint256("0xb6abcb933d3e3590345ca5d3abb697461093313f8886568ac8ae740d223e56f6"), new uint256("0xfaf5fcebee3ec0df5155393a99da43de18b12e620fef5edb111a791ecbfaa63a")) }
}; };
var checkpoints = new Checkpoints(Network.StratisTest, new ConsensusSettings() { UseCheckpoints = true }); var checkpoints = new Checkpoints(Network.StratisTest, new ConsensusSettings() { UseCheckpoints = true });
...@@ -312,9 +322,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests ...@@ -312,9 +322,9 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests
private void VerifyCheckpoints(Checkpoints checkpoints, Dictionary<int, CheckpointInfo> checkpointValues) private void VerifyCheckpoints(Checkpoints checkpoints, Dictionary<int, CheckpointInfo> checkpointValues)
{ {
foreach (var checkpoint in checkpointValues) foreach (KeyValuePair<int, CheckpointInfo> checkpoint in checkpointValues)
{ {
var result = checkpoints.GetCheckpoint(checkpoint.Key); CheckpointInfo result = checkpoints.GetCheckpoint(checkpoint.Key);
Assert.Equal(checkpoint.Value.Hash, result.Hash); Assert.Equal(checkpoint.Value.Hash, result.Hash);
Assert.Equal(checkpoint.Value.StakeModifierV2, result.StakeModifierV2); Assert.Equal(checkpoint.Value.StakeModifierV2, result.StakeModifierV2);
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.Consensus.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.Consensus.Tests</AssemblyName>
...@@ -15,21 +14,19 @@ ...@@ -15,21 +14,19 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.Consensus.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Consensus\Stratis.Bitcoin.Features.Consensus.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Consensus\Stratis.Bitcoin.Features.Consensus.csproj" />
...@@ -37,15 +34,12 @@ ...@@ -37,15 +34,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
...@@ -135,7 +135,7 @@ namespace Stratis.Bitcoin.Features.Consensus ...@@ -135,7 +135,7 @@ namespace Stratis.Bitcoin.Features.Consensus
new DeStreamLoadCoinviewRule(), new DeStreamLoadCoinviewRule(),
new DeStreamFundsPreservationRule(), new DeStreamFundsPreservationRule(),
new TransactionDuplicationActivationRule(), // implements BIP30 new TransactionDuplicationActivationRule(), // implements BIP30
new PowCoinviewRule(), // implements BIP68, MaxSigOps and BlockReward calculation new DeStreamPowCoinviewRule(), // implements BIP68, MaxSigOps and BlockReward calculation
new DeStreamBlockFeeRule() new DeStreamBlockFeeRule()
}; };
...@@ -181,7 +181,7 @@ namespace Stratis.Bitcoin.Features.Consensus ...@@ -181,7 +181,7 @@ namespace Stratis.Bitcoin.Features.Consensus
new DeStreamLoadCoinviewRule(), new DeStreamLoadCoinviewRule(),
new DeStreamFundsPreservationRule(), new DeStreamFundsPreservationRule(),
new TransactionDuplicationActivationRule(), // implements BIP30 new TransactionDuplicationActivationRule(), // implements BIP30
new PosCoinviewRule(), // implements BIP68, MaxSigOps and BlockReward calculation new DeStreamPosCoinviewRule(), // implements BIP68, MaxSigOps and BlockReward calculation
new DeStreamBlockFeeRule() new DeStreamBlockFeeRule()
}; };
} }
......
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Consensus.Rules;
using Stratis.Bitcoin.Features.Consensus.Interfaces;
using Stratis.Bitcoin.Utilities;
namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
{
/// <summary>
/// Proof of stake override for the coinview rules - BIP68, MaxSigOps and BlockReward checks.
/// </summary>
[ExecutionRule]
public sealed class DeStreamPosCoinviewRule : DeStreamCoinViewRule
{
/// <summary>Provides functionality for checking validity of PoS blocks.</summary>
private IStakeValidator stakeValidator;
/// <summary>Database of stake related data for the current blockchain.</summary>
private IStakeChain stakeChain;
/// <summary>The consensus of the parent Network.</summary>
private NBitcoin.Consensus consensus;
/// <inheritdoc />
public override void Initialize()
{
this.Logger.LogTrace("()");
base.Initialize();
this.consensus = this.Parent.Network.Consensus;
var consensusRules = (PosConsensusRules)this.Parent;
this.stakeValidator = consensusRules.StakeValidator;
this.stakeChain = consensusRules.StakeChain;
this.Logger.LogTrace("(-)");
}
/// <inheritdoc />
/// <summary>Compute and store the stake proofs.</summary>
public override async Task RunAsync(RuleContext context)
{
this.Logger.LogTrace("()");
this.CheckAndComputeStake(context);
await base.RunAsync(context).ConfigureAwait(false);
var posRuleContext = context as PosRuleContext;
await this.stakeChain.SetAsync(context.ValidationContext.ChainedHeader, posRuleContext.BlockStake).ConfigureAwait(false);
this.Logger.LogTrace("(-)");
}
/// <inheritdoc/>
protected override bool IsProtocolTransaction(Transaction transaction)
{
return transaction.IsCoinBase || transaction.IsCoinStake;
}
/// <inheritdoc />
public override void CheckBlockReward(RuleContext context, Money fees, int height, Block block)
{
this.Logger.LogTrace("({0}:{1},{2}:'{3}')", nameof(fees), fees, nameof(height), height);
if (BlockStake.IsProofOfStake(block))
{
var posRuleContext = context as PosRuleContext;
Money stakeReward = block.Transactions[1].TotalOut - posRuleContext.TotalCoinStakeValueIn;
Money calcStakeReward = fees + this.GetProofOfStakeReward(height);
this.Logger.LogTrace("Block stake reward is {0}, calculated reward is {1}.", stakeReward, calcStakeReward);
if (stakeReward > calcStakeReward)
{
this.Logger.LogTrace("(-)[BAD_COINSTAKE_AMOUNT]");
ConsensusErrors.BadCoinstakeAmount.Throw();
}
}
else
{
Money blockReward = fees + this.GetProofOfWorkReward(height);
this.Logger.LogTrace("Block reward is {0}, calculated reward is {1}.", block.Transactions[0].TotalOut, blockReward);
if (block.Transactions[0].TotalOut > blockReward)
{
this.Logger.LogTrace("(-)[BAD_COINBASE_AMOUNT]");
ConsensusErrors.BadCoinbaseAmount.Throw();
}
}
this.Logger.LogTrace("(-)");
}
/// <inheritdoc />
public override void UpdateCoinView(RuleContext context, Transaction transaction)
{
this.Logger.LogTrace("()");
var posRuleContext = context as PosRuleContext;
UnspentOutputSet view = posRuleContext.UnspentOutputSet;
if (transaction.IsCoinStake)
posRuleContext.TotalCoinStakeValueIn = view.GetValueIn(transaction);
base.UpdateUTXOSet(context, transaction);
this.Logger.LogTrace("(-)");
}
/// <inheritdoc />
public override void CheckMaturity(UnspentOutputs coins, int spendHeight)
{
this.Logger.LogTrace("({0}:'{1}/{2}',{3}:{4})", nameof(coins), coins.TransactionId, coins.Height, nameof(spendHeight), spendHeight);
base.CheckCoinbaseMaturity(coins, spendHeight);
if (coins.IsCoinstake)
{
if ((spendHeight - coins.Height) < this.consensus.CoinbaseMaturity)
{
this.Logger.LogTrace("Coinstake transaction height {0} spent at height {1}, but maturity is set to {2}.", coins.Height, spendHeight, this.consensus.CoinbaseMaturity);
this.Logger.LogTrace("(-)[COINSTAKE_PREMATURE_SPENDING]");
ConsensusErrors.BadTransactionPrematureCoinstakeSpending.Throw();
}
}
this.Logger.LogTrace("(-)");
}
/// <summary>
/// Checks and computes stake.
/// </summary>
/// <param name="context">Context that contains variety of information regarding blocks validation and execution.</param>
/// <exception cref="ConsensusErrors.PrevStakeNull">Thrown if previous stake is not found.</exception>
/// <exception cref="ConsensusErrors.SetStakeEntropyBitFailed">Thrown if failed to set stake entropy bit.</exception>
private void CheckAndComputeStake(RuleContext context)
{
this.Logger.LogTrace("()");
ChainedHeader chainedHeader = context.ValidationContext.ChainedHeader;
Block block = context.ValidationContext.Block;
var posRuleContext = context as PosRuleContext;
BlockStake blockStake = posRuleContext.BlockStake;
// Verify hash target and signature of coinstake tx.
if (BlockStake.IsProofOfStake(block))
{
ChainedHeader prevChainedHeader = chainedHeader.Previous;
BlockStake prevBlockStake = this.stakeChain.Get(prevChainedHeader.HashBlock);
if (prevBlockStake == null)
ConsensusErrors.PrevStakeNull.Throw();
// Only do proof of stake validation for blocks that are after the assumevalid block or after the last checkpoint.
if (!context.SkipValidation)
{
this.stakeValidator.CheckProofOfStake(posRuleContext, prevChainedHeader, prevBlockStake, block.Transactions[1], chainedHeader.Header.Bits.ToCompact());
}
else this.Logger.LogTrace("POS validation skipped for block at height {0}.", chainedHeader.Height);
}
// PoW is checked in CheckBlock().
if (BlockStake.IsProofOfWork(block))
posRuleContext.HashProofOfStake = chainedHeader.Header.GetPoWHash();
// Compute stake entropy bit for stake modifier.
if (!blockStake.SetStakeEntropyBit(blockStake.GetStakeEntropyBit()))
{
this.Logger.LogTrace("(-)[STAKE_ENTROPY_BIT_FAIL]");
ConsensusErrors.SetStakeEntropyBitFailed.Throw();
}
// Record proof hash value.
blockStake.HashProof = posRuleContext.HashProofOfStake;
int lastCheckpointHeight = this.Parent.Checkpoints.GetLastCheckpointHeight();
if (chainedHeader.Height > lastCheckpointHeight)
{
// Compute stake modifier.
ChainedHeader prevChainedHeader = chainedHeader.Previous;
BlockStake blockStakePrev = prevChainedHeader == null ? null : this.stakeChain.Get(prevChainedHeader.HashBlock);
blockStake.StakeModifierV2 = this.stakeValidator.ComputeStakeModifierV2(prevChainedHeader, blockStakePrev, blockStake.IsProofOfWork() ? chainedHeader.HashBlock : blockStake.PrevoutStake.Hash);
}
else if (chainedHeader.Height == lastCheckpointHeight)
{
// Copy checkpointed stake modifier.
CheckpointInfo checkpoint = this.Parent.Checkpoints.GetCheckpoint(lastCheckpointHeight);
blockStake.StakeModifierV2 = checkpoint.StakeModifierV2;
this.Logger.LogTrace("Last checkpoint stake modifier V2 loaded: '{0}'.", blockStake.StakeModifierV2);
}
else this.Logger.LogTrace("POS stake modifier computation skipped for block at height {0} because it is not above last checkpoint block height {1}.", chainedHeader.Height, lastCheckpointHeight);
this.Logger.LogTrace("(-)[OK]");
}
/// <inheritdoc />
public override Money GetProofOfWorkReward(int height)
{
if (this.IsPremine(height))
return this.consensus.PremineReward;
return this.consensus.ProofOfWorkReward;
}
/// <summary>
/// Gets miner's coin stake reward.
/// </summary>
/// <param name="height">Target block height.</param>
/// <returns>Miner's coin stake reward.</returns>
public Money GetProofOfStakeReward(int height)
{
if (this.IsPremine(height))
return this.consensus.PremineReward;
return this.consensus.ProofOfStakeReward;
}
}
}
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Consensus.Rules;
using Stratis.Bitcoin.Utilities;
namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
{
/// <inheritdoc />
[ExecutionRule]
public sealed class DeStreamPowCoinviewRule : DeStreamCoinViewRule
{
/// <summary>Consensus parameters.</summary>
private NBitcoin.Consensus consensus;
/// <inheritdoc />
public override void Initialize()
{
this.Logger.LogTrace("()");
base.Initialize();
this.consensus = this.Parent.Network.Consensus;
this.Logger.LogTrace("(-)");
}
/// <inheritdoc/>
protected override bool IsProtocolTransaction(Transaction transaction)
{
return transaction.IsCoinBase;
}
/// <inheritdoc/>
public override void CheckBlockReward(RuleContext context, Money fees, int height, Block block)
{
this.Logger.LogTrace("()");
Money blockReward = fees + this.GetProofOfWorkReward(height);
if (block.Transactions[0].TotalOut > blockReward)
{
this.Logger.LogTrace("(-)[BAD_COINBASE_AMOUNT]");
ConsensusErrors.BadCoinbaseAmount.Throw();
}
this.Logger.LogTrace("(-)");
}
/// <inheritdoc/>
public override Money GetProofOfWorkReward(int height)
{
if (this.IsPremine(height))
return this.consensus.PremineReward;
if (this.consensus.ProofOfWorkReward == 0)
return 0;
int halvings = height / this.consensus.SubsidyHalvingInterval;
// Force block reward to zero when right shift is undefined.
if (halvings >= 64)
return 0;
Money subsidy = this.consensus.ProofOfWorkReward;
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
subsidy >>= halvings;
return subsidy;
}
/// <inheritdoc/>
public override void CheckMaturity(UnspentOutputs coins, int spendHeight)
{
base.CheckCoinbaseMaturity(coins, spendHeight);
}
/// <inheritdoc/>
public override void UpdateCoinView(RuleContext context, Transaction transaction)
{
base.UpdateUTXOSet(context, transaction);
}
/// <inheritdoc />
public override Task RunAsync(RuleContext context)
{
return base.RunAsync(context);
}
}
}
\ No newline at end of file
...@@ -11,7 +11,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules ...@@ -11,7 +11,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
/// Proof of stake override for the coinview rules - BIP68, MaxSigOps and BlockReward checks. /// Proof of stake override for the coinview rules - BIP68, MaxSigOps and BlockReward checks.
/// </summary> /// </summary>
[ExecutionRule] [ExecutionRule]
public sealed class PosCoinviewRule : DeStreamCoinViewRule public sealed class PosCoinviewRule : CoinViewRule
{ {
/// <summary>Provides functionality for checking validity of PoS blocks.</summary> /// <summary>Provides functionality for checking validity of PoS blocks.</summary>
private IStakeValidator stakeValidator; private IStakeValidator stakeValidator;
......
...@@ -8,7 +8,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules ...@@ -8,7 +8,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
{ {
/// <inheritdoc /> /// <inheritdoc />
[ExecutionRule] [ExecutionRule]
public sealed class PowCoinviewRule : DeStreamCoinViewRule public sealed class PowCoinviewRule : CoinViewRule
{ {
/// <summary>Consensus parameters.</summary> /// <summary>Consensus parameters.</summary>
private NBitcoin.Consensus consensus; private NBitcoin.Consensus consensus;
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.Dns.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.Dns.Tests</AssemblyName>
...@@ -15,35 +14,30 @@ ...@@ -15,35 +14,30 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.Dns.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.Dns.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.Dns.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.Dns.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.Dns.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.Dns.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Stratis.Bitcoin.Features.Dns\Stratis.Bitcoin.Features.Dns.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Dns\Stratis.Bitcoin.Features.Dns.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.LightWallet.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.LightWallet.Tests</AssemblyName>
...@@ -15,22 +14,20 @@ ...@@ -15,22 +14,20 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.LightWallet.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.LightWallet\Stratis.Bitcoin.Features.LightWallet.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.LightWallet\Stratis.Bitcoin.Features.LightWallet.csproj" />
...@@ -38,15 +35,12 @@ ...@@ -38,15 +35,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.MemoryPool.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.MemoryPool.Tests</AssemblyName>
...@@ -15,22 +14,20 @@ ...@@ -15,22 +14,20 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.BlockStore\Stratis.Bitcoin.Features.BlockStore.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.BlockStore\Stratis.Bitcoin.Features.BlockStore.csproj" />
...@@ -40,15 +37,12 @@ ...@@ -40,15 +37,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
...@@ -16,27 +15,24 @@ ...@@ -16,27 +15,24 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -50,8 +50,7 @@ namespace Stratis.Bitcoin.Features.Miner ...@@ -50,8 +50,7 @@ namespace Stratis.Bitcoin.Features.Miner
context.CoinstakeContext.CoinstakeTx.AddOutput(new TxOut(Money.Zero, deStreamAddressKey)); context.CoinstakeContext.CoinstakeTx.AddOutput(new TxOut(Money.Zero, deStreamAddressKey));
} }
// No way to call base function and change smth after this, replacing whole function is the only way. /// <inheritdoc />
// All modified code is extraced to functions.
public override async Task<bool> CreateCoinstakeAsync(List<UtxoStakeDescription> utxoStakeDescriptions, public override async Task<bool> CreateCoinstakeAsync(List<UtxoStakeDescription> utxoStakeDescriptions,
Block block, ChainedHeader chainTip, long searchInterval, Block block, ChainedHeader chainTip, long searchInterval,
long fees, CoinstakeContext coinstakeContext) long fees, CoinstakeContext coinstakeContext)
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.Notifications.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.Notifications.Tests</AssemblyName>
...@@ -15,37 +14,32 @@ ...@@ -15,37 +14,32 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.Notifications.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Notifications\Stratis.Bitcoin.Features.Notifications.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Notifications\Stratis.Bitcoin.Features.Notifications.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using NBitcoin; using NBitcoin;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Stratis.Bitcoin.Controllers.Models; using Stratis.Bitcoin.Controllers.Models;
using Stratis.Bitcoin.Features.RPC.Models; using Stratis.Bitcoin.Features.RPC;
using Xunit; using Xunit;
namespace Stratis.Bitcoin.Features.RPC.Tests.Models namespace Stratis.Bitcoin.Tests.Models
{ {
public class TransactionModelsTest : BaseRPCModelTest, IDisposable public class TransactionModelsTest : BaseModelTest, IDisposable
{ {
private const string TxBlock10Hex = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0136ffffffff0100f2052a01000000434104fcc2888ca91cf0103d8c5797c256bf976e81f280205d002d85b9b622ed1a6f820866c7b5fe12285cfa78c035355d752fc94a398b67597dc4fbb5b386816425ddac00000000"; private const string TxBlock10Hex = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0136ffffffff0100f2052a01000000434104fcc2888ca91cf0103d8c5797c256bf976e81f280205d002d85b9b622ed1a6f820866c7b5fe12285cfa78c035355d752fc94a398b67597dc4fbb5b386816425ddac00000000";
private const string TxBlock10Hash = "d3ad39fa52a89997ac7381c95eeffeaf40b66af7a57e9eba144be0a175a12b11"; private const string TxBlock10Hash = "d3ad39fa52a89997ac7381c95eeffeaf40b66af7a57e9eba144be0a175a12b11";
...@@ -24,9 +27,10 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -24,9 +27,10 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
public TransactionModelsTest() public TransactionModelsTest()
{ {
this.txBlock10CoinbaseModelBrief = new TransactionBriefModel(Transaction.Parse(TxBlock10Hex, RawFormat.BlockExplorer)); var network = Network.Main;
this.txBlock460373CoinbaseModelVerbose = new TransactionVerboseModel(Transaction.Parse(TxBlock460373CoinbaseHex, RawFormat.BlockExplorer), Network.Main); this.txBlock10CoinbaseModelBrief = new TransactionBriefModel(network.CreateTransaction(TxBlock10Hex));
this.txTwoInTwoOutModelVerbose = new TransactionVerboseModel(Transaction.Parse(TxTwoInTwoOutHex, RawFormat.BlockExplorer), Network.Main); this.txBlock460373CoinbaseModelVerbose = new TransactionVerboseModel(network.CreateTransaction(TxBlock460373CoinbaseHex), network);
this.txTwoInTwoOutModelVerbose = new TransactionVerboseModel(network.CreateTransaction(TxTwoInTwoOutHex), network);
} }
public void Dispose() public void Dispose()
...@@ -39,7 +43,7 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -39,7 +43,7 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
[Fact] [Fact]
public void TransactionModelBriefRenderTest() public void TransactionModelBriefRenderTest()
{ {
var model = this.txBlock10CoinbaseModelBrief; TransactionBriefModel model = this.txBlock10CoinbaseModelBrief;
string json = ModelToJson(model); string json = ModelToJson(model);
string expectedJson = "\"" + TxBlock10Hex + "\""; string expectedJson = "\"" + TxBlock10Hex + "\"";
...@@ -58,9 +62,9 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -58,9 +62,9 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
string actualHex = obj.Value<string>("hex"); string actualHex = obj.Value<string>("hex");
string actualTxid = obj.Value<string>("txid"); string actualTxid = obj.Value<string>("txid");
int? actualSize = obj.Value<int>("size"); int? actualSize = obj.Value<int>("size");
int? actualVersion = obj.Value<int?>("version"); var actualVersion = obj.Value<int?>("version");
int? actualLocktime = obj.Value<int?>("locktime"); var actualLocktime = obj.Value<int?>("locktime");
var actualPropertyNameOrder = obj.Children().Select(o => (o as JProperty)?.Name); IEnumerable<string> actualPropertyNameOrder = obj.Children().Select(o => (o as JProperty)?.Name);
Assert.Equal(7, actualElements); Assert.Equal(7, actualElements);
Assert.Equal(TxBlock460373CoinbaseHex, actualHex); Assert.Equal(TxBlock460373CoinbaseHex, actualHex);
...@@ -78,14 +82,14 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -78,14 +82,14 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
string expectedCoinbase = "0355060704eba7e3582f4254432e434f4d2fb6000ddbcbe5000000000000"; string expectedCoinbase = "0355060704eba7e3582f4254432e434f4d2fb6000ddbcbe5000000000000";
JObject obj = ModelToJObject(this.txBlock460373CoinbaseModelVerbose); JObject obj = ModelToJObject(this.txBlock460373CoinbaseModelVerbose);
Assert.True(obj.HasValues); Assert.True(obj.HasValues);
var vin = obj["vin"]; JToken vin = obj["vin"];
Assert.NotNull(vin); Assert.NotNull(vin);
int actualVinCount = vin.Count(); int actualVinCount = vin.Count();
int? actualVinInnerElements = vin.FirstOrDefault()?.Count(); int? actualVinInnerElements = vin.FirstOrDefault()?.Count();
string actualCoinbase = vin.FirstOrDefault()?.Value<string>("coinbase"); string actualCoinbase = vin.FirstOrDefault()?.Value<string>("coinbase");
uint? actualSequence = vin.FirstOrDefault()?.Value<uint>("sequence"); var actualSequence = vin.FirstOrDefault()?.Value<uint>("sequence");
var actualPropertyNameOrder = vin.FirstOrDefault()?.Select(o => (o as JProperty)?.Name); IEnumerable<string> actualPropertyNameOrder = vin.FirstOrDefault()?.Select(o => (o as JProperty)?.Name);
Assert.Equal(1, actualVinCount); Assert.Equal(1, actualVinCount);
Assert.Equal(2, actualVinInnerElements); Assert.Equal(2, actualVinInnerElements);
...@@ -100,14 +104,14 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -100,14 +104,14 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
var expectedPropertyNameOrder = new string[] { "value", "n", "scriptPubKey" }; var expectedPropertyNameOrder = new string[] { "value", "n", "scriptPubKey" };
JObject obj = ModelToJObject(this.txBlock460373CoinbaseModelVerbose); JObject obj = ModelToJObject(this.txBlock460373CoinbaseModelVerbose);
Assert.True(obj.HasValues); Assert.True(obj.HasValues);
var vout = obj["vout"]; JToken vout = obj["vout"];
Assert.NotNull(vout); Assert.NotNull(vout);
int actualVoutCount = vout.Count(); int actualVoutCount = vout.Count();
int? actualVoutInnerElements = vout.FirstOrDefault()?.Count(); int? actualVoutInnerElements = vout.FirstOrDefault()?.Count();
decimal? actualTotalValue = vout.Sum(o => o.Value<decimal?>("value")); decimal? actualTotalValue = vout.Sum(o => o.Value<decimal?>("value"));
int? actualLastVoutN = vout.LastOrDefault().Value<int?>("n"); var actualLastVoutN = vout.LastOrDefault().Value<int?>("n");
var actualPropertyNameOrder = vout.FirstOrDefault()?.Select(o => (o as JProperty)?.Name); IEnumerable<string> actualPropertyNameOrder = vout.FirstOrDefault()?.Select(o => (o as JProperty)?.Name);
Assert.Equal(2, actualVoutCount); Assert.Equal(2, actualVoutCount);
Assert.Equal(3, actualVoutInnerElements); Assert.Equal(3, actualVoutInnerElements);
...@@ -126,11 +130,11 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -126,11 +130,11 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
var secondScript = obj["vout"]?.LastOrDefault()?.Value<JToken>("scriptPubKey"); var secondScript = obj["vout"]?.LastOrDefault()?.Value<JToken>("scriptPubKey");
string actualFirstVoutScriptType = firstScript?.Value<string>("type"); string actualFirstVoutScriptType = firstScript?.Value<string>("type");
int? actualReqSigs = firstScript?.Value<int>("reqSigs"); var actualReqSigs = firstScript?.Value<int>("reqSigs");
int? actualAddressCount = firstScript?["addresses"]?.Count(); int? actualAddressCount = firstScript?["addresses"]?.Count();
string actualSecondVoutScriptType = secondScript?.Value<string>("type"); string actualSecondVoutScriptType = secondScript?.Value<string>("type");
var actualFirstPropertyNameOrder = firstScript?.Select(o => (o as JProperty)?.Name); IEnumerable<string> actualFirstPropertyNameOrder = firstScript?.Select(o => (o as JProperty)?.Name);
var actualSecondPropertyNameOrder = secondScript?.Select(o => (o as JProperty)?.Name); IEnumerable<string> actualSecondPropertyNameOrder = secondScript?.Select(o => (o as JProperty)?.Name);
Assert.Equal("scripthash", actualFirstVoutScriptType); Assert.Equal("scripthash", actualFirstVoutScriptType);
Assert.Equal(1, actualReqSigs); Assert.Equal(1, actualReqSigs);
...@@ -146,18 +150,18 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -146,18 +150,18 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
var expectedPropertyNameOrder = new string[] { "txid", "vout", "scriptSig", "sequence" }; var expectedPropertyNameOrder = new string[] { "txid", "vout", "scriptSig", "sequence" };
JObject obj = ModelToJObject(this.txTwoInTwoOutModelVerbose); JObject obj = ModelToJObject(this.txTwoInTwoOutModelVerbose);
Assert.True(obj.HasValues); Assert.True(obj.HasValues);
var vin = obj["vin"]; JToken vin = obj["vin"];
var firstIn = vin.FirstOrDefault(); JToken firstIn = vin.FirstOrDefault();
var lastIn = vin.LastOrDefault(); JToken lastIn = vin.LastOrDefault();
int actualVinCount = vin.Count(); int actualVinCount = vin.Count();
string actualFirstTxId = firstIn?.Value<string>("txid"); string actualFirstTxId = firstIn?.Value<string>("txid");
int? actualFirstNdx = firstIn?.Value<int?>("vout"); var actualFirstNdx = firstIn?.Value<int?>("vout");
uint? actualFirstSequence = firstIn?.Value<uint>("sequence"); var actualFirstSequence = firstIn?.Value<uint>("sequence");
string actualLastTxId = lastIn?.Value<string>("txid"); string actualLastTxId = lastIn?.Value<string>("txid");
int? actualLastNdx = lastIn?.Value<int?>("vout"); var actualLastNdx = lastIn?.Value<int?>("vout");
uint? actualLastSequence = lastIn?.Value<uint>("sequence"); var actualLastSequence = lastIn?.Value<uint>("sequence");
var actualPropertyNameOrder = firstIn?.Select(o => (o as JProperty)?.Name); IEnumerable<string> actualPropertyNameOrder = firstIn?.Select(o => (o as JProperty)?.Name);
Assert.Equal(2, actualVinCount); Assert.Equal(2, actualVinCount);
Assert.Equal("19d03bf27410e3ee024211b8470c0fb3fb93913d0f8c7a0e96185ead2d58a7b1", actualFirstTxId); Assert.Equal("19d03bf27410e3ee024211b8470c0fb3fb93913d0f8c7a0e96185ead2d58a7b1", actualFirstTxId);
...@@ -169,4 +173,23 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models ...@@ -169,4 +173,23 @@ namespace Stratis.Bitcoin.Features.RPC.Tests.Models
Assert.Equal(expectedPropertyNameOrder, actualPropertyNameOrder); Assert.Equal(expectedPropertyNameOrder, actualPropertyNameOrder);
} }
} }
public class BaseModelTest
{
protected static JObject ModelToJObject(object model)
{
string json = ModelToJson(model);
JObject obj = JObject.Parse(json);
return obj;
}
protected static string ModelToJson(object model)
{
var formatter = new RPCJsonOutputFormatter(new JsonSerializerSettings(), System.Buffers.ArrayPool<char>.Create());
var sw = new StringWriter();
formatter.WriteObject(sw, model);
string json = sw.ToString();
return json;
}
}
} }
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.RPC.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.RPC.Tests</AssemblyName>
...@@ -15,22 +14,20 @@ ...@@ -15,22 +14,20 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.RPC.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.RPC.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.RPC.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.RPC.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.RPC.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.RPC.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj" />
...@@ -39,15 +36,12 @@ ...@@ -39,15 +36,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.Wallet.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.Wallet.Tests</AssemblyName>
...@@ -15,23 +14,21 @@ ...@@ -15,23 +14,21 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.Wallet.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="FluentAssertions" Version="5.4.1" /> <PackageReference Include="FluentAssertions" Version="5.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" />
...@@ -40,15 +37,12 @@ ...@@ -40,15 +37,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
...@@ -76,7 +76,7 @@ namespace Stratis.Bitcoin.Features.Wallet.Tests ...@@ -76,7 +76,7 @@ namespace Stratis.Bitcoin.Features.Wallet.Tests
}); });
} }
[Fact] [Fact(Skip = "Fee check is disabled")]
public void BuildTransactionFeeTooLowThrowsWalletException() public void BuildTransactionFeeTooLowThrowsWalletException()
{ {
Assert.Throws<WalletException>(() => Assert.Throws<WalletException>(() =>
...@@ -138,7 +138,6 @@ namespace Stratis.Bitcoin.Features.Wallet.Tests ...@@ -138,7 +138,6 @@ namespace Stratis.Bitcoin.Features.Wallet.Tests
}; };
walletTransactionHandler.BuildTransaction(CreateContext(walletReference, "password", destinationKeys.PubKey.ScriptPubKey, new Money(7500), FeeType.Low, 0)); walletTransactionHandler.BuildTransaction(CreateContext(walletReference, "password", destinationKeys.PubKey.ScriptPubKey, new Money(7500), FeeType.Low, 0));
int qwe = 1;
}); });
} }
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.WatchOnlyWallet.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Features.WatchOnlyWallet.Tests</AssemblyName>
...@@ -15,37 +14,32 @@ ...@@ -15,37 +14,32 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" /> <None Remove="Stratis.Bitcoin.Features.WatchOnlyWallet.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.WatchOnlyWallet\Stratis.Bitcoin.Features.WatchOnlyWallet.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.WatchOnlyWallet\Stratis.Bitcoin.Features.WatchOnlyWallet.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
...@@ -459,8 +459,7 @@ namespace Stratis.Bitcoin.IntegrationTests.Common.EnvironmentMockUpHelpers ...@@ -459,8 +459,7 @@ namespace Stratis.Bitcoin.IntegrationTests.Common.EnvironmentMockUpHelpers
var blocks = new List<Block>(); var blocks = new List<Block>();
DateTimeOffset now = this.MockTime == null ? DateTimeOffset.UtcNow : this.MockTime.Value; DateTimeOffset now = this.MockTime == null ? DateTimeOffset.UtcNow : this.MockTime.Value;
//for (int i = 0; i < blockCount; i++) for (int i = 0; i < blockCount; i++)
for (int i = 0; i < 3; i++)
{ {
uint nonce = 0; uint nonce = 0;
var block = new Block(); var block = new Block();
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
...@@ -17,11 +16,11 @@ ...@@ -17,11 +16,11 @@
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Product /> <Product />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
...@@ -34,14 +33,12 @@ ...@@ -34,14 +33,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants> <DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
<DocumentationFile></DocumentationFile> <DocumentationFile>
</DocumentationFile>
</PropertyGroup> </PropertyGroup>
</Project>
</Project> \ No newline at end of file
...@@ -15,25 +15,14 @@ namespace Stratis.Bitcoin.IntegrationTests.Common ...@@ -15,25 +15,14 @@ namespace Stratis.Bitcoin.IntegrationTests.Common
{ {
public static void WaitLoop(Func<bool> act) public static void WaitLoop(Func<bool> act)
{ {
var cancel = new CancellationTokenSource(Debugger.IsAttached ? 15 * 60 * 1000 : 30 * 1000); var cancel = new CancellationTokenSource(Debugger.IsAttached ? 15 * 60 * 1000 : 5 * 60 * 1000);
while (!act()) while (!act())
{ {
cancel.Token.ThrowIfCancellationRequested(); cancel.Token.ThrowIfCancellationRequested();
//Thread.Sleep(50); Thread.Sleep(50);
} }
} }
public static bool AreNodesSyncedTemp(CoreNode node1, FullNode node2)
{
if (node1.FullNode.Chain.Tip.HashBlock != node2.Chain.Tip.HashBlock) return false;
if (node1.FullNode.ChainBehaviorState.ConsensusTip.HashBlock != node2.ChainBehaviorState.ConsensusTip.HashBlock) return false;
if (node1.FullNode.GetBlockStoreTip().HashBlock != node2.GetBlockStoreTip().HashBlock) return false;
if (node1.FullNode.MempoolManager().InfoAll().Count != node2.MempoolManager().InfoAll().Count) return false;
if (node1.FullNode.WalletManager().WalletTipHash != node2.WalletManager().WalletTipHash) return false;
//if (node1.CreateRPCClient().GetBestBlockHash() != node2.CreateRPCClient().GetBestBlockHash()) return false;
return true;
}
public static bool AreNodesSynced(CoreNode node1, CoreNode node2) public static bool AreNodesSynced(CoreNode node1, CoreNode node2)
{ {
if (node1.FullNode.Chain.Tip.HashBlock != node2.FullNode.Chain.Tip.HashBlock) return false; if (node1.FullNode.Chain.Tip.HashBlock != node2.FullNode.Chain.Tip.HashBlock) return false;
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NBitcoin;
using Xunit;
namespace Stratis.Bitcoin.IntegrationTests
{
public class ConstructorsForSerializableClassesTest
{
[Fact]
public void AssureParameterlessConstructorsExistenceForSerializableClasses()
{
// This list contain types that inherit IBitcoinSerializable but don't have a public
// parameterless constructor for a good reason so they should not fail this test.
List<Type> exceptionalTypes = new List<Type>()
{
typeof(NBitcoin.ExtKey),
typeof(NBitcoin.ExtPubKey),
typeof(NBitcoin.PubKey),
typeof(NBitcoin.PosBlock),
typeof(NBitcoin.PosBlockHeader),
typeof(NBitcoin.PosTransaction),
typeof(NBitcoin.Protocol.CompactVarInt),
};
var types = AppDomain.CurrentDomain.GetAssemblies()
.Where(x =>x.FullName.Contains("Stratis") || x.FullName.Contains("NBitcoin"))
.SelectMany(s => s.GetTypes())
.Where(p => typeof(IBitcoinSerializable).IsAssignableFrom(p) && !p.IsInterface && p.IsClass);
foreach (var type in types)
{
if (exceptionalTypes.Contains(type))
continue;
bool parameterlessConstructorExists = type.GetConstructors().Any(x => x.GetParameters().Length == 0);
Assert.True(parameterlessConstructorExists, $"Class {type.FullName} inherits {typeof(IBitcoinSerializable).Name} " +
"but doesn't have a parameterless constructor which is needed for serialization and deserialization process!");
}
}
/// <summary>
/// Serializes input and returns deserialized object.
/// </summary>
/// <remarks>Needed for troubleshooting this test.</remarks>
private T CloneViaSerializeDeserialize<T>(T input) where T : IBitcoinSerializable
{
MemoryStream ms = new MemoryStream();
BitcoinStream bitcoinStream = new BitcoinStream(ms, true);
input.ReadWrite(bitcoinStream);
ms.Position = 0;
bitcoinStream = new BitcoinStream(bitcoinStream.Inner, false);
var obj = Activator.CreateInstance<T>();
obj.ReadWrite(bitcoinStream);
return obj;
}
}
}
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'"> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
<OutputType>exe</OutputType> <OutputType>exe</OutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.IntegrationTests</AssemblyName> <AssemblyName>Stratis.Bitcoin.IntegrationTests</AssemblyName>
<PackageId>Stratis.Bitcoin.IntegrationTests</PackageId> <PackageId>Stratis.Bitcoin.IntegrationTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
...@@ -20,15 +18,14 @@ ...@@ -20,15 +18,14 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateProgramFile>false</GenerateProgramFile> <GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
...@@ -45,16 +42,13 @@ ...@@ -45,16 +42,13 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.4.1" /> <PackageReference Include="FluentAssertions" Version="5.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="Data\test.wallet.json"> <None Update="Data\test.wallet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
...@@ -66,10 +60,8 @@ ...@@ -66,10 +60,8 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Builders\" /> <Folder Include="Builders\" />
<Folder Include="Extensions\" /> <Folder Include="Extensions\" />
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
</Project> <PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
</Project>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Tests</AssemblyName> <AssemblyName>Stratis.Bitcoin.Tests</AssemblyName>
...@@ -15,37 +14,32 @@ ...@@ -15,37 +14,32 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn> <NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Stratis.Bitcoin.Tests\**" /> <Compile Remove="Stratis.Bitcoin.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Tests\**" /> <EmbeddedResource Remove="Stratis.Bitcoin.Tests\**" />
<None Remove="Stratis.Bitcoin.Tests\**" /> <None Remove="Stratis.Bitcoin.Tests\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" /> <ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin.Tests.Wallet.Common\Stratis.Bitcoin.Tests.Wallet.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" /> <ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="xunit.runner.json"> <None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project>
</Project> \ No newline at end of file
...@@ -74,15 +74,6 @@ namespace Stratis.Bitcoin.Configuration ...@@ -74,15 +74,6 @@ namespace Stratis.Bitcoin.Configuration
/// <summary>Minimum relay transaction fee for network.</summary> /// <summary>Minimum relay transaction fee for network.</summary>
public FeeRate MinRelayTxFeeRate { get; private set; } public FeeRate MinRelayTxFeeRate { get; private set; }
/// <summary>
/// Returns default data root directory name
/// </summary>
protected virtual string DataRootDirName
{
get { return "StratisNode"; }
}
/// <summary> /// <summary>
/// Initializes a new instance of the object. /// Initializes a new instance of the object.
/// </summary> /// </summary>
...@@ -100,6 +91,11 @@ namespace Stratis.Bitcoin.Configuration ...@@ -100,6 +91,11 @@ namespace Stratis.Bitcoin.Configuration
/// name would be determined. In this case we first need to determine the network. /// name would be determined. In this case we first need to determine the network.
/// </remarks> /// </remarks>
public NodeSettings(Network network = null, ProtocolVersion protocolVersion = SupportedProtocolVersion, public NodeSettings(Network network = null, ProtocolVersion protocolVersion = SupportedProtocolVersion,
string agent = "StratisBitcoin", string[] args = null) : this("StratisNode", network, protocolVersion, agent, args)
{
}
protected NodeSettings(string dataRootDirName, Network network = null, ProtocolVersion protocolVersion = SupportedProtocolVersion,
string agent = "StratisBitcoin", string[] args = null) string agent = "StratisBitcoin", string[] args = null)
{ {
// Create the default logger factory and logger. // Create the default logger factory and logger.
...@@ -168,7 +164,7 @@ namespace Stratis.Bitcoin.Configuration ...@@ -168,7 +164,7 @@ namespace Stratis.Bitcoin.Configuration
if (this.DataDir == null) if (this.DataDir == null)
{ {
// Create the data directories if they don't exist. // Create the data directories if they don't exist.
this.DataDir = this.CreateDefaultDataDirectories(Path.Combine(this.DataRootDirName, this.Network.RootFolderName), this.Network); this.DataDir = this.CreateDefaultDataDirectories(Path.Combine(dataRootDirName, this.Network.RootFolderName), this.Network);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment