Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Implemented new Pearldiver version of IRI 1.5 + clearly seperated UnitTests and IntegrationTests #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

<IsPackable>false</IsPackable>

<RootNamespace>Iota.Api.Standard.Tests</RootNamespace>
<RootNamespace>Iota.Api.Standard.IntegrationTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions IotaApi.Standard.IntegrationTests/IotaCoreApiTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
using System.Linq;
using Iota.Api.Standard.Exception;
using Xunit;

namespace Iota.Api.Standard.IntegrationTests
{
public class IotaCoreApiTest
{
private static readonly string TEST_BUNDLE =
"XZKJUUMQOYUQFKMWQZNTFMSS9FKJLOEV9DXXXWPMQRTNCOUSUQNTBIJTVORLOQPLYZOTMLFRHYKMTGZZU";

private static readonly string TEST_ADDRESS_WITH_CHECKSUM =
"PNGMCSNRCTRHCHPXYTPKEJYPCOWKOMRXZFHH9N9VDIKMNVAZCMIYRHVJIAZARZTUETJVFDMBEBIQE9QTHBFWDAOEFA";

private static readonly string TEST_HASH =
"OAATQS9VQLSXCLDJVJJVYUGONXAXOFMJOZNSYWRZSWECMXAQQURHQBJNLD9IOFEPGZEPEMPXCIVRX9999";

private static IotaApi _iotaApi;

public IotaCoreApiTest()
{
_iotaApi = new IotaApi("node.iotawallet.info", 14265);
}

[Fact]
public void ShouldGetNodeInfo()
{
var nodeInfo = _iotaApi.GetNodeInfo();
Assert.NotNull(nodeInfo.AppVersion);
Assert.NotNull(nodeInfo.AppName);
Assert.NotNull(nodeInfo.JreVersion);
}

[Fact]
public void ShouldGetNeighbors()
{
var neighbors = _iotaApi.GetNeighbors();
Assert.NotNull(neighbors.Neighbors);
}

[Fact]
public void ShouldAddNeighbors()
{
try
{
var response = _iotaApi.AddNeighbors("udp://8.8.8.8:14265");
Assert.NotNull(response);
}
catch (IotaApiException e)
{
Assert.Contains("not available on this node", e.Message);
}
}

[Fact]
public void ShouldRemoveNeighbors()
{
try
{
var response = _iotaApi.RemoveNeighbors("udp://8.8.8.8:14265");
Assert.NotNull(response);
}
catch (IotaApiException e)
{
Assert.Contains("not available on this node", e.Message);
}
}

[Fact]
public void ShouldGetTips()
{
var tips = _iotaApi.GetTips();
Assert.NotNull(tips);
}

[Fact]
public void ShouldFindTransactionsByAddresses()
{
var trans = _iotaApi.FindTransactionsByAddresses(TEST_ADDRESS_WITH_CHECKSUM);
Assert.NotNull(trans.Hashes);
Assert.True(trans.Hashes.Count > 0);
}

[Fact]
public void ShouldFindTransactionsByApprovees()
{
var trans = _iotaApi.FindTransactionsByApprovees(TEST_HASH);
Assert.NotNull(trans.Hashes);
}

[Fact]
public void ShouldFindTransactionsByBundles()
{
var trans = _iotaApi.FindTransactionsByBundles(TEST_HASH);
Assert.NotNull(trans.Hashes);
}

[Fact]
public void ShouldFindTransactionsByDigests()
{
var trans = _iotaApi.FindTransactionsByDigests(TEST_HASH);
Assert.NotNull(trans.Hashes);
}

[Fact]
public void ShouldGetTrytes()
{
var response = _iotaApi.GetTrytes(TEST_HASH);
Assert.NotNull(response.Trytes);
}

[Fact]
public void ShouldThrowOnInvalidMileStone()
{
Assert.Throws<IotaApiException>(
() => _iotaApi.GetInclusionStates(new[] { TEST_HASH }, new[] { "DNSBRJWNOVUCQPILOQIFDKBFJMVOTGHLIMLLRXOHFTJZGRHJUEDAOWXQRYGDI9KHYFGYDWQJZKX999999" })
);
}

[Fact]
public void ShouldGetInclusionStates()
{
var response = _iotaApi.GetInclusionStates( new[] {TEST_HASH}, new[] {_iotaApi.GetNodeInfo().LatestSolidSubtangleMilestone});
Assert.NotNull(response.States);
}

[Fact]
public void ShouldGetTransactionsToApprove()
{
var response = _iotaApi.GetTransactionsToApprove(7);

Assert.NotNull(response.TrunkTransaction);
Assert.NotNull(response.BranchTransaction);
}

[Fact]
public void ShouldFindTransactions()
{
var test = TEST_BUNDLE;
// responseharper disable once UnusedVariable
var responsep = _iotaApi.FindTransactions(new[] {test}.ToList(),
new[] {test}.ToList(), new[] {test}.ToList(), new[] {test}.ToList());
}

[Fact]
public void ShouldGetBalances()
{
var response = _iotaApi.GetBalances(new[] {TEST_ADDRESS_WITH_CHECKSUM}.ToList(), 100);
Assert.NotNull(response.Balances);
Assert.NotNull(response.References);
Assert.False(response.MilestoneIndex == 0);
}
}
}
42 changes: 42 additions & 0 deletions IotaApi.Standard.IntegrationTests/LocalPoWTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using Iota.Api.Standard.Model;
using Iota.Api.Standard.Pow;
using Xunit;

namespace Iota.Api.Standard.IntegrationTests
{
public class LocalPoWTest
{
private const string TEST_SEED1 =
"IHDEENZYITYVYSPKAURUZAQKGVJEREFDJMYTANNXXGPZ9GJWTEOJJ9IPMXOGZNQLSNMFDSQOTZAEETUEA";

private const string TEST_ADDRESS_WITHOUT_CHECKSUM_SECURITY_LEVEL_2 =
"LXQHWNY9CQOHPNMKFJFIJHGEPAENAOVFRDIBF99PPHDTWJDCGHLYETXT9NPUVSNKT9XDTDYNJKJCPQMZC";

private const string TEST_MESSAGE = "JUSTANOTHERJOTATEST";
private const string TEST_TAG = "JOTASPAM9999999999999999999";
private const int MIN_WEIGHT_MAGNITUDE = 14;
private const int DEPTH = 9;

private IotaApi _iotaClient;

public LocalPoWTest()
{
_iotaClient = new IotaApi("node.iotawallet.info", 14265)
{
LocalPow = new PearlDiverLocalPoW()
};
}

[Fact]
public void ShouldSendTransfer()
{
var transfers = new List<Transfer>
{
new Transfer(TEST_ADDRESS_WITHOUT_CHECKSUM_SECURITY_LEVEL_2, 0, TEST_MESSAGE, TEST_TAG)
};
var result = _iotaClient.SendTransfer( TEST_SEED1, 2, DEPTH, MIN_WEIGHT_MAGNITUDE, transfers.ToArray(), null, null, false, false);
Assert.NotNull(result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using Iota.Api.Standard.Model;
using Iota.Api.Standard.Pow;
using Iota.Api.Standard.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

namespace Iota.Api.Standard.Tests.Utils
namespace Iota.Api.Standard.IntegrationTests
{
[TestClass]
public class MultisigTest
{
private const string TestSeed1 = "ABCDFG";
Expand All @@ -24,13 +23,12 @@ public class MultisigTest

private IotaApi _iotaClient;

[TestInitialize]
public void CreateApiClientInstance()
public MultisigTest()
{
_iotaClient = new IotaApi("node.iotawallet.info", 14265);
}

[TestMethod]
[Fact]
public void BasicMultiSigTest()
{
Multisig ms = new Multisig();
Expand Down Expand Up @@ -58,7 +56,7 @@ public void BasicMultiSigTest()

Console.WriteLine("Is a valid multisig address " + isValidMultisigAddress);

Assert.IsTrue(isValidMultisigAddress, "Address is not a valid multisigAddress");
Assert.True(isValidMultisigAddress, "Address is not a valid multisigAddress");

List<Transfer> transfers = new List<Transfer>
{
Expand All @@ -78,8 +76,8 @@ public void BasicMultiSigTest()
Signing sgn = new Signing(new Kerl());

bool isValidSignature = sgn.ValidateSignatures(bundle, multiSigAddress);
Console.WriteLine("Result of multi-signature validation is " + isValidSignature);
Assert.IsTrue(isValidSignature, "MultiSignature not valid");

Assert.True(isValidSignature, "MultiSignature not valid");

}
}
Expand Down
Loading