Skip to content

Commit

Permalink
refactoring (#288)
Browse files Browse the repository at this point in the history
* refactoring

* message priority

* add failure reason for `sendrawtransaction` (neo-project/neo-node#116)

* fix bug in `sendrawtransaction`

* improve RpcServer and Plugin system

* add `unconnected` to RPC command `getpeers`

* update dependencies:

- Microsoft.AspNetCore.ResponseCompression v2.1.1
- Microsoft.AspNetCore.Server.Kestrel v2.1.1
- Microsoft.AspNetCore.Server.Kestrel.Https v2.1.1
- Microsoft.EntityFrameworkCore.Sqlite v2.1.1
- Microsoft.Extensions.Configuration.Json v2.1.1

* add WebSocket

* fix bug in Snapshot.Dispose()

* Hides the caught exceptions logs in `RemoteNode`

* fix block stuck

* fix bug in p2p connection

* fix #305

* fix consensus

* checked on Fixed8 mul

* solve the problem of disconnecting from peers

* fix bug in `System.Runtime.GetTime`

* add RPC command: `getwalletheight`

* fix p2p bug

* Prevent error messages when exiting

* optimize p2p network

* allow user interface to send messages to plugins

* change version to 2.9.0

* backward compatible for sendrawtransaction

* Solve the problem of resynchronizing blocks

* put unverified transactions in the memory pool back into the message queue after the block is persisted

* minor change to consensus
  • Loading branch information
erikzhang authored Sep 14, 2018
1 parent b8ad89e commit c64748e
Show file tree
Hide file tree
Showing 190 changed files with 5,840 additions and 6,623 deletions.
1 change: 0 additions & 1 deletion neo.UnitTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Coverage
* Header.cs
* Helper.cs
* InvocationTransaction.cs
* IssueTransaction.cs
* MinerTransaction.cs
* SpentCoin.cs
* SpentCoinState.cs
Expand Down
161 changes: 0 additions & 161 deletions neo.UnitTests/TestBlockchain.cs

This file was deleted.

10 changes: 9 additions & 1 deletion neo.UnitTests/TestMetaDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@

namespace Neo.UnitTests
{
public class TestMetaDataCache<T> : MetaDataCache<T> where T : class, ISerializable, new()
public class TestMetaDataCache<T> : MetaDataCache<T> where T : class, ICloneable<T>, ISerializable, new()
{
public TestMetaDataCache()
: base(null)
{
}

protected override void AddInternal(T item)
{
}

protected override T TryGetInternal()
{
return null;
}

protected override void UpdateInternal(T item)
{
}
}
}
5 changes: 1 addition & 4 deletions neo.UnitTests/TestTransaction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Neo.Core;
using System;
using System.Collections.Generic;
using System.Text;
using Neo.Network.P2P.Payloads;

namespace Neo.UnitTests
{
Expand Down
61 changes: 6 additions & 55 deletions neo.UnitTests/TestUtils.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.Cryptography.ECC;
using Neo.Network.P2P.Payloads;
using Neo.VM;
using Neo.Wallets;
using Neo.SmartContract;
using System;

namespace Neo.UnitTests
{
Expand All @@ -30,7 +28,7 @@ public static ClaimTransaction GetClaimTransaction()
Attributes = new TransactionAttribute[0],
Inputs = new CoinReference[0],
Outputs = new TransactionOutput[0],
Scripts = new Witness[0]
Witnesses = new Witness[0]
};
}

Expand All @@ -42,48 +40,7 @@ public static MinerTransaction GetMinerTransaction()
Attributes = new TransactionAttribute[0],
Inputs = new CoinReference[0],
Outputs = new TransactionOutput[0],
Scripts = new Witness[0]
};
}

public static IssueTransaction GetIssueTransaction(bool inputVal, decimal outputVal, UInt256 assetId)
{
TestUtils.SetupTestBlockchain(assetId);

CoinReference[] inputsVal;
if (inputVal)
{
inputsVal = new[]
{
TestUtils.GetCoinReference(null)
};
}
else
{
inputsVal = new CoinReference[0];
}

return new IssueTransaction
{
Attributes = new TransactionAttribute[0],
Inputs = inputsVal,
Outputs = new[]
{
new TransactionOutput
{
AssetId = assetId,
Value = Fixed8.FromDecimal(outputVal),
ScriptHash = Contract.CreateMultiSigRedeemScript(1, TestUtils.StandbyValidators).ToScriptHash()
}
},
Scripts = new[]
{
new Witness
{
InvocationScript = new byte[0],
VerificationScript = new[] { (byte)OpCode.PUSHT }
}
}
Witnesses = new Witness[0]
};
}

Expand All @@ -97,12 +54,6 @@ public static CoinReference GetCoinReference(UInt256 prevHash)
};
}

public static void SetupTestBlockchain(UInt256 assetId)
{
Blockchain testBlockchain = new TestBlockchain(assetId);
Blockchain.RegisterBlockchain(testBlockchain);
}

public static void SetupHeaderWithValues(Header header, UInt256 val256, out UInt256 merkRootVal, out UInt160 val160, out uint timestampVal, out uint indexVal, out ulong consensusDataVal, out Witness scriptVal)
{
setupBlockBaseWithValues(header, val256, out merkRootVal, out val160, out timestampVal, out indexVal, out consensusDataVal, out scriptVal);
Expand Down Expand Up @@ -142,7 +93,7 @@ private static void setupBlockBaseWithValues(BlockBase bb, UInt256 val256, out U
InvocationScript = new byte[0],
VerificationScript = new[] { (byte)OpCode.PUSHT }
};
bb.Script = scriptVal;
bb.Witness = scriptVal;
}
}
}
7 changes: 4 additions & 3 deletions neo.UnitTests/TestVerifiable.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using System;
using System.IO;
using Neo.Core;

namespace Neo.UnitTests
{
public class TestVerifiable : IVerifiable
{
private string testStr = "testStr";

public Witness[] Scripts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public Witness[] Witnesses { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public int Size => throw new NotImplementedException();

Expand All @@ -27,7 +28,7 @@ public byte[] GetMessage()
throw new NotImplementedException();
}

public UInt160[] GetScriptHashesForVerifying()
public UInt160[] GetScriptHashesForVerifying(Snapshot snapshot)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion neo.UnitTests/UT_AccountState.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.IO;
using Neo.Ledger;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down
3 changes: 2 additions & 1 deletion neo.UnitTests/UT_AssetState.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.IO;
using Neo.Ledger;
using Neo.Network.P2P.Payloads;
using System.Globalization;
using System.IO;
using System.Text;
Expand Down
Loading

0 comments on commit c64748e

Please sign in to comment.