adds block exchange tests. Updates namespaces
This commit is contained in:
parent
7aae48d489
commit
b81d574a4b
|
@ -1,6 +1,7 @@
|
|||
using CodexPlugin;
|
||||
using FileUtils;
|
||||
using Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
|
@ -21,6 +22,9 @@ namespace ContinuousTests.Tests
|
|||
[TestMoment(t: Zero)]
|
||||
public void UploadTestFile()
|
||||
{
|
||||
LogBlockExchangeStatus(Nodes[0], "Before upload");
|
||||
LogBlockExchangeStatus(Nodes[1], "Before upload");
|
||||
|
||||
file = FileManager.GenerateFile(size);
|
||||
|
||||
LogStoredBytes(Nodes[0]);
|
||||
|
@ -37,6 +41,9 @@ namespace ContinuousTests.Tests
|
|||
LogBytesPerMillisecond(() => dl = Nodes[1].DownloadContent(cid!));
|
||||
|
||||
file.AssertIsEqual(dl);
|
||||
|
||||
LogBlockExchangeStatus(Nodes[0], "After download");
|
||||
LogBlockExchangeStatus(Nodes[1], "After download");
|
||||
}
|
||||
|
||||
private void LogStoredBytes(ICodexNode node)
|
||||
|
@ -65,5 +72,11 @@ namespace ContinuousTests.Tests
|
|||
var bytesPerMs = totalBytes / totalMs;
|
||||
Log.Log($"Bytes per millisecond: {bytesPerMs}");
|
||||
}
|
||||
|
||||
private void LogBlockExchangeStatus(ICodexNode codexNode, string msg)
|
||||
{
|
||||
var response = codexNode.GetDebugBlockExchange();
|
||||
Log.Log($"{codexNode.GetName()} {msg}: {JsonConvert.SerializeObject(response)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using CodexTests;
|
||||
using DistTestCore;
|
||||
using FileUtils;
|
||||
using NUnit.Framework;
|
||||
using Tests;
|
||||
using Utils;
|
||||
|
||||
namespace CodexLongTests.BasicTests
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using DistTestCore;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using Tests;
|
||||
using Utils;
|
||||
|
||||
namespace CodexLongTests.BasicTests
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using DistTestCore;
|
||||
using CodexTests;
|
||||
using DistTestCore;
|
||||
using NUnit.Framework;
|
||||
using Tests;
|
||||
|
||||
namespace CodexLongTests.BasicTests
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using DistTestCore;
|
||||
using FileUtils;
|
||||
using NUnit.Framework;
|
||||
using Tests;
|
||||
using Utils;
|
||||
|
||||
namespace CodexLongTests.BasicTests
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using DistTestCore;
|
||||
using CodexTests;
|
||||
using DistTestCore;
|
||||
using NUnit.Framework;
|
||||
using Tests;
|
||||
using Utils;
|
||||
|
||||
namespace CodexLongTests.DownloadConnectivityTests
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using CodexPlugin;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests
|
||||
namespace CodexTests
|
||||
{
|
||||
public class AutoBootstrapDistTest : CodexDistTest
|
||||
{
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
using CodexPlugin;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlockExchangeTests : CodexDistTest
|
||||
{
|
||||
[Test]
|
||||
public void EmptyAfterExchange()
|
||||
{
|
||||
var bootstrap = AddCodex(s => s.WithName("bootstrap"));
|
||||
var node = AddCodex(s => s.WithName("node").WithBootstrapNode(bootstrap));
|
||||
|
||||
AssertExchangeIsEmpty(bootstrap, node);
|
||||
|
||||
var file = GenerateTestFile(1.MB());
|
||||
var cid = bootstrap.UploadFile(file);
|
||||
node.DownloadContent(cid);
|
||||
|
||||
AssertExchangeIsEmpty(bootstrap, node);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyAfterExchangeWithBystander()
|
||||
{
|
||||
var bootstrap = AddCodex(s => s.WithName("bootstrap"));
|
||||
var node = AddCodex(s => s.WithName("node").WithBootstrapNode(bootstrap));
|
||||
var bystander = AddCodex(s => s.WithName("bystander").WithBootstrapNode(bootstrap));
|
||||
|
||||
AssertExchangeIsEmpty(bootstrap, node, bystander);
|
||||
|
||||
var file = GenerateTestFile(1.MB());
|
||||
var cid = bootstrap.UploadFile(file);
|
||||
node.DownloadContent(cid);
|
||||
|
||||
AssertExchangeIsEmpty(bootstrap, node, bystander);
|
||||
}
|
||||
|
||||
private void AssertExchangeIsEmpty(params ICodexNode[] nodes)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
Time.Retry(() => AssertBlockExchangeIsEmpty(node), nameof(AssertExchangeIsEmpty));
|
||||
}
|
||||
}
|
||||
|
||||
private void AssertBlockExchangeIsEmpty(ICodexNode node)
|
||||
{
|
||||
var msg = $"BlockExchange for {node.GetName()}: ";
|
||||
var response = node.GetDebugBlockExchange();
|
||||
foreach (var peer in response.peers)
|
||||
{
|
||||
var activeWants = peer.wants.Where(w => !w.cancel).ToArray();
|
||||
Assert.That(activeWants.Length, Is.EqualTo(0), msg + "thinks a peer has active wants.");
|
||||
}
|
||||
Assert.That(response.taskQueue, Is.EqualTo(0), msg + "has tasks in queue.");
|
||||
Assert.That(response.pendingBlocks, Is.EqualTo(0), msg + "has pending blocks.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ using MetricsPlugin;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[Ignore("Used for debugging continuous tests")]
|
||||
[TestFixture]
|
||||
|
@ -87,7 +87,7 @@ namespace Tests.BasicTests
|
|||
//CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
|
||||
//CheckRoutingTables(GetAllOnlineCodexNodes());
|
||||
|
||||
var node = RandomUtils.PickOneRandom(nodes.ToList());
|
||||
var node = nodes.ToList().PickOneRandom();
|
||||
var file = GenerateTestFile(50.MB());
|
||||
node.UploadFile(file);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using MetricsPlugin;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ExampleTests : CodexDistTest
|
||||
|
@ -59,7 +59,7 @@ namespace Tests.BasicTests
|
|||
.WithStorageQuota(11.GB())
|
||||
.EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, isValidator: true)
|
||||
.WithSimulateProofFailures(failEveryNProofs: 3));
|
||||
|
||||
|
||||
AssertBalance(geth, contracts, seller, Is.EqualTo(sellerInitialBalance));
|
||||
seller.Marketplace.MakeStorageAvailable(
|
||||
size: 10.GB(),
|
||||
|
@ -72,7 +72,7 @@ namespace Tests.BasicTests
|
|||
var buyer = AddCodex(s => s
|
||||
.WithBootstrapNode(seller)
|
||||
.EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: buyerInitialBalance));
|
||||
|
||||
|
||||
AssertBalance(geth, contracts, buyer, Is.EqualTo(buyerInitialBalance));
|
||||
|
||||
var contentId = buyer.UploadFile(testFile);
|
||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
// Warning!
|
||||
// This is a test to check network-isolation in the test-infrastructure.
|
||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class OneClientTests : DistTest
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
using DistTestCore;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ThreeClientTest : AutoBootstrapDistTest
|
||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace Tests.BasicTests
|
||||
namespace CodexTests.BasicTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TwoClientTests : DistTest
|
||||
|
|
|
@ -9,7 +9,7 @@ using GethPlugin;
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace Tests
|
||||
namespace CodexTests
|
||||
{
|
||||
public class CodexDistTest : DistTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CodexContractsPlugin;
|
||||
using CodexTests;
|
||||
using GethPlugin;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
|
|
@ -3,7 +3,7 @@ using Logging;
|
|||
using MetricsPlugin;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace Tests
|
||||
namespace CodexTests
|
||||
{
|
||||
public static class MetricsAccessExtensions
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
|
||||
[assembly: LevelOfParallelism(1)]
|
||||
namespace Tests
|
||||
namespace CodexTests
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests.PeerDiscoveryTests
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CodexContractsPlugin;
|
||||
using CodexTests;
|
||||
using GethPlugin;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
|
Loading…
Reference in New Issue