Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions Monero.IntegrationTests/Monero.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"/>
<PackageReference Include="coverlet.collector" Version="8.0.1"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0"/>
<PackageReference Include="xunit.v3" Version="3.2.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Monero.IntegrationTests/MoneroDaemonRpcIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public async Task TestMining()
// start mining
await _daemon.StartMining(address, 1, false, true);

GenUtils.WaitFor(30);
await GenUtils.WaitForAsync(30, Xunit.TestContext.Current.CancellationToken);

// stop mining
await _daemon.StopMining();
Expand Down Expand Up @@ -760,7 +760,7 @@ public async Task TestStop()
await _daemon.Stop();

// give the daemon time to shut down
GenUtils.WaitFor(TestUtils.SyncPeriodInMs);
await GenUtils.WaitForAsync(TestUtils.SyncPeriodInMs, Xunit.TestContext.Current.CancellationToken);
// try to interact with the daemon
try
{
Expand Down
4 changes: 2 additions & 2 deletions Monero.IntegrationTests/MoneroRpcConnectionIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public async Task TestWalletRpcConnection()
[Fact]
public async Task TestSendRequest()
{
// Setup connection
// 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);
var jsonResponse = await connection.SendCommandAsync<NoRequestModel, MoneroDaemonInfo>("get_info", NoRequestModel.Instance, Xunit.TestContext.Current.CancellationToken);

Assert.NotNull(jsonResponse);
Assert.Null(jsonResponse.Error);
Expand Down
22 changes: 16 additions & 6 deletions Monero.IntegrationTests/MoneroWalletRpcIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,27 @@ public async Task TestGetSubaddressAddressOutOfRange()
public async Task TestGetHeight()
{
ulong lastHeight = await _wallet.GetHeight();

await _daemon.WaitForNextBlockHeader();

GenUtils.WaitFor(2000);

var syncResult = await _wallet.Sync(null, null);
const int maxRetries = 15;
const int delayMs = 1000;
bool blockFetched = false;
ulong currentHeight = lastHeight;

Assert.True(syncResult.NumBlocksFetched > 0, "No blocks fetched from wallet sync");
for (int i = 0; i < maxRetries; i++)
{
var syncResult = await _wallet.Sync(null, null);
currentHeight = await _wallet.GetHeight();

ulong currentHeight = await _wallet.GetHeight();
if (syncResult.NumBlocksFetched > 0 && currentHeight > lastHeight)
{
blockFetched = true;
break;
}
await GenUtils.WaitForAsync(delayMs, Xunit.TestContext.Current.CancellationToken);
}

Assert.True(blockFetched, $"No blocks fetched after {maxRetries}s. Last height: {lastHeight}, current height: {currentHeight}");
Assert.True(currentHeight > lastHeight, $"Expected currentHeight: {currentHeight} > lastHeight: {lastHeight}");
}

Expand Down
8 changes: 4 additions & 4 deletions Monero.UnitTests/Monero.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0"/>
<PackageReference Include="xunit.v3" Version="3.2.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PackageReference Include="coverlet.collector" Version="8.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
11 changes: 2 additions & 9 deletions Monero/Common/GenUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,8 @@ public static string GetGuid()
return subarray;
}

public static void WaitFor(int durationMs)
public static async Task WaitForAsync(int durationMs, CancellationToken cancellationToken)
{
try
{
Thread.Sleep(durationMs);
}
catch (ThreadInterruptedException)
{
throw new Exception("Thread was interrupted while sleeping");
}
await Task.Delay(durationMs, cancellationToken);
}
}
Loading