Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet format #879

Merged
merged 1 commit into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions neo.UnitTests/UT_ConsensusServiceMailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Neo.UnitTests
{
[TestClass]
public class UT_ConsensusServiceMailbox : TestKit
public class UT_ConsensusServiceMailbox : TestKit
{
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism

Expand Down Expand Up @@ -42,10 +42,10 @@ public void ConsensusServiceMailbox_Test_IsHighPriority()
uut.IsHighPriority(new ConsensusService.SetViewNumber()).Should().Be(true);
uut.IsHighPriority(new ConsensusService.Timer()).Should().Be(true);
uut.IsHighPriority(new Blockchain.PersistCompleted()).Should().Be(true);

// any random object should not have priority
object obj = null;
uut.IsHighPriority(obj).Should().Be(false);
uut.IsHighPriority(obj).Should().Be(false);
}
}
}
46 changes: 23 additions & 23 deletions neo.UnitTests/UT_ProtocolHandlerMailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neo.UnitTests
{
[TestClass]
public class UT_ProtocolHandlerMailbox : TestKit
public class UT_ProtocolHandlerMailbox : TestKit
{
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism

Expand Down Expand Up @@ -96,99 +96,99 @@ public void ProtocolHandlerMailbox_Test_ShallDrop()
// Version (no drop)
msg = Message.Create(MessageCommand.Version, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Verack (no drop)
msg = Message.Create(MessageCommand.Verack, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);

//connectivity
// GetAddr (drop)
msg = Message.Create(MessageCommand.GetAddr, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(true);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(true);
// Addr (no drop)
msg = Message.Create(MessageCommand.Addr, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Ping (no drop)
msg = Message.Create(MessageCommand.Ping, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Pong (no drop)
msg = Message.Create(MessageCommand.Pong, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);

//synchronization
// GetHeaders (drop)
msg = Message.Create(MessageCommand.GetHeaders, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(true);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(true);
// Headers (no drop)
msg = Message.Create(MessageCommand.Headers, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// GetBlocks (drop)
msg = Message.Create(MessageCommand.GetBlocks, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(true);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(true);
// Mempool (drop)
msg = Message.Create(MessageCommand.Mempool, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(true);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(true);
// Inv (no drop)
msg = Message.Create(MessageCommand.Inv, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// GetData (drop)
msg = Message.Create(MessageCommand.GetData, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(true);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(true);
// NotFound (no drop)
msg = Message.Create(MessageCommand.NotFound, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Transaction (no drop)
msg = Message.Create(MessageCommand.Transaction, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Block (no drop)
msg = Message.Create(MessageCommand.Block, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Consensus (no drop)
msg = Message.Create(MessageCommand.Consensus, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// Reject (no drop)
msg = Message.Create(MessageCommand.Reject, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);

//SPV protocol
// FilterLoad (no drop)
msg = Message.Create(MessageCommand.FilterLoad, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// FilterAdd (no drop)
msg = Message.Create(MessageCommand.FilterAdd, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// FilterClear (no drop)
msg = Message.Create(MessageCommand.FilterClear, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
// MerkleBlock (no drop)
msg = Message.Create(MessageCommand.MerkleBlock, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);

//others
// Alert (no drop)
msg = Message.Create(MessageCommand.Alert, s);
uut.ShallDrop(msg, emptyQueue).Should().Be(false);
uut.ShallDrop(msg, new object[]{ msg }).Should().Be(false);
uut.ShallDrop(msg, new object[] { msg }).Should().Be(false);
}
}
}
2 changes: 1 addition & 1 deletion neo.UnitTests/UT_RemoteNodeMailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neo.UnitTests
{
[TestClass]
public class UT_RemoteNodeMailbox : TestKit
public class UT_RemoteNodeMailbox : TestKit
{
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism

Expand Down
4 changes: 2 additions & 2 deletions neo.UnitTests/UT_StorageItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Value_Get()
[TestMethod]
public void Value_Set()
{
byte[] val = new byte[] { 0x42, 0x32};
byte[] val = new byte[] { 0x42, 0x32 };
uut.Value = val;
uut.Value.Length.Should().Be(2);
uut.Value[0].Should().Be(val[0]);
Expand Down Expand Up @@ -56,7 +56,7 @@ public void Clone()
StorageItem newSi = ((ICloneable<StorageItem>)uut).Clone();
newSi.Value.Length.Should().Be(10);
newSi.Value[0].Should().Be(0x42);
for (int i=1; i<10; i++)
for (int i = 1; i < 10; i++)
{
newSi.Value[i].Should().Be(0x20);
}
Expand Down
8 changes: 4 additions & 4 deletions neo.UnitTests/UT_TaskManagerMailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Neo.UnitTests
{
[TestClass]
public class UT_TaskManagerMailbox : TestKit
public class UT_TaskManagerMailbox : TestKit
{
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism

Expand Down Expand Up @@ -42,12 +42,12 @@ public void TaskManager_Test_IsHighPriority()

// low priority
// -> NewTasks: generic InvPayload
uut.IsHighPriority(new TaskManager.NewTasks{ Payload = new InvPayload() }).Should().Be(false);
uut.IsHighPriority(new TaskManager.NewTasks { Payload = new InvPayload() }).Should().Be(false);

// high priority
// -> NewTasks: payload Block or Consensus
uut.IsHighPriority(new TaskManager.NewTasks{ Payload = new InvPayload{ Type = InventoryType.Block } }).Should().Be(true);
uut.IsHighPriority(new TaskManager.NewTasks{ Payload = new InvPayload{ Type = InventoryType.Consensus } }).Should().Be(true);
uut.IsHighPriority(new TaskManager.NewTasks { Payload = new InvPayload { Type = InventoryType.Block } }).Should().Be(true);
uut.IsHighPriority(new TaskManager.NewTasks { Payload = new InvPayload { Type = InventoryType.Consensus } }).Should().Be(true);

// any random object should not have priority
object obj = null;
Expand Down
4 changes: 2 additions & 2 deletions neo/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void OnCommitReceived(ConsensusPayload payload, Commit commit)
// this function increases existing timer (never decreases) with a value proportional to `maxDelayInBlockTimes`*`Blockchain.SecondsPerBlock`
private void ExtendTimerByFactor(int maxDelayInBlockTimes)
{
TimeSpan nextDelay = expected_delay - (TimeProvider.Current.UtcNow - clock_started) + TimeSpan.FromMilliseconds(maxDelayInBlockTimes*Blockchain.SecondsPerBlock * 1000.0 / context.M);
TimeSpan nextDelay = expected_delay - (TimeProvider.Current.UtcNow - clock_started) + TimeSpan.FromMilliseconds(maxDelayInBlockTimes * Blockchain.SecondsPerBlock * 1000.0 / context.M);
if (!context.WatchOnly && !context.ViewChanging && !context.CommitSent && (nextDelay > TimeSpan.Zero))
ChangeTimer(nextDelay);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ private void OnConsensusPayload(ConsensusPayload payload)
{
return;
}
context.LastSeenMessage[payload.ValidatorIndex] = (int) payload.BlockIndex;
context.LastSeenMessage[payload.ValidatorIndex] = (int)payload.BlockIndex;
foreach (IP2PPlugin plugin in Plugin.P2PPlugins)
if (!plugin.OnConsensusMessage(payload))
return;
Expand Down
2 changes: 1 addition & 1 deletion neo/Consensus/RecoveryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RecoveryRequest : ConsensusMessage

public override int Size => base.Size
+ sizeof(uint); //Timestamp

public RecoveryRequest() : base(ConsensusMessageType.RecoveryRequest) { }

public override void Deserialize(BinaryReader reader)
Expand Down
2 changes: 1 addition & 1 deletion neo/UIntBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Neo
{

/// <summary>
/// Base class for little-endian unsigned integers. Two classes inherit from this: UInt160 and UInt256.
/// Only basic comparison/serialization are proposed for these classes. For arithmetic purposes, use BigInteger class.
Expand Down