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

[Neo Plugin UT] Rpcserver unit test on node #3353

Merged
merged 33 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d1eab9a
try mock
Jim8y Jun 14, 2024
9b238ec
Merge branch 'master' into mock-rpcserver-test
Jim8y Jun 14, 2024
dff3c79
not use mock
Jim8y Jun 14, 2024
cb5c875
test
Jim8y Jun 14, 2024
cccab76
fix test
Jim8y Jun 15, 2024
ef6b001
use neo testutils
Jim8y Jun 16, 2024
3c43399
complete rpcserver blockchain tests.
Jim8y Jun 16, 2024
0c90df1
revert change to ByteArrayComparer
Jim8y Jun 16, 2024
bee3102
revert cache change
Jim8y Jun 16, 2024
a674ec7
add more detail to comments
Jim8y Jun 16, 2024
cdc2b41
add more exception test cases
Jim8y Jun 16, 2024
a58e05f
fix warning
Jim8y Jun 16, 2024
02f3264
Apply suggestions from code review
shargon Jun 16, 2024
d8b67b3
update TODO mark
Jim8y Jun 16, 2024
b5d5bfd
Merge branch 'mock-rpcserver-test' of github.com:Jim8y/neo into mock-…
Jim8y Jun 16, 2024
98beb3d
Merge branch 'master' into mock-rpcserver-test
Jim8y Jun 19, 2024
a4c7638
add node rpc tests
Jim8y Jun 24, 2024
1b92a11
Merge branch 'master' into rpcserver_test_node
Jim8y Jun 24, 2024
92858b2
fix build error
Jim8y Jun 26, 2024
5a1918e
Merge branch 'master' into rpcserver_test_node
Jim8y Jun 26, 2024
d39b9dc
set the mempool to 5.
Jim8y Jun 26, 2024
0a43d30
Merge branch 'rpcserver_test_node' of github.com:Jim8y/neo into rpcse…
Jim8y Jun 26, 2024
3e91a32
remove memory pool test.
Jim8y Jun 26, 2024
d1a0058
Merge branch 'master' into rpcserver_test_node
Jim8y Jul 4, 2024
46c0216
fix tests
Jim8y Jul 4, 2024
d8bc36a
fix test issue
Jim8y Jul 5, 2024
4f19409
Merge branch 'master' into rpcserver_test_node
shargon Jul 5, 2024
4841d19
Update tests/Neo.UnitTests/TestUtils.Transaction.cs
shargon Jul 5, 2024
38724a7
Merge branch 'master' into rpcserver_test_node
shargon Jul 5, 2024
c4f4e0b
Merge branch 'master' into rpcserver_test_node
Jim8y Jul 10, 2024
b52b81f
Merge branch 'master' into rpcserver_test_node
NGDAdmin Jul 11, 2024
e092c65
Merge branch 'master' into rpcserver_test_node
NGDAdmin Jul 11, 2024
1a52f19
Merge branch 'master' into rpcserver_test_node
NGDAdmin Jul 11, 2024
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
21 changes: 21 additions & 0 deletions src/Neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,5 +659,26 @@ internal bool ReVerifyTopUnverifiedTransactionsIfNeeded(int maxToVerify, DataCac

return _unverifiedTransactions.Count > 0;
}

#if DEBUG
// This method is only for test purpose
// Do not remove it from the DEBUG build
internal void Clear()
Comment on lines +663 to +666
Copy link
Member

@shargon shargon Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it doesn't hurt without debug, it's already internal, but it's ok for me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we compile in release maybe it fault because the UT require this method

Copy link
Member

@cschuchardt88 cschuchardt88 Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then add to test the same way as #if DEBUG

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jim8y we need to compile the whole sln in release, I think it won't work with this change

{
_txRwLock.EnterReadLock();
try
{
_unsortedTransactions.Clear();
_conflicts.Clear();
_sortedTransactions.Clear();
_unverifiedTransactions.Clear();
_unverifiedSortedTransactions.Clear();
}
finally
{
_txRwLock.ExitReadLock();
}
}
#endif
}
}
6 changes: 3 additions & 3 deletions src/Plugins/RpcServer/RpcServer.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static JObject GetRelayResult(VerifyResult reason, UInt256 hash)
}

[RpcMethod]
protected virtual JToken GetVersion(JArray _params)
protected internal virtual JToken GetVersion(JArray _params)
{
JObject json = new();
json["tcpport"] = localNode.ListenerTcpPort;
Expand Down Expand Up @@ -150,15 +150,15 @@ private static string StripPrefix(string s, string prefix)
}

[RpcMethod]
protected virtual JToken SendRawTransaction(JArray _params)
protected internal virtual JToken SendRawTransaction(JArray _params)
{
Transaction tx = Result.Ok_Or(() => Convert.FromBase64String(_params[0].AsString()).AsSerializable<Transaction>(), RpcError.InvalidParams.WithData($"Invalid Transaction Format: {_params[0]}"));
RelayResult reason = system.Blockchain.Ask<RelayResult>(tx).Result;
return GetRelayResult(reason.Result, tx.Hash);
}

[RpcMethod]
protected virtual JToken SubmitBlock(JArray _params)
protected internal virtual JToken SubmitBlock(JArray _params)
{
Block block = Result.Ok_Or(() => Convert.FromBase64String(_params[0].AsString()).AsSerializable<Block>(), RpcError.InvalidParams.WithData($"Invalid Block Format: {_params[0]}"));
RelayResult reason = system.Blockchain.Ask<RelayResult>(block).Result;
Expand Down
49 changes: 0 additions & 49 deletions tests/Neo.Plugins.RpcServer.Tests/TestBlockchain.cs

This file was deleted.

65 changes: 0 additions & 65 deletions tests/Neo.Plugins.RpcServer.Tests/TestProtocolSettings.cs

This file was deleted.

6 changes: 4 additions & 2 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using Akka.Actor;
using Akka.Util.Internal;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.IO;
Expand Down Expand Up @@ -101,8 +102,9 @@ public void TestGetBlockHash()
{
var snapshot = _neoSystem.GetSnapshot();
var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 3);
TestUtils.BlocksAdd(snapshot, block.Hash, block);
snapshot.Commit();
// TestUtils.BlocksAdd(snapshot, block.Hash, block);
// snapshot.Commit();
var reason = _neoSystem.Blockchain.Ask<Blockchain.RelayResult>(block).Result;
var expectedHash = block.Hash.ToString();
var result = _rpcServer.GetBlockHash(new JArray(block.Index));
Assert.AreEqual(expectedHash, result.AsString());
Expand Down
Loading
Loading