forked from btcpay-monero/monero-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoneroRpcConnectionIntegrationTest.cs
More file actions
64 lines (46 loc) · 1.91 KB
/
Copy pathMoneroRpcConnectionIntegrationTest.cs
File metadata and controls
64 lines (46 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Monero.Common;
using Monero.Daemon.Common;
using Monero.IntegrationTests.Utils;
using Xunit;
namespace Monero.IntegrationTests;
public class MoneroRpcConnectionIntegrationTest
{
// Can connect to node
[Fact]
public async Task TestNodeRpcConnection()
{
MoneroRpcConnection connection = new(TestUtils.DaemonRpcUri, TestUtils.DaemonRpcUsername, TestUtils.DaemonRpcPassword);
await TestConnection(connection, TestUtils.DaemonRpcUri.AbsoluteUri);
}
// Can connect to wallet
[Fact]
public async Task TestWalletRpcConnection()
{
MoneroRpcConnection connection = new(TestUtils.PrimaryWalletRpcUri, TestUtils.WalletRpcUsername, TestUtils.WalletRpcPassword);
await TestConnection(connection, TestUtils.PrimaryWalletRpcUri.AbsoluteUri);
}
// Can send a request to RPC
[Fact]
public async Task TestSendRequest()
{
// Set up a connection
MoneroRpcConnection connection = new(TestUtils.DaemonRpcUri, TestUtils.DaemonRpcUsername, TestUtils.DaemonRpcPassword);
await TestConnection(connection, TestUtils.DaemonRpcUri.AbsoluteUri);
// Test monerod JSON request
var jsonResponse = await connection.SendCommandAsync<NoRequestModel, MoneroDaemonInfo>("get_info", NoRequestModel.Instance, Xunit.TestContext.Current.CancellationToken);
Assert.NotNull(jsonResponse);
Assert.Null(jsonResponse.Error);
// Test monerod PATH request
MoneroDaemonInfo pathResponse = await connection.SendPathRequest<MoneroDaemonInfo>("get_info", []);
Assert.NotNull(pathResponse);
Assert.Null(pathResponse.Error);
}
private static Task TestConnection(MoneroRpcConnection? connection, string? uri)
{
Assert.NotNull(connection);
Assert.NotNull(uri);
Assert.NotEmpty(uri);
Assert.Equal(uri, connection.GetUri());
return Task.CompletedTask;
}
}