Skip to content

Commit 9402f01

Browse files
Fix lint
1 parent 934104d commit 9402f01

7 files changed

Lines changed: 88 additions & 81 deletions

File tree

Monero.Test/TestMoneroDaemonRpc.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Monero.Test;
1111
public class MoneroDaemonRpcFixture : IDisposable
1212
{
1313
public readonly TestContext BINARY_BLOCK_CTX = new();
14-
14+
1515
public MoneroDaemonRpc Daemon;
1616
public MoneroWalletRpc Wallet;
1717
public bool IsRestricted;
@@ -21,7 +21,7 @@ public MoneroDaemonRpcFixture()
2121
Daemon = TestUtils.GetDaemonRpc();
2222
//Wallet = TestUtils.GetWalletRpc();
2323
IsRestricted = Daemon.IsRestricted();
24-
24+
2525
BINARY_BLOCK_CTX.hasHex = false;
2626
BINARY_BLOCK_CTX.headerIsFull = false;
2727
BINARY_BLOCK_CTX.hasTxs = true;
@@ -33,11 +33,11 @@ public MoneroDaemonRpcFixture()
3333
BINARY_BLOCK_CTX.txContext.fromBinaryBlock = true;
3434

3535
TestUtils.WALLET_TX_TRACKER.Reset(); // all wallets need to wait for txs to confirm to reliably sync
36-
36+
3737
// Wait for some blocks to mine
3838
GenUtils.WaitFor(10000);
3939
}
40-
40+
4141
public void Dispose()
4242
{
4343
GC.SuppressFinalize(this);
@@ -58,11 +58,11 @@ public class TestMoneroDaemonRpc : IClassFixture<MoneroDaemonRpcFixture>
5858
private static TestContext BINARY_BLOCK_CTX = new();
5959

6060
private MoneroDaemonRpcFixture fixture;
61-
61+
6262
public TestMoneroDaemonRpc(MoneroDaemonRpcFixture fixture)
6363
{
6464
BINARY_BLOCK_CTX = fixture.BINARY_BLOCK_CTX;
65-
65+
6666
daemon = fixture.Daemon;
6767
wallet = fixture.Wallet;
6868

@@ -80,7 +80,7 @@ public TestMoneroDaemonRpc(MoneroDaemonRpcFixture fixture)
8080
}
8181

8282
#region Non Relays Tests
83-
83+
8484
[Fact]
8585
public void TestGetVersion()
8686
{
@@ -1124,7 +1124,7 @@ public void TestMining()
11241124
daemon.StartMining(address, 1, false, true);
11251125

11261126
GenUtils.WaitFor(30);
1127-
1127+
11281128
// stop mining
11291129
daemon.StopMining();
11301130
}
@@ -1168,7 +1168,7 @@ public void TestGetMiningStatus()
11681168
}
11691169
catch (MoneroError e)
11701170
{
1171-
throw e;
1171+
throw;
11721172
}
11731173
finally
11741174
{
@@ -1403,7 +1403,7 @@ public void TestBlockListener()
14031403
}
14041404
catch (MoneroError e)
14051405
{
1406-
throw e;
1406+
throw;
14071407
}
14081408
finally
14091409
{
@@ -1432,7 +1432,7 @@ private static void MineBlocks()
14321432
MoneroUtils.Log(0, e.Message);
14331433
}
14341434
}
1435-
1435+
14361436
private static void TestBlockHeader(MoneroBlockHeader? header, bool isFull)
14371437
{
14381438
Assert.NotNull(header);
@@ -1627,9 +1627,9 @@ private static void TestTx(MoneroTx? tx, TestContext? ctx)
16271627
if (tx.IsConfirmed() == true)
16281628
{
16291629
Assert.NotNull(tx.GetBlock());
1630-
Assert.True(tx.GetBlock().GetTxs().Contains(tx));
1630+
Assert.Contains(tx, tx.GetBlock().GetTxs());
16311631
Assert.True(tx.GetBlock().GetHeight() > 0);
1632-
Assert.True(tx.GetBlock().GetTxs().Contains(tx));
1632+
Assert.Contains(tx, tx.GetBlock().GetTxs());
16331633
Assert.True(tx.GetBlock().GetHeight() > 0);
16341634
Assert.True(tx.GetBlock().GetTimestamp() > 0);
16351635
Assert.True(tx.GetRelay());
@@ -1742,7 +1742,7 @@ private static void TestTx(MoneroTx? tx, TestContext? ctx)
17421742
if (ctx.fromBinaryBlock == true) Assert.Null(tx.GetFullHex()); // TODO: GetBlocksByHeight() has inconsistent client-side pruning
17431743
else Assert.True(tx.GetFullHex().Length > 0);
17441744
if (ctx.fromBinaryBlock == true) Assert.Null(tx.GetRctSigPrunable()); // TODO: GetBlocksByHeight() has inconsistent client-side pruning
1745-
//else Assert.NotNull((tx.GetRctSigPrunable()); // TODO: define and test this
1745+
//else Assert.NotNull((tx.GetRctSigPrunable()); // TODO: define and test this
17461746
Assert.False(tx.IsDoubleSpendSeen());
17471747
if (tx.IsConfirmed() == true)
17481748
{
@@ -2058,8 +2058,6 @@ private static void TestPeer(MoneroPeer peer)
20582058
Assert.True(peer.GetCurrentUpload() >= 0);
20592059
Assert.True(peer.GetHeight() >= 0);
20602060
Assert.True(peer.GetLiveTime() >= 0);
2061-
Assert.NotNull(peer.IsLocalIp());
2062-
Assert.NotNull(peer.IsLocalHost());
20632061
Assert.True(peer.GetNumReceives() >= 0);
20642062
Assert.True(peer.GetReceiveIdleTime() >= 0);
20652063
Assert.True(peer.GetNumSends() >= 0);
@@ -2076,7 +2074,6 @@ private static void TestKnownPeer(MoneroPeer peer, bool fromConnection)
20762074
Assert.True(peer.GetHost().Length > 0);
20772075
Assert.True(peer.GetPort() > 0);
20782076
Assert.True(peer.GetRpcPort() == null || peer.GetRpcPort() >= 0);
2079-
Assert.NotNull(peer.IsOnline());
20802077
//if (peer.GetRpcCreditsPerHash() != null) TestUtils.testUnsignedBigInteger(peer.GetRpcCreditsPerHash());
20812078
if (fromConnection) Assert.Null(peer.GetLastSeenTimestamp());
20822079
else
@@ -2145,7 +2142,7 @@ private static void TestSubmitTxResultGood(MoneroSubmitTxResult result)
21452142
catch (Exception e)
21462143
{
21472144
MoneroUtils.Log(0, "Submit result is not good");
2148-
throw e;
2145+
throw;
21492146
}
21502147
}
21512148

@@ -2224,7 +2221,7 @@ private static void TestSubmitThenRelay(List<MoneroTx> txs)
22242221
catch (Exception e)
22252222
{
22262223
daemon.FlushTxPool(txHashes); // flush txs when relay fails to prevent double spends in other tests
2227-
throw e;
2224+
throw;
22282225
}
22292226

22302227
// wait for txs to be relayed // TODO (monero-project): all txs should be relayed: https://github.com/monero-project/monero/issues/8523

Monero.Test/Utils/TestUtils.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static MoneroWalletRpc GetWalletRpc()
9999
}
100100
else
101101
{
102-
throw e;
102+
throw;
103103
}
104104
}
105105

@@ -162,7 +162,7 @@ public static string GetExternalWalletAddress()
162162
}
163163

164164
MoneroNetworkType? networkType = info.GetNetworkType();
165-
165+
166166
switch (networkType)
167167
{
168168
case MoneroNetworkType.STAGENET:
@@ -176,7 +176,7 @@ public static string GetExternalWalletAddress()
176176
}
177177
}
178178

179-
public static MoneroWallet CreateWalletGroundTruth(MoneroNetworkType networkType, string seed, ulong? startHeight, ulong? restoreHeight)
179+
public static MoneroWallet CreateWalletGroundTruth(MoneroNetworkType networkType, string seed, ulong? startHeight, ulong? restoreHeight)
180180
{
181181
throw new NotImplementedException("MoneroWalletFull is not implemented");
182182
}
@@ -192,7 +192,8 @@ public static bool TxsMergeable(MoneroTxWallet tx1, MoneroTxWallet tx2)
192192
copy1.Merge(copy2);
193193
return true;
194194
}
195-
catch (Exception e) {
195+
catch (Exception e)
196+
{
196197
Console.WriteLine(e);
197198
return false;
198199
}

Monero/Common/GenUtils.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static string GetGuid()
99
{
1010
return Guid.NewGuid().ToString();
1111
}
12-
12+
1313
public static T? Reconcile<T>(T? val1, T? val2, bool? resolveDefined = null, bool? resolveTrue = null, bool? resolveMax = null)
1414
{
1515
// check for the same reference
@@ -26,9 +26,9 @@ public static string GetGuid()
2626

2727
if (val1 is bool bool1 && val2 is bool bool2)
2828
{
29-
if (bool1 == bool2) return val1;
29+
if (bool1 == bool2) return val1;
3030
}
31-
31+
3232
// resolve one value null
3333
if (val1 == null || val2 == null)
3434
{
@@ -41,7 +41,7 @@ public static string GetGuid()
4141
{
4242
return (T)(object)resolveTrue.Value;
4343
}
44-
44+
4545
if (val1 is IEnumerable e1 && val2 is IEnumerable e2)
4646
{
4747
var list1 = e1.Cast<object>().ToList();
@@ -119,8 +119,9 @@ public static string GetGuid()
119119
Array.Copy(array, startIndexInclusive, subarray, 0, newSize);
120120
return subarray;
121121
}
122-
123-
public static void WaitFor(ulong durationMs) {
122+
123+
public static void WaitFor(ulong durationMs)
124+
{
124125
WaitFor((int)durationMs);
125126
}
126127

@@ -136,13 +137,15 @@ public static void WaitFor(int durationMs)
136137
throw new Exception("Thread was interrupted while sleeping");
137138
}
138139
}
139-
140-
public static string KvLine(object? key, object? value, int indent, bool newline = true, bool ignoreUndefined = true) {
140+
141+
public static string KvLine(object? key, object? value, int indent, bool newline = true, bool ignoreUndefined = true)
142+
{
141143
if (value == null && ignoreUndefined) return "";
142144
return GetIndent(indent) + key + ": " + value + (newline ? '\n' : "");
143145
}
144-
145-
public static string GetIndent(int length) {
146+
147+
public static string GetIndent(int length)
148+
{
146149
string str = "";
147150
for (int i = 0; i < length; i++) str += " "; // two spaces
148151
return str;

Monero/Common/MoneroBlockHeader.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -266,28 +266,28 @@ public virtual MoneroBlockHeader Merge(MoneroBlockHeader? header)
266266
this.SetPowHash(GenUtils.Reconcile(this.GetPowHash(), header.GetPowHash()));
267267
return this;
268268
}
269-
269+
270270
public virtual bool Equals(MoneroBlockHeader? other)
271271
{
272272
if (other == null) return false;
273273
if (other == this) return true;
274-
return hash == other.hash &&
275-
height == other.height &&
276-
timestamp == other.timestamp &&
277-
size == other.size &&
278-
weight == other.weight &&
279-
longTermWeight == other.longTermWeight &&
280-
depth == other.depth &&
281-
difficulty == other.difficulty &&
282-
cumulativeDifficulty == other.cumulativeDifficulty &&
283-
majorVersion == other.majorVersion &&
284-
minorVersion == other.minorVersion &&
285-
nonce == other.nonce &&
286-
minerTxHash == other.minerTxHash &&
287-
numTxs == other.numTxs &&
288-
orphanStatus == other.orphanStatus &&
289-
prevHash == other.prevHash &&
290-
reward == other.reward &&
274+
return hash == other.hash &&
275+
height == other.height &&
276+
timestamp == other.timestamp &&
277+
size == other.size &&
278+
weight == other.weight &&
279+
longTermWeight == other.longTermWeight &&
280+
depth == other.depth &&
281+
difficulty == other.difficulty &&
282+
cumulativeDifficulty == other.cumulativeDifficulty &&
283+
majorVersion == other.majorVersion &&
284+
minorVersion == other.minorVersion &&
285+
nonce == other.nonce &&
286+
minerTxHash == other.minerTxHash &&
287+
numTxs == other.numTxs &&
288+
orphanStatus == other.orphanStatus &&
289+
prevHash == other.prevHash &&
290+
reward == other.reward &&
291291
powHash == other.powHash;
292292
}
293293
}

Monero/Common/MoneroUtils.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public static bool IsValidHex(string str)
248248
return false;
249249
}
250250
}
251-
251+
252252
public static void ValidateBase58(string standardAddress)
253253
{
254254
foreach (char c in standardAddress)
@@ -257,7 +257,7 @@ public static void ValidateBase58(string standardAddress)
257257
throw new MoneroError("Invalid Base58 " + standardAddress);
258258
}
259259
}
260-
260+
261261
public static bool IsValidBase58(string standardAddress)
262262
{
263263
try
@@ -365,7 +365,7 @@ public static MoneroIntegratedAddress GetIntegratedAddress(MoneroNetworkType net
365365
{
366366
throw new NotImplementedException("MoneroUtils.GetIntegratedAddress(): not implemented.");
367367
}
368-
368+
369369
public static Uri ParseUri(string uri)
370370
{
371371
if (!string.IsNullOrEmpty(uri) && !Regex.IsMatch(uri.ToLower(), @"^\w+://.+"))
@@ -503,7 +503,7 @@ private static int[] Uint64To8be(BigInteger num, int size)
503503
}
504504
return res;
505505
}
506-
506+
507507
private static string BinToHex(int[] data)
508508
{
509509
var builder = new StringBuilder();
@@ -518,7 +518,7 @@ public static Dictionary<string, object> BinaryBlocksToMap(byte[] blocks)
518518
{
519519
throw new NotImplementedException("MoneroUtils.BinaryBlocksToMap(): not implemented");
520520
}
521-
521+
522522
public static void MergeTx(List<MoneroTx> txs, MoneroTx tx)
523523
{
524524
foreach (MoneroTx aTx in txs)

Monero/Daemon/MoneroDaemonDefault.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public virtual List<MoneroDaemonListener> GetListeners()
117117
public virtual string? GetTxHex(string txHash, bool prune = false)
118118
{
119119
var hexes = GetTxHexes([txHash], prune);
120-
120+
121121
return hexes.FirstOrDefault();
122122
}
123123

0 commit comments

Comments
 (0)