Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
destream-blockchain
Commits
f71c2a62
Commit
f71c2a62
authored
Mar 07, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temp fix lost dependencies
parent
ce5750fb
Pipeline
#130
failed with stage
in 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
101 deletions
+97
-101
ProvenBlockHeaderTests.cs
Sources/NBitcoin.Tests/ProvenBlockHeaderTests.cs
+95
-95
Stratis.Bitcoin.csproj
Sources/Stratis.Bitcoin/Stratis.Bitcoin.csproj
+0
-4
Program.cs
Sources/Stratis.SmartContracts.Tools.Sct/Program.cs
+2
-2
No files found.
Sources/NBitcoin.Tests/ProvenBlockHeaderTests.cs
View file @
f71c2a62
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();
}
//
}
}
//
}
}
//
}
Sources/Stratis.Bitcoin/Stratis.Bitcoin.csproj
View file @
f71c2a62
...
@@ -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" />
...
...
Sources/Stratis.SmartContracts.Tools.Sct/Program.cs
View file @
f71c2a62
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"
)]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment