Skip to content

Commit 2df00bf

Browse files
committed
Add code format check
1 parent c0a11ab commit 2df00bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+557
-251
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Code format check
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
- uses: actions/checkout@v5
18+
with:
19+
submodules: recursive
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: 8.0.x
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Code format check
30+
run: |
31+
dotnet tool install -g dotnet-format
32+
dotnet format monero-lws-csharp.sln --no-restore --verify-no-changes --verbosity diagnostic

Monero.Lws.IntegrationTests/MoneroLwsServiceIntegrationTest.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class MoneroLwsServiceIntegrationTest
88
private static readonly string Address = TestUtils.Address;
99
private static readonly string ViewKey = TestUtils.PrivateViewKey;
1010
private static readonly MoneroLwsService Lws = TestUtils.GetLwsService();
11-
11+
1212
[Fact]
1313
public async Task TestGetVersion()
1414
{
@@ -37,7 +37,7 @@ public async Task GetDaemonStatus()
3737
Assert.False(string.IsNullOrEmpty(response.Network));
3838
Assert.False(string.IsNullOrEmpty(response.State));
3939
}
40-
40+
4141
[Fact]
4242
public async Task TestLogin()
4343
{
@@ -61,28 +61,28 @@ public async Task TestAcceptRequests()
6161
{
6262
var requests = await Lws.ListRequests();
6363
List<string> addressesToCreate = [];
64-
64+
6565
foreach (var createRequest in requests.Create)
6666
{
6767
addressesToCreate.Add(createRequest.Address);
6868
}
6969

7070
var created = await Lws.AcceptRequests("create", addressesToCreate);
71-
71+
7272
Assert.Equal(addressesToCreate.Count, created.UpdatedAddresses.Count);
73-
73+
7474
List<string> addressesToImport = [];
75-
75+
7676
foreach (var importRequest in requests.Import)
7777
{
7878
addressesToImport.Add(importRequest.Address);
7979
}
8080

8181
var imported = await Lws.AcceptRequests("import", addressesToImport);
82-
82+
8383
Assert.Equal(addressesToImport.Count, imported.UpdatedAddresses.Count);
8484
}
85-
85+
8686
[Fact]
8787
public async Task TestGetAddressInfo()
8888
{
@@ -95,14 +95,14 @@ public async Task TestGetAddressInfo()
9595
Assert.False(string.IsNullOrEmpty(response.LockedFunds));
9696
Assert.False(string.IsNullOrEmpty(response.TotalReceived));
9797
Assert.False(string.IsNullOrEmpty(response.TotalSent));
98-
98+
9999
if (response.TotalSent != "0")
100100
{
101101
Assert.NotNull(response.SpentOutputs);
102102
Assert.NotEmpty(response.SpentOutputs);
103103
TestSpends(response.SpentOutputs);
104104
}
105-
105+
106106
Assert.Null(response.Rates);
107107
}
108108

@@ -123,7 +123,7 @@ public async Task TestGetAddressTxs()
123123
foreach (var tx in response.Transactions)
124124
{
125125
TestTransaction(tx);
126-
}
126+
}
127127
}
128128
}
129129

@@ -148,7 +148,7 @@ public async Task TestGetUnspentOuts()
148148
Assert.True(fee > lastFee);
149149
lastFee = fee;
150150
}
151-
151+
152152
TestOutputs(response.Outputs);
153153
}
154154

@@ -166,7 +166,7 @@ public async Task TestImportWallet()
166166
Assert.False(string.IsNullOrEmpty(response.PaymentAddress));
167167
Assert.False(string.IsNullOrEmpty(response.PaymentId));
168168
}
169-
169+
170170
Assert.NotNull(response.Status);
171171

172172
if (response.NewRequest)
@@ -205,7 +205,7 @@ public async Task TestProvisionSubaddrs()
205205
var response = await Lws.ProvisionSubaddrs(Address, ViewKey, 0, 20, 1, 1, true);
206206
TestSubaddrs(response, true, true);
207207
}
208-
208+
209209
[Fact]
210210
public async Task TestGetSubaddrs()
211211
{
@@ -237,7 +237,7 @@ public async Task TestValidate()
237237
{
238238
Assert.Fail($"{response.Error.Field}: {response.Error.Details}");
239239
}
240-
240+
241241
Assert.False(string.IsNullOrEmpty(response.Address));
242242
Assert.Equal(TestUtils.Address, response.Address);
243243
}
@@ -258,21 +258,21 @@ public async Task TestListRequests()
258258
TestAccounts(response.Create, true);
259259
TestAccounts(response.Import, true);
260260
}
261-
261+
262262
[Fact]
263263
public async Task TestAddAccount()
264264
{
265265
var address = "43a1cERdj8rT1513tmMUY5MBcWbt1hgSo2fgLhoRrkYTPXejjRjU9y2WCjYfdZMLfZ6LKVc7YRGJMdtxD3x9Dtjc6fFjH9q";
266266
var viewKey = "4f8d491198f5219b80a03ae2be337b37ace5a4626c67e80a68beb7d0e3eaaa08";
267-
267+
268268
var accounts = await Lws.ListAccounts();
269269
var found = accounts.Active.Find(x => x.Address.Equals(address));
270270
if (found != null)
271271
{
272272
// account already added
273273
return;
274274
}
275-
275+
276276
var response = await Lws.AddAccount(address, viewKey);
277277
Assert.NotEmpty(response.UpdatedAddresses);
278278
Assert.Single(response.UpdatedAddresses);
@@ -295,7 +295,7 @@ public async Task TestModifyAccountStatus()
295295
Assert.Single(response.UpdatedAddresses);
296296
Assert.Equal(TestUtils.Address, response.UpdatedAddresses.First());
297297
}
298-
298+
299299
private static void TestTransaction(MoneroLwsTransaction? tx)
300300
{
301301
Assert.NotNull(tx);
@@ -336,7 +336,7 @@ private static void TestOutputs(List<MoneroLwsRandomOutput>? outputs)
336336
TestOutput(output);
337337
}
338338
}
339-
339+
340340
private static void TestOutput(MoneroLwsRandomOutput? output)
341341
{
342342
Assert.NotNull(output);
@@ -353,7 +353,7 @@ private static void TestOutputs(List<MoneroLwsOutput>? outputs)
353353
TestOutput(output);
354354
}
355355
}
356-
356+
357357
private static void TestOutput(MoneroLwsOutput? output)
358358
{
359359
Assert.NotNull(output);
@@ -368,15 +368,15 @@ private static void TestOutput(MoneroLwsOutput? output)
368368
Assert.False(string.IsNullOrEmpty(output.TxPrefixHash));
369369
Assert.False(string.IsNullOrEmpty(output.TxPubKey));
370370
Assert.False(string.IsNullOrEmpty(output.Timestamp));
371-
371+
372372
if (output.SpendKeyImages.Count > 0)
373373
{
374374
foreach (var keyImage in output.SpendKeyImages)
375375
{
376376
Assert.NotEmpty(keyImage);
377377
}
378378
}
379-
379+
380380
TestAddressMeta(output.Recipient);
381381
}
382382

@@ -388,7 +388,7 @@ private static void TestSpends(List<MoneroLwsSpend>? spends)
388388
TestSpend(spend);
389389
}
390390
}
391-
391+
392392
private static void TestSpend(MoneroLwsSpend? spend)
393393
{
394394
Assert.NotNull(spend);
@@ -399,7 +399,7 @@ private static void TestSpend(MoneroLwsSpend? spend)
399399
Assert.True(spend.Mixin >= 0);
400400
TestAddressMeta(spend.Sender);
401401
}
402-
402+
403403
private static void TestSubaddrs(MoneroLwsSubaddrs? subaddrs, bool expectNew, bool expectAll)
404404
{
405405
if (subaddrs == null)
@@ -418,7 +418,7 @@ private static void TestSubaddrs(MoneroLwsSubaddrs? subaddrs, bool expectNew, bo
418418
{
419419
Assert.NotNull(subaddrs.AllSubaddrs);
420420
Assert.NotEmpty(subaddrs.AllSubaddrs);
421-
TestSubaddrsEntries(subaddrs.AllSubaddrs);
421+
TestSubaddrsEntries(subaddrs.AllSubaddrs);
422422
}
423423
}
424424

@@ -434,7 +434,7 @@ private static void TestSubaddrsEntries(List<MoneroLwsSubaddrsEntry>? entries)
434434
TestSubaddrsEntry(entry);
435435
}
436436
}
437-
437+
438438
private static void TestSubaddrsEntry(MoneroLwsSubaddrsEntry? entry)
439439
{
440440
Assert.NotNull(entry);
@@ -458,7 +458,7 @@ private static void TestIndexRange(List<long>? indexRange)
458458
Assert.Equal(2, indexRange.Count);
459459
var lowerBound = indexRange[0];
460460
var upperBound = indexRange[1];
461-
461+
462462
Assert.True(lowerBound >= 0);
463463
Assert.True(upperBound >= 0);
464464
Assert.True(lowerBound <= upperBound);
@@ -470,7 +470,7 @@ private static void TestAddressMeta(MoneroLwsAddressMeta? addressMeta)
470470
Assert.True(addressMeta.MajIndex >= 0);
471471
Assert.True(addressMeta.MinIndex >= 0);
472472
}
473-
473+
474474
private static void TestAccount(MoneroLwsAccount? account, bool request)
475475
{
476476
Assert.NotNull(account);
@@ -480,7 +480,7 @@ private static void TestAccount(MoneroLwsAccount? account, bool request)
480480
Assert.True(account.StartHeight >= 0);
481481
return;
482482
}
483-
483+
484484
Assert.True(account.ScanHeight >= 0);
485485
Assert.True(account.AccessTime >= 0);
486486
}
@@ -493,7 +493,7 @@ private static void TestAccounts(List<MoneroLwsAccount>? accounts, bool request)
493493
TestAccount(account, request);
494494
}
495495
}
496-
496+
497497
private static void TestAccounts(List<MoneroLwsAccount>? accounts)
498498
{
499499
TestAccounts(accounts, false);

Monero.Lws.IntegrationTests/Utils/TestUtils.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ internal static class TestUtils
66
public static readonly Uri LwsServiceUri = new(GetDefaultEnv("XMR_LWS_URI", "http://127.0.0.1:8443"));
77
public const string Username = "";
88
public const string Password = "";
9-
public const string Address = "42EhKmBx6pAPYhX4QCHKBPRw8dgc3VVVdA7g2dxr5wz21crqvPUkwPTde64Xac5uawQeFbh6K7PD4YLqiX1VTP5jUH7gZez";
9+
10+
public const string Address =
11+
"42EhKmBx6pAPYhX4QCHKBPRw8dgc3VVVdA7g2dxr5wz21crqvPUkwPTde64Xac5uawQeFbh6K7PD4YLqiX1VTP5jUH7gZez";
12+
1013
public const string PublicViewKey = "b244f89be70e16db0d8905628480708d590ffd4e820303bb61c96cf2395bfaf1";
1114
public const string PublicSpendKey = "1030f7c992ec9b86cc0055d2c44632951104e67b05d28c367ecd8382c0931303";
1215
public const string PrivateViewKey = "41f55a92b942681e35bf7bb64f71142729039bd8e606a4f4218c543065c15c05";
1316

1417
private static MoneroLwsService? _lwsService = null;
15-
18+
1619
public static MoneroLwsService GetLwsService()
1720
{
1821
if (_lwsService == null)
@@ -22,11 +25,10 @@ public static MoneroLwsService GetLwsService()
2225

2326
return _lwsService;
2427
}
25-
28+
2629
private static string GetDefaultEnv(string key, string defaultValue)
2730
{
2831
string? currentValue = Environment.GetEnvironmentVariable(key);
2932
return string.IsNullOrEmpty(currentValue) ? defaultValue : currentValue;
3033
}
31-
3234
}

Monero.Lws/Common/MoneroLwsAccount.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ public class MoneroLwsAccount
77
/// <summary>
88
/// Account primary address.
99
/// </summary>
10-
[JsonPropertyName("address")] public string Address { get; set; } = "";
10+
[JsonPropertyName("address")]
11+
public string Address { get; set; } = "";
1112

1213
/// <summary>
1314
/// Account scan height.
1415
/// </summary>
15-
[JsonPropertyName("scan_height")] public long ScanHeight { get; set; } = 0;
16+
[JsonPropertyName("scan_height")]
17+
public long ScanHeight { get; set; } = 0;
1618

1719
/// <summary>
1820
/// Account start height.
1921
/// </summary>
20-
[JsonPropertyName("start_height")] public long StartHeight { get; set; } = 0;
21-
22+
[JsonPropertyName("start_height")]
23+
public long StartHeight { get; set; } = 0;
24+
2225
/// <summary>
2326
/// Account last access time.
2427
/// </summary>
25-
[JsonPropertyName("access_time")] public long AccessTime { get; set; } = 0;
26-
28+
[JsonPropertyName("access_time")]
29+
public long AccessTime { get; set; } = 0;
2730
}

Monero.Lws/Common/MoneroLwsAccountLookahead.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ public class MoneroLwsAccountLookahead
1010
/// <summary>
1111
/// Account index lookahead.
1212
/// </summary>
13-
[JsonPropertyName("maj_i")] public long MajorIndex { get; set; } = 0;
13+
[JsonPropertyName("maj_i")]
14+
public long MajorIndex { get; set; } = 0;
15+
1416
/// <summary>
1517
/// Subaddress index lookahead.
1618
/// </summary>
17-
[JsonPropertyName("min_i")] public long MinorIndex { get; set; } = 0;
19+
[JsonPropertyName("min_i")]
20+
public long MinorIndex { get; set; } = 0;
1821
}

Monero.Lws/Common/MoneroLwsAddressMeta.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ namespace Monero.Lws.Common;
88
public class MoneroLwsAddressMeta
99
{
1010
/// <summary>Subaddress major index</summary>
11-
[JsonPropertyName("maj_i")] public long MajIndex { get; set; } = 0;
11+
[JsonPropertyName("maj_i")]
12+
public long MajIndex { get; set; } = 0;
13+
1214
/// <summary>Subaddress minor index</summary>
13-
[JsonPropertyName("min_i")] public long MinIndex { get; set; } = 0;
15+
[JsonPropertyName("min_i")]
16+
public long MinIndex { get; set; } = 0;
1417
}

Monero.Lws/Common/MoneroLwsApiException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ public class MoneroLwsApiException(int code, string message) : Exception(message
1111
/// Error code.
1212
/// </summary>
1313
public readonly int Code = code;
14-
}
14+
}

0 commit comments

Comments
 (0)