-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix GetTransactionFromBlock Syscall (#1170) * Fix Syscall * Fix * Unit Test for Smartcontract Module (#1090) * submit ut * fix * Enhance functions in TestDataCache * git amend blockchain * fix test related to TestDataCache * dotnet format * dotnet format * add blank line * fix test * Optimize random * Optimize Random * fix test * add decimal test * fix * 2019/9/25 16:54 change format * Fixes events * update assertion sentence * update UT following code change * format * add type check * recommit * recommit * Ensure txs are cleared before Blockchain actor (#1166) * Unit Test For RPC Module (#1111) * fix payload limits (#1194) * Fix JsonSerializer (#1197) * Fix #1128 (#1129) * Fix #1128 * Update BlockBase.cs * Add shutdown event for plugins (#1195) * add shutdown event for plugins * use IDisposable * dispose plugins first * Removing brackets * Replace function exceptwith and unionwith with faster functions (#1174) * Replace ExceptWith & UnionWith with equal but faster functionality * Optimization * Optimization * Optimize remove * Update neo/Network/P2P/TaskManager.cs Co-Authored-By: Erik Zhang <erik@neo.org> * Code optimization * Update Helper.cs * Small change * Optimization * Update Helper.cs * Revert * Optimization * Optimize FIFOSet * Rename * Inline * Update UT_FIFOSet.cs * Fix * Update UT_FIFOSet.cs * Update FIFOSet.cs * Update FIFOSet.cs * Revert FIFOSet * Update Helper.cs * Optimize * Reverting independet byte checks to SequenceEqual * Unit tests for some auxiliary classes (#1192) * Fix p2p filter unconnected peers (#1160) * Remove the case of GetData in ProtocolHandlerMailbox#ShallDrop (#1201) * Add GetFullBlocks P2P logic (enable fixing #522) (#1138) * add GetFullBlocks P2P logic * add missing new line * allow request genesis block * Optimization * Update MessageCommand.cs * - rename command - fix protocol handler cast - fix payload deserialization for default value * change to ushort per review * remove default count, rename class * typo + failed refactor coverage ¯\_(ツ)_/¯ * Use base64 in JsonSerializer (#1199) * Base64 Json * No format * Json Transaction optimization * Change to Base64 * Revert some changes * Revert * Remove Helper.Base64 * Remove Base64FormattingOptions.None * Optimize MerkleTree (3x) (#1203) * Optimize MerkleTree * Update MerkleTree.cs * Update MerkleTree.cs * Added more verbosity to CN logs (#1202) * Add reason log for cn * Update ConsensusService.cs * Keep track of sender fee (#1183) * Keep track of sender fee to avoid duplicate computation * Code optimization * Optimize * Optimize * Optimize * Code optimization * Correction * Renaming currentFee to totalSenderFeeFromPool * Renaming on Verify as well * Add consideration for null Transactions * Move sender fee recording systems to class SendersMonitor * Code optimization * Capitalize public items * Code optimization * Code optimization * Optimization * Code optimization * Using problem description (#1214) Using problem description helps problem grouping (people may propose different solutions for the same problem) * Improve SYSCALLs: `Neo.Crypto.*` (#1190) * Prevent XXE (3x) (#1229) * Remove unnecessary logic from Mempool (#1216) * Prevent remove storage flag when there are something stored (#1227) * Add NeoAPI and update code after testing with NEO3 preview1 (#1150)
- Loading branch information
Showing
126 changed files
with
6,285 additions
and
296 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
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 |
---|---|---|
|
@@ -255,3 +255,4 @@ paket-files/ | |
*.sln.iml | ||
|
||
PublishProfiles | ||
/.vscode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.IO; | ||
|
||
namespace Neo.UnitTests.IO | ||
{ | ||
[TestClass] | ||
public class UT_ByteArrayComparer | ||
{ | ||
[TestMethod] | ||
public void TestCompare() | ||
{ | ||
ByteArrayComparer comparer = new ByteArrayComparer(); | ||
byte[] x = new byte[0], y = new byte[0]; | ||
comparer.Compare(x, y).Should().Be(0); | ||
|
||
x = new byte[] { 1 }; | ||
comparer.Compare(x, y).Should().Be(1); | ||
y = x; | ||
comparer.Compare(x, y).Should().Be(0); | ||
|
||
x = new byte[] { 1 }; | ||
y = new byte[] { 2 }; | ||
comparer.Compare(x, y).Should().Be(-1); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using Neo.Ledger; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.Persistence; | ||
using System; | ||
using System.Numerics; | ||
|
||
namespace Neo.UnitTests.Ledger | ||
{ | ||
[TestClass] | ||
public class UT_SendersFeeMonitor | ||
{ | ||
private Transaction CreateTransactionWithFee(long networkFee, long systemFee) | ||
{ | ||
Random random = new Random(); | ||
var randomBytes = new byte[16]; | ||
random.NextBytes(randomBytes); | ||
Mock<Transaction> mock = new Mock<Transaction>(); | ||
mock.Setup(p => p.Reverify(It.IsAny<Snapshot>(), It.IsAny<BigInteger>())).Returns(true); | ||
mock.Setup(p => p.Verify(It.IsAny<Snapshot>(), It.IsAny<BigInteger>())).Returns(true); | ||
mock.Object.Script = randomBytes; | ||
mock.Object.Sender = UInt160.Zero; | ||
mock.Object.NetworkFee = networkFee; | ||
mock.Object.SystemFee = systemFee; | ||
mock.Object.Attributes = new TransactionAttribute[0]; | ||
mock.Object.Cosigners = new Cosigner[0]; | ||
mock.Object.Witnesses = new[] | ||
{ | ||
new Witness | ||
{ | ||
InvocationScript = new byte[0], | ||
VerificationScript = new byte[0] | ||
} | ||
}; | ||
return mock.Object; | ||
} | ||
|
||
[TestMethod] | ||
public void TestMemPoolSenderFee() | ||
{ | ||
Transaction transaction = CreateTransactionWithFee(1, 2); | ||
SendersFeeMonitor sendersFeeMonitor = new SendersFeeMonitor(); | ||
sendersFeeMonitor.GetSenderFee(transaction.Sender).Should().Be(0); | ||
sendersFeeMonitor.AddSenderFee(transaction); | ||
sendersFeeMonitor.GetSenderFee(transaction.Sender).Should().Be(3); | ||
sendersFeeMonitor.AddSenderFee(transaction); | ||
sendersFeeMonitor.GetSenderFee(transaction.Sender).Should().Be(6); | ||
sendersFeeMonitor.RemoveSenderFee(transaction); | ||
sendersFeeMonitor.GetSenderFee(transaction.Sender).Should().Be(3); | ||
sendersFeeMonitor.RemoveSenderFee(transaction); | ||
sendersFeeMonitor.GetSenderFee(transaction.Sender).Should().Be(0); | ||
} | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.Network.RPC.Models; | ||
using System; | ||
|
||
namespace Neo.UnitTests.Network.RPC.Models | ||
{ | ||
[TestClass] | ||
public class UT_RpcBlock | ||
{ | ||
[TestMethod] | ||
public void TestToJson() | ||
{ | ||
var rpcBlock = new RpcBlock(); | ||
var block = new Block(); | ||
TestUtils.SetupBlockWithValues(block, UInt256.Zero, out UInt256 _, out UInt160 _, out ulong _, out uint _, out Witness _, out Transaction[] _, 1); | ||
rpcBlock.Block = block; | ||
var json = rpcBlock.ToJson(); | ||
json["previousblockhash"].AsString().Should().Be("0x0000000000000000000000000000000000000000000000000000000000000000"); | ||
json.Should().NotBeNull(); | ||
|
||
rpcBlock.Confirmations = 1; | ||
rpcBlock.NextBlockHash = UInt256.Zero; | ||
json = rpcBlock.ToJson(); | ||
json["confirmations"].AsNumber().Should().Be(1); | ||
} | ||
} | ||
} |
Oops, something went wrong.