Skip to content

Commit a8a0e8d

Browse files
committed
Update changes for wallet export feature
1 parent 8e3923a commit a8a0e8d

File tree

8 files changed

+68
-173
lines changed

8 files changed

+68
-173
lines changed

.github/workflows/ci-dotnet-maui.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
- name: Build solution
3535
run: dotnet build ./Spoke/SPOKE.sln -c Release --no-restore
3636

37-
- name: Run tests
37+
- name: Run solution tests
3838
run: |
39-
dotnet test ./Spoke/SPOKE.sln -c Release --no-build --verbosity minimal || true
39+
dotnet test ./Spoke/SPOKE.sln -c Release --no-build --verbosity minimal
40+
41+
- name: Run Spoke.Tests only
42+
run: |
43+
dotnet test ./Spoke/Spoke.Tests/Spoke.Tests.csproj -c Release --no-build --verbosity minimal
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using IXICore;
5+
using Xunit;
6+
7+
namespace Spoke.Tests;
8+
9+
public class ExportViewingWalletTests : IDisposable
10+
{
11+
private readonly string _tempDir;
12+
13+
public ExportViewingWalletTests()
14+
{
15+
_tempDir = Path.Combine(Path.GetTempPath(), "SpokeExportTest", Guid.NewGuid().ToString());
16+
Directory.CreateDirectory(_tempDir);
17+
}
18+
19+
public void Dispose()
20+
{
21+
try
22+
{
23+
if (Directory.Exists(_tempDir))
24+
{
25+
Directory.Delete(_tempDir, true);
26+
}
27+
}
28+
catch
29+
{
30+
// best-effort cleanup
31+
}
32+
}
33+
34+
[Fact]
35+
public void WalletStorage_GeneratesViewingWalletBytes()
36+
{
37+
string walletPath = Path.Combine(_tempDir, "wallet.ixi");
38+
WalletStorage wallet = new WalletStorage(walletPath);
39+
bool generated = wallet.generateWallet("test-password-123");
40+
Assert.True(generated, "Wallet generation failed");
41+
42+
string walletIdSegment = new string(wallet.getMyAddressesBase58().First().Take(8).ToArray());
43+
string expectedBackupPath = walletPath + "." + walletIdSegment + ".bak";
44+
wallet.backup();
45+
Assert.True(File.Exists(expectedBackupPath), "Wallet backup was not created");
46+
47+
byte[] viewingBytes = wallet.getRawViewingWallet();
48+
Assert.NotNull(viewingBytes);
49+
Assert.True(viewingBytes.Length > 0, "Viewing wallet export should contain bytes");
50+
}
51+
}

Spoke.Tests/Spoke.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
<PackageReference Include="xunit" Version="2.5.0" />
99
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
11+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
12+
<PackageReference Include="Open.NAT" Version="2.1.0" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<ProjectReference Include="..\Spoke\Spoke.Core\Spoke.Core.csproj" />
1116
</ItemGroup>
1217
<ItemGroup>
1318
<!-- Include only the small, testable BridgeConnection source file directly to avoid referencing MAUI app projects -->
1419
<Compile Include="..\Spoke\BridgeConnection.cs" />
1520
</ItemGroup>
21+
22+
<Import Project="..\Ixian-Core\IXICore.projitems" Label="Shared" />
1623
</Project>

Spoke.UnitTestsClean/Spoke.UnitTestsClean.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1111
</ItemGroup>
1212
<ItemGroup>
13+
<ProjectReference Include="../Spoke/Spoke.Core/Spoke.Core.csproj" />
1314
</ItemGroup>
1415
</Project>

Spoke.UnitTestsClean/UnitTests/ExportViewingWalletTests.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

Spoke.UnitTestsClean/UnitTests/WalletManagerTests.cs

Lines changed: 0 additions & 120 deletions
This file was deleted.

Spoke/Spoke/Meta/Node.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ public static bool generateWallet(string pass)
199199
{
200200
// Save the wallet password to preferences
201201
Preferences.Default.Set("walletpass", pass);
202+
203+
ws.backup();
202204

203205
Logging.info("Wallet generated and saved successfully to {0}", walletPath);
204206
return true;

temp_paths.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"REPO_ROOT":"D:/Spoke","BRANCH":"feature/wallet-export","FEATURE_DIR":"D:\\Spoke\\specs\\feature\\wallet-export","FEATURE_SPEC":"D:\\Spoke\\specs\\feature\\wallet-export\\spec.md","IMPL_PLAN":"D:\\Spoke\\specs\\feature\\wallet-export\\plan.md","TASKS":"D:\\Spoke\\specs\\feature\\wallet-export\\tasks.md"}

0 commit comments

Comments
 (0)