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
2 changes: 1 addition & 1 deletion .github/workflows/Compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
working-directory: ./csharp/IotaWalletNet

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
run: dotnet test --configuration Release --no-build --verbosity normal -p:ParallelizeTestCollections=false
working-directory: ./csharp/IotaWalletNet
2 changes: 1 addition & 1 deletion .github/workflows/GithubNuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
working-directory: ./csharp/IotaWalletNet

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
run: dotnet test --configuration Release --no-build --verbosity normal -p:ParallelizeTestCollections=false
working-directory: ./csharp/IotaWalletNet

- name: Get Version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
working-directory: ./csharp/IotaWalletNet

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
run: dotnet test --configuration Release --no-build --verbosity normal -p:ParallelizeTestCollections=false
working-directory: ./csharp/IotaWalletNet

- name: Get Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace IotaWalletNet.Application.Common.Interfaces
{
public interface IWallet : IRustBridgeCommunicator
public interface IWallet : IRustBridgeCommunicator, IDisposable
{
ClientOptionsBuilder ConfigureClientOptions();
SecretManagerOptionsBuilder ConfigureSecretManagerOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class ClientOptions

public bool FallbackToLocalPow { get; set; } = true;

//public bool Offline { get; set; } = true;

}

public class ClientOptionsBuilder
Expand Down
3 changes: 2 additions & 1 deletion csharp/IotaWalletNet/IotaWalletNet.Application/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace IotaWalletNet.Application
{
public class Wallet : RustBridgeCommunicator, IWallet, IDisposable
public class Wallet : RustBridgeCommunicator, IWallet
{

#region Variables
Expand Down Expand Up @@ -135,6 +135,7 @@ public SecretManagerOptionsBuilder ConfigureSecretManagerOptions()
public WalletOptionsBuilder ConfigureWalletOptions()
=> new WalletOptionsBuilder(this);


public void Dispose()
{
CloseIotaWallet(_walletHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace IotaWalletNet.Tests.Common.Interfaces
public class DependencyTestBase : IDisposable
{
protected IServiceScope _serviceScope;
protected const String STRONGHOLD_PATH = "./stronghold";
protected const string DATABASE_PATH = "./walletdb";

public DependencyTestBase()
{
Expand All @@ -19,9 +21,30 @@ public DependencyTestBase()
_serviceScope = serviceProvider.CreateScope();
}

public void StrongholdCleanup(string path=STRONGHOLD_PATH)
{
if(File.Exists(path))
File.Delete(path);
}

public void DatabaseCleanup(string path=DATABASE_PATH)
{
if(Directory.Exists(path))
Directory.Delete(path, true);
}
public void Dispose()
{
_serviceScope.Dispose();

//Force garbage collection
GC.Collect();

//Give enough time for services to close
Thread.Sleep(100);

StrongholdCleanup();
DatabaseCleanup();

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

namespace IotaWalletNet.Tests.Wallet
{
[Collection("Sequential")]
public class ClientOptionsTest : DependencyTestBase
{

Expand All @@ -21,6 +22,8 @@ public void ClientOptionsBuilderShouldReturnWalletWhenBuild()
.ThenBuild();

wallet.Should().NotBeNull();


}

[Fact]
Expand All @@ -41,6 +44,8 @@ public void AddingDuplicateNodesShouldBeTreatedAsSingle()

clientOptions.Nodes.Should().HaveCount(1);
clientOptions.Nodes.First().Equals(nodeUrl);


}

[Fact]
Expand All @@ -63,6 +68,8 @@ public void AddingNonDuplicateNodesShouldBeTreatedAsMultiple()
clientOptions.Nodes.Should().HaveCount(2);
clientOptions.Nodes.First().Equals(nodeUrl);
clientOptions.Nodes.ToList()[1].Equals(secondNodeUrl);


}

[Fact]
Expand Down Expand Up @@ -99,6 +106,7 @@ public void ClientOptionsShouldBeConfigurableByBuilder()
clientOptions.Nodes.Should().HaveCount(1);
clientOptions.Nodes.First().Equals(nodeUrl);


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

namespace IotaWalletNet.Tests.Wallet
{
[Collection("Sequential")]
public class SecretManagerOptionsTest : DependencyTestBase
{
[Fact]
Expand All @@ -14,31 +15,33 @@ public void SecretManagerOptionBuilderShouldReturnWalletWhenBuild()
IWallet wallet = _serviceScope.ServiceProvider.GetRequiredService<IWallet>();
wallet = wallet
.ConfigureSecretManagerOptions()
.SetSnapshotPath("./snapshot")
.SetSnapshotPath(STRONGHOLD_PATH)
.SetPassword("password")
.ThenBuild();

wallet.Should().NotBeNull();


}

[Fact]
public void SecretManagerOptionShouldBeConfigurableByBuilder()
{
IWallet wallet = _serviceScope.ServiceProvider.GetRequiredService<IWallet>();
string snapshotPath = "./snapshot";
string password = "password";

wallet = wallet
.ConfigureSecretManagerOptions()
.SetSnapshotPath(snapshotPath)
.SetSnapshotPath(STRONGHOLD_PATH)
.SetPassword(password)
.ThenBuild();

SecretManagerOptions secretManagerOptions = wallet.GetWalletOptions().SecretManager;

secretManagerOptions.Stronghold.SnapshotPath.Equals(snapshotPath);
secretManagerOptions.Stronghold.SnapshotPath.Equals(STRONGHOLD_PATH);
secretManagerOptions.Stronghold.Password.Equals(password);


}
}
}
10 changes: 8 additions & 2 deletions csharp/IotaWalletNet/IotaWalletNet.Tests/Wallet/WalletTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

namespace IotaWalletNet.Tests.Wallet
{
[Collection("Sequential")]
public class WalletTest : DependencyTestBase
{

[Fact]
public void WalletShouldBeInitializedWithBasicConfigurations()
{
Expand All @@ -29,6 +31,8 @@ public void WalletShouldBeInitializedWithBasicConfigurations()
.Invoking(w => w = w.ThenInitialize())
.Should()
.NotThrow();


}

[Fact]
Expand All @@ -39,7 +43,7 @@ public void WalletShouldBeInitializedWithAdvancedConfigurations()
wallet = wallet
.ConfigureWalletOptions()
.SetCoinType(WalletOptions.TypeOfCoin.Shimmer)
.SetStoragePath("./walletdb")
.SetStoragePath(DATABASE_PATH)
.ThenBuild()
.ConfigureClientOptions()
.AddNodeUrl("https://api.testnet.shimmer.network")
Expand All @@ -48,13 +52,15 @@ public void WalletShouldBeInitializedWithAdvancedConfigurations()
.ThenBuild()
.ConfigureSecretManagerOptions()
.SetPassword("password")
.SetSnapshotPath("./mystronghold")
.SetSnapshotPath(STRONGHOLD_PATH)
.ThenBuild();

wallet
.Invoking(w => w = w.ThenInitialize())
.Should()
.NotThrow();


}
}
}