Skip to content

[Plugin UT] add more rpcserver UTs #3864

New issue

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

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

Already on GitHub? # to your account

Merged
merged 5 commits into from
Apr 2, 2025
Merged

[Plugin UT] add more rpcserver UTs #3864

merged 5 commits into from
Apr 2, 2025

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Apr 1, 2025

Description

This pr adds missing uts for rpcserver

Fixes # (issue)

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Running all UTs.

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y Jim8y marked this pull request as draft April 1, 2025 06:34
@Jim8y Jim8y marked this pull request as ready for review April 1, 2025 08:01
@Jim8y Jim8y requested review from Copilot and NGDAdmin April 1, 2025 08:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds comprehensive unit tests for various aspects of the rpcserver functionality including POST request processing, wallet operations, smart contract invocations, node peer handling, blockchain queries, and storage lookup. Key changes include:

  • The introduction of new test helper methods and test cases in UT_RpcServer.cs to simulate POST requests.
  • Additional unit tests in UT_RpcServer.Wallet.cs, UT_RpcServer.Utilities.cs, UT_RpcServer.SmartContract.cs, UT_RpcServer.Node.cs, and UT_RpcServer.Blockchain.cs covering error cases and edge scenarios.
  • Enhancements to verify pagination, invalid input handling, and diagnostic outputs in the blockchain and smart contract tests.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.cs Adds helper method SimulatePostRequest and tests for malformed JSON and batch requests.
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Wallet.cs Introduces tests covering DumpPrivKey, wallet balance queries, and key import conditions.
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Utilities.cs Adds tests for address validation covering empty strings, wrong length, and invalid checksum scenarios.
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs Adds tests for various error scenarios in contract invocation and script execution.
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs Introduces tests for peer status and version information.
tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs Implements tests for block retrieval, mempool state, storage pagination, and transaction queries.
Comments suppressed due to low confidence (1)

tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs:282

  • The array initializer syntax used inside the new JArray constructor (i.e. '[' and ']') is non‐standard. Consider replacing it with new JArray(item1, item2, …) or using a valid collection initializer for JArray.
var invalidParams = new JArray([

Copy link
Contributor

@Wi1l-B0t Wi1l-B0t left a comment

Choose a reason for hiding this comment

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

There are many lines that are too long.
Can the be made shorter?

shargon and others added 2 commits April 1, 2025 19:53
Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
@Jim8y
Copy link
Contributor Author

Jim8y commented Apr 1, 2025

There are many lines that are too long. Can the be made shorter?

style can alwayse updated later.

@NGDAdmin NGDAdmin merged commit 31851f4 into master Apr 2, 2025
7 checks passed
@NGDAdmin NGDAdmin deleted the rpcserver-ut branch April 2, 2025 05:52
Jim8y added a commit to Jim8y/neo that referenced this pull request Apr 9, 2025
* master: (163 commits)
  [style] Added some var styles (neo-project#3867)
  [`fix`] stop syncing on block 1465790 (neo-project#3888)
  Optimize block deserialization (neo-project#3879)
  Avoid double `ToArray` on `OnInvMessageReceived` (neo-project#3875)
  style: format long lines (neo-project#3884)
  optimize: return GetFileNameWithoutExtension(Path) if name is not set (neo-project#3883)
  Fix possible null exception (neo-project#3880)
  Remove linkedList (neo-project#3873)
  Optimize Uint160 and Uint256 constructor (neo-project#3872)
  Release the resources (neo-project#3868)
  [Clean] Remove `IRawReadOnlyStore` (neo-project#3869)
  move non-plugins out of plugins (neo-project#3863)
  feature: set name when create wallet (neo-project#3866)
  Native: swap Policy's `[get/set]AttributeFee` implementations (neo-project#3859)
  Fix: concurrent conflict in Cache.CopyTo (neo-project#3860)
  Fix: add default key parameter in help cmd (neo-project#3865)
  [Plugin UT] add more rpcserver UTs (neo-project#3864)
  config: upgrade NeoFS chains protocol configuration (neo-project#3858)
  [`Optimization`]: add exception message to `ArgumentException` (neo-project#3862)
  Native: unify arguments naming of CryptoLib's `verifyWith*` methods (neo-project#3855)
  ...

# Conflicts:
#	benchmarks/Neo.VM.Benchmarks/OpCode/Arrays/OpCode.ReverseN.cs
#	benchmarks/Neo.VM.Benchmarks/Program.cs
#	src/Neo/Neo.csproj
#	src/Neo/ProtocolSettings.cs
#	src/Neo/SmartContract/ApplicationEngine.cs
#	src/Neo/SmartContract/Native/NeoToken.cs
#	src/Neo/SmartContract/Native/RoleManagement.cs
#	tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs
#	tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractPermission.cs
#	tests/Neo.UnitTests/SmartContract/Native/UT_NativeContract.cs
#	tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs
#	tests/Neo.UnitTests/UT_ProtocolSettings.cs
#	tests/Neo.VM.Tests/UT_ReferenceCounter.cs
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants