forked from neo-project/neo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shargon/indentation
THANKS MAN!
- Loading branch information
Showing
4 changed files
with
186 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,56 @@ | ||
using Akka.Actor; | ||
using Akka.TestKit.Xunit2; | ||
using Akka.TestKit.Xunit2; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.Network.P2P; | ||
using Neo.Network.P2P.Capabilities; | ||
using Neo.Network.P2P.Payloads; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace Neo.UnitTests | ||
{ | ||
[TestClass] | ||
public class UT_ProtocolHandler : TestKit | ||
{ | ||
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism | ||
[TestClass] | ||
public class UT_ProtocolHandler : TestKit | ||
{ | ||
private static readonly Random TestRandom = new Random(1337); // use fixed seed for guaranteed determinism | ||
|
||
private NeoSystem testBlockchain; | ||
private NeoSystem testBlockchain; | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
Shutdown(); | ||
} | ||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
Shutdown(); | ||
} | ||
|
||
[TestInitialize] | ||
public void TestSetup() | ||
{ | ||
Akka.Actor.ActorSystem system = Sys; | ||
var config = TestKit.DefaultConfig; | ||
var akkaSettings = new Akka.Actor.Settings(system, config); | ||
testBlockchain = TestBlockchain.InitializeMockNeoSystem(); | ||
} | ||
[TestInitialize] | ||
public void TestSetup() | ||
{ | ||
Akka.Actor.ActorSystem system = Sys; | ||
var config = TestKit.DefaultConfig; | ||
var akkaSettings = new Akka.Actor.Settings(system, config); | ||
testBlockchain = TestBlockchain.InitializeMockNeoSystem(); | ||
} | ||
|
||
[TestMethod] | ||
public void ProtocolHandler_Test_SendVersion_TellParent() | ||
{ | ||
var senderProbe = CreateTestProbe(); | ||
var parent = CreateTestProbe(); | ||
var protocolActor = ActorOfAsTestActorRef<ProtocolHandler>(()=> new ProtocolHandler(testBlockchain, parent)); | ||
|
||
var payload = new VersionPayload() | ||
{ | ||
UserAgent = "".PadLeft(1024, '0'), | ||
Nonce = 1, | ||
Magic = 2, | ||
Timestamp = 5, | ||
Version = 6, | ||
Capabilities = new NodeCapability[] | ||
{ | ||
new ServerCapability(NodeCapabilityType.TcpServer, 25) | ||
} | ||
}; | ||
[TestMethod] | ||
public void ProtocolHandler_Test_SendVersion_TellParent() | ||
{ | ||
var senderProbe = CreateTestProbe(); | ||
var parent = CreateTestProbe(); | ||
var protocolActor = ActorOfAsTestActorRef<ProtocolHandler>(() => new ProtocolHandler(testBlockchain, parent)); | ||
|
||
senderProbe.Send(protocolActor, Message.Create(MessageCommand.Version, payload)); | ||
parent.ExpectMsg<VersionPayload>(); | ||
} | ||
} | ||
var payload = new VersionPayload() | ||
{ | ||
UserAgent = "".PadLeft(1024, '0'), | ||
Nonce = 1, | ||
Magic = 2, | ||
Timestamp = 5, | ||
Version = 6, | ||
Capabilities = new NodeCapability[] | ||
{ | ||
new ServerCapability(NodeCapabilityType.TcpServer, 25) | ||
} | ||
}; | ||
|
||
|
||
senderProbe.Send(protocolActor, Message.Create(MessageCommand.Version, payload)); | ||
parent.ExpectMsg<VersionPayload>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.