Skip to content

Commit

Permalink
[Neo Plugin RpcServer UT]Plugin rpcserver wallet UTs (#3433)
Browse files Browse the repository at this point in the history
* wallet

* fix util

* add comments and fix ut

* Update tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Wallet.cs

* remove comment

---------

Co-authored-by: Christopher Schuchardt <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: NGD Admin <[email protected]>
  • Loading branch information
4 people committed Jul 29, 2024
1 parent eb167b3 commit c2141e8
Show file tree
Hide file tree
Showing 7 changed files with 785 additions and 204 deletions.
2 changes: 1 addition & 1 deletion src/Plugins/RpcServer/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class Result
/// <typeparam name="T">The return type</typeparam>
/// <returns>The execution result</returns>
/// <exception cref="RpcException">The Rpc exception</exception>
public static T Ok_Or<T>(this Func<T> function, RpcError err, bool withData = false)
public static T Ok_Or<T>(Func<T> function, RpcError err, bool withData = false)
{
try
{
Expand Down
10 changes: 5 additions & 5 deletions src/Plugins/RpcServer/RpcServer.SmartContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static Witness[] WitnessesFromJson(JArray _params)
}

[RpcMethod]
protected virtual JToken InvokeFunction(JArray _params)
protected internal virtual JToken InvokeFunction(JArray _params)
{
UInt160 script_hash = Result.Ok_Or(() => UInt160.Parse(_params[0].AsString()), RpcError.InvalidParams.WithData($"Invalid script hash {nameof(script_hash)}"));
string operation = Result.Ok_Or(() => _params[1].AsString(), RpcError.InvalidParams);
Expand All @@ -231,7 +231,7 @@ protected virtual JToken InvokeFunction(JArray _params)
}

[RpcMethod]
protected virtual JToken InvokeScript(JArray _params)
protected internal virtual JToken InvokeScript(JArray _params)
{
byte[] script = Result.Ok_Or(() => Convert.FromBase64String(_params[0].AsString()), RpcError.InvalidParams);
Signer[] signers = _params.Count >= 2 ? SignersFromJson((JArray)_params[1], system.Settings) : null;
Expand All @@ -241,7 +241,7 @@ protected virtual JToken InvokeScript(JArray _params)
}

[RpcMethod]
protected virtual JToken TraverseIterator(JArray _params)
protected internal virtual JToken TraverseIterator(JArray _params)
{
settings.SessionEnabled.True_Or(RpcError.SessionsDisabled);
Guid sid = Result.Ok_Or(() => Guid.Parse(_params[0].GetString()), RpcError.InvalidParams.WithData($"Invalid session id {nameof(sid)}"));
Expand All @@ -262,7 +262,7 @@ protected virtual JToken TraverseIterator(JArray _params)
}

[RpcMethod]
protected virtual JToken TerminateSession(JArray _params)
protected internal virtual JToken TerminateSession(JArray _params)
{
settings.SessionEnabled.True_Or(RpcError.SessionsDisabled);
Guid sid = Result.Ok_Or(() => Guid.Parse(_params[0].GetString()), RpcError.InvalidParams.WithData("Invalid session id"));
Expand All @@ -278,7 +278,7 @@ protected virtual JToken TerminateSession(JArray _params)
}

[RpcMethod]
protected virtual JToken GetUnclaimedGas(JArray _params)
protected internal virtual JToken GetUnclaimedGas(JArray _params)
{
string address = Result.Ok_Or(() => _params[0].AsString(), RpcError.InvalidParams.WithData($"Invalid address {nameof(address)}"));
JObject json = new();
Expand Down
188 changes: 169 additions & 19 deletions src/Plugins/RpcServer/RpcServer.Wallet.cs

Large diffs are not rendered by default.

Loading

0 comments on commit c2141e8

Please sign in to comment.