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
47 changes: 47 additions & 0 deletions Monero.IntegrationTests/MiningFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using NUnit.Framework;

namespace Monero.IntegrationTests;

[SetUpFixture]
public class MiningFixture : MoneroIntegrationTestBase
{
[OneTimeSetUp]
public async Task RunBeforeAnyTests()
{
await MineToHeight(10);
}

[OneTimeTearDown]
public async Task RunAfterAllTests()
{
await TestUtils.GetDaemonRpc().StopMining();
}

private static async Task MineToHeight(ulong targetHeight)
{
var daemon = TestUtils.GetDaemonRpc();

var currentHeight = await daemon.GetHeight();
if (currentHeight >= targetHeight) return;

var miningStatus = await daemon.GetMiningStatus();
if (miningStatus.IsActive != true)
{
await daemon.StartMining(
"9xSyMy1r9h3BVjMrF3CTqQCQy36yCfkpn7uVfMyTUbez3hhumqBUqGUNNALjcd7f1HJBRdeH82bCC3veFHW7z3xm28gug4d",
1,
false,
false
);
}
while (true)
{
var height = await daemon.GetHeight();
if (height >= targetHeight)
{
break;
}
await Task.Delay(1000);
}
}
}
32 changes: 9 additions & 23 deletions Monero.IntegrationTests/MoneroDaemonRpcIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,30 @@
using Monero.Daemon;
using Monero.Daemon.Common;
using Monero.Daemon.Rpc;
using Monero.IntegrationTests.Utils;

using NUnit.Framework;

namespace Monero.IntegrationTests;

public class MoneroDaemonRpcIntegrationTest : MoneroIntegrationTestBase
{

#region Notification Tests

// Can notify listeners when a new block is added to the chain
[Test]
public async Task TestBlockListener()
{
try
{
// register a listener
MoneroDaemonListener listener = new();
Daemon.AddListener(listener);
// register a listener
MoneroDaemonListener listener = new();
Daemon.AddListener(listener);

// wait for the next block notification
MoneroBlockHeader header = await Daemon.WaitForNextBlockHeader();
Daemon.RemoveListener(listener); // unregister listener so daemon does not keep polling
TestBlockHeader(header, true);
// wait for the next block notification
MoneroBlockHeader header = await Daemon.WaitForNextBlockHeader();
Daemon.RemoveListener(listener); // unregister listener so daemon does not keep polling
TestBlockHeader(header, true);

// test that listener was called with the equivalent header
Assert.That(header.Equals(listener.GetLastBlockHeader()));
}
finally
{
// stop mining
try { await Daemon.StopMining(); }
catch (MoneroError)
{
// ignore
}
}
// test that listener was called with the equivalent header
Assert.That(header.Equals(listener.GetLastBlockHeader()));
}

#endregion
Expand Down
1 change: 0 additions & 1 deletion Monero.IntegrationTests/MoneroIntegrationTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Monero.Daemon;
using Monero.IntegrationTests.Utils;
using Monero.Wallet;

namespace Monero.IntegrationTests;
Expand Down
1 change: 0 additions & 1 deletion Monero.IntegrationTests/MoneroWalletRpcIntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Monero.Common;
using Monero.IntegrationTests.Utils;
using Monero.Wallet;
using Monero.Wallet.Common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using NUnit.Framework;

namespace Monero.IntegrationTests.Utils;
namespace Monero.IntegrationTests;

internal abstract class TestUtils
{
Expand Down
21 changes: 0 additions & 21 deletions Monero.IntegrationTests/Utils/StartMining.cs

This file was deleted.

9 changes: 0 additions & 9 deletions Monero.IntegrationTests/Utils/StopMining.cs

This file was deleted.

2 changes: 0 additions & 2 deletions Monero.IntegrationTests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ services:
"--rpc-max-connections=1000",
"--max-connections-per-ip=10",
"--rpc-max-connections-per-private-ip=1000",
"--start-mining=9xSyMy1r9h3BVjMrF3CTqQCQy36yCfkpn7uVfMyTUbez3hhumqBUqGUNNALjcd7f1HJBRdeH82bCC3veFHW7z3xm28gug4d",
"--mining-threads=1",
"--non-interactive"
]
volumes:
Expand Down