Commit f71c2a62 authored by Sergei Zubov's avatar Sergei Zubov

Temp fix lost dependencies

parent ce5750fb
Pipeline #130 failed with stage
in 49 seconds
using System; //using System;
using System.IO; //using System.IO;
using System.Linq; //using System.Linq;
using FluentAssertions; //using FluentAssertions;
using Stratis.Bitcoin.Tests.Common; //using Stratis.Bitcoin.Tests.Common;
using Xunit; //using Xunit;
//
namespace NBitcoin.Tests //namespace NBitcoin.Tests
{ //{
public class ProvenBlockHeaderTests : TestBase // public class ProvenBlockHeaderTests : TestBase
{ // {
public ProvenBlockHeaderTests() : base(KnownNetworks.StratisTest) // public ProvenBlockHeaderTests() : base(KnownNetworks.StratisTest)
{ // {
} // }
//
[Fact] // [Fact]
public void ProvenBlockHeaderShouldSerializeAndDeserializeCorrectly() // public void ProvenBlockHeaderShouldSerializeAndDeserializeCorrectly()
{ // {
// Setup new header to serialize with some fake properties. // // Setup new header to serialize with some fake properties.
ProvenBlockHeader provenHeaderToSerialize = CreateNewProvenBlockHeaderMock(); // ProvenBlockHeader provenHeaderToSerialize = CreateNewProvenBlockHeaderMock();
provenHeaderToSerialize.BlockTime = new DateTimeOffset(new DateTime(2018, 1, 1)); // provenHeaderToSerialize.BlockTime = new DateTimeOffset(new DateTime(2018, 1, 1));
provenHeaderToSerialize.Bits = 1; // provenHeaderToSerialize.Bits = 1;
provenHeaderToSerialize.Nonce = 2; // provenHeaderToSerialize.Nonce = 2;
//
// Attempt to serialize it. // // Attempt to serialize it.
using (var ms = new MemoryStream()) // using (var ms = new MemoryStream())
{ // {
provenHeaderToSerialize.ReadWrite(new BitcoinStream(ms, true)); // provenHeaderToSerialize.ReadWrite(new BitcoinStream(ms, true));
//
byte[] bytes = ms.ToArray(); // byte[] bytes = ms.ToArray();
bytes.Should().HaveCountGreaterThan(0); // bytes.Should().HaveCountGreaterThan(0);
//
// Setup another slightly different header and try to load it from // // Setup another slightly different header and try to load it from
// serialized data from original header. // // serialized data from original header.
ProvenBlockHeader provenHeaderToDeserialize = CreateNewProvenBlockHeaderMock(); // ProvenBlockHeader provenHeaderToDeserialize = CreateNewProvenBlockHeaderMock();
provenHeaderToDeserialize.GetHash().Should().NotBe(provenHeaderToSerialize.GetHash()); // provenHeaderToDeserialize.GetHash().Should().NotBe(provenHeaderToSerialize.GetHash());
//
// Attempt to deserialize it. // // Attempt to deserialize it.
provenHeaderToDeserialize.ReadWrite(bytes, this.Network.Consensus.ConsensusFactory); // provenHeaderToDeserialize.ReadWrite(bytes, this.Network.Consensus.ConsensusFactory);
//
provenHeaderToDeserialize.GetHash().Should().Be(provenHeaderToSerialize.GetHash()); // provenHeaderToDeserialize.GetHash().Should().Be(provenHeaderToSerialize.GetHash());
//
// Check if merke proofs are identical. // // Check if merke proofs are identical.
provenHeaderToDeserialize.MerkleProof.Hashes.Should().BeEquivalentTo(provenHeaderToSerialize.MerkleProof.Hashes); // provenHeaderToDeserialize.MerkleProof.Hashes.Should().BeEquivalentTo(provenHeaderToSerialize.MerkleProof.Hashes);
provenHeaderToDeserialize.MerkleProof.TransactionCount.Should().Be(provenHeaderToSerialize.MerkleProof.TransactionCount); // provenHeaderToDeserialize.MerkleProof.TransactionCount.Should().Be(provenHeaderToSerialize.MerkleProof.TransactionCount);
for (int i = 0; i < provenHeaderToSerialize.MerkleProof.Flags.Length; i++) // for (int i = 0; i < provenHeaderToSerialize.MerkleProof.Flags.Length; i++)
{ // {
provenHeaderToDeserialize.MerkleProof.Flags[i].Should().Be(provenHeaderToSerialize.MerkleProof.Flags[i]); // provenHeaderToDeserialize.MerkleProof.Flags[i].Should().Be(provenHeaderToSerialize.MerkleProof.Flags[i]);
} // }
//
// Check if coinstake properties match. // // Check if coinstake properties match.
provenHeaderToDeserialize.Coinstake.Should().BeEquivalentTo(provenHeaderToSerialize.Coinstake); // provenHeaderToDeserialize.Coinstake.Should().BeEquivalentTo(provenHeaderToSerialize.Coinstake);
//
// Check if signature properties match. // // Check if signature properties match.
provenHeaderToDeserialize.Signature.Signature.Should().BeEquivalentTo(provenHeaderToSerialize.Signature.Signature); // provenHeaderToDeserialize.Signature.Signature.Should().BeEquivalentTo(provenHeaderToSerialize.Signature.Signature);
//
// Check base properties. // // Check base properties.
provenHeaderToDeserialize.BlockTime.Should().Be(provenHeaderToSerialize.BlockTime); // provenHeaderToDeserialize.BlockTime.Should().Be(provenHeaderToSerialize.BlockTime);
provenHeaderToDeserialize.CurrentVersion.Should().Be(provenHeaderToSerialize.CurrentVersion); // provenHeaderToDeserialize.CurrentVersion.Should().Be(provenHeaderToSerialize.CurrentVersion);
provenHeaderToDeserialize.Nonce.Should().Be(provenHeaderToSerialize.Nonce); // provenHeaderToDeserialize.Nonce.Should().Be(provenHeaderToSerialize.Nonce);
provenHeaderToDeserialize.Time.Should().Be(provenHeaderToSerialize.Time); // provenHeaderToDeserialize.Time.Should().Be(provenHeaderToSerialize.Time);
provenHeaderToDeserialize.Version.Should().Be(provenHeaderToSerialize.Version); // provenHeaderToDeserialize.Version.Should().Be(provenHeaderToSerialize.Version);
} // }
} // }
//
[Fact] // [Fact]
public void ShouldNotBeAbleToCreateProvenBlockHeaderFromANullBlock() // public void ShouldNotBeAbleToCreateProvenBlockHeaderFromANullBlock()
{ // {
Action createProvenHeader = () => ((PosConsensusFactory)this.Network.Consensus.ConsensusFactory).CreateProvenBlockHeader(null); // Action createProvenHeader = () => ((PosConsensusFactory)this.Network.Consensus.ConsensusFactory).CreateProvenBlockHeader(null);
createProvenHeader.Should().Throw<ArgumentNullException>(); // createProvenHeader.Should().Throw<ArgumentNullException>();
} // }
//
[Fact] // [Fact]
public void WhenCreatingNewProvenHeaderMerkleProofIsCorrectlyCreated() // public void WhenCreatingNewProvenHeaderMerkleProofIsCorrectlyCreated()
{ // {
PosBlock block = this.CreatePosBlockMock(); // PosBlock block = this.CreatePosBlockMock();
//
// Add 20 more transactions. // // Add 20 more transactions.
for (int i = 0; i < 20; i++) // for (int i = 0; i < 20; i++)
{ // {
Transaction tx = this.Network.CreateTransaction(); // Transaction tx = this.Network.CreateTransaction();
//
tx.AddInput(new TxIn(Script.Empty)); // tx.AddInput(new TxIn(Script.Empty));
tx.AddOutput(Money.COIN + i, new Script(Enumerable.Range(1, 5).SelectMany(index => Guid.NewGuid().ToByteArray()))); // tx.AddOutput(Money.COIN + i, new Script(Enumerable.Range(1, 5).SelectMany(index => Guid.NewGuid().ToByteArray())));
//
block.AddTransaction(tx); // block.AddTransaction(tx);
} // }
//
block.UpdateMerkleRoot(); // block.UpdateMerkleRoot();
ProvenBlockHeader provenBlockHeader = CreateNewProvenBlockHeaderMock(block); // ProvenBlockHeader provenBlockHeader = CreateNewProvenBlockHeaderMock(block);
provenBlockHeader.MerkleProof.Hashes.Should().HaveCount(6); // provenBlockHeader.MerkleProof.Hashes.Should().HaveCount(6);
provenBlockHeader.MerkleProof.Check(provenBlockHeader.HashMerkleRoot).Should().BeTrue(); // provenBlockHeader.MerkleProof.Check(provenBlockHeader.HashMerkleRoot).Should().BeTrue();
} // }
} // }
} //}
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
<CodeAnalysisRuleSet>..\Stratis.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\Stratis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ConcurrentHashSet" Version="1.0.2" /> <PackageReference Include="ConcurrentHashSet" Version="1.0.2" />
<PackageReference Include="DBreeze" Version="1.89.0" /> <PackageReference Include="DBreeze" Version="1.89.0" />
......
using McMaster.Extensions.CommandLineUtils; using McMaster.Extensions.CommandLineUtils;
using Stratis.SmartContracts.Tools.Sct.Build; //using Stratis.SmartContracts.Tools.Sct.Build;
using Stratis.SmartContracts.Tools.Sct.Deployment; using Stratis.SmartContracts.Tools.Sct.Deployment;
using Stratis.SmartContracts.Tools.Sct.Validation; using Stratis.SmartContracts.Tools.Sct.Validation;
...@@ -7,7 +7,7 @@ namespace Stratis.SmartContracts.Tools.Sct ...@@ -7,7 +7,7 @@ namespace Stratis.SmartContracts.Tools.Sct
{ {
[Command(ThrowOnUnexpectedArgument = false)] [Command(ThrowOnUnexpectedArgument = false)]
[Subcommand("validate", typeof(Validator))] [Subcommand("validate", typeof(Validator))]
[Subcommand("build", typeof(Builder))] // [Subcommand("build", typeof(Builder))]
[Subcommand("deploy", typeof(Deployer))] [Subcommand("deploy", typeof(Deployer))]
[HelpOption] [HelpOption]
[VersionOption("-v|--version", "v0.0.2")] [VersionOption("-v|--version", "v0.0.2")]
......
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