Fix a few warnings.
MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/ConfigTranslatorTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/ConfigTranslatorTests.cs
@@ -81,22 +81,28 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
config.AddOrUpdate("main.whitebind=127.0.0.1:18444");
WhiteBind? whiteBind = translator.TryGetWhiteBind();
- var ipEndPoint = whiteBind.EndPoint as IPEndPoint;
- Assert.Equal(IPAddress.Loopback, ipEndPoint.Address);
+ Assert.NotNull(whiteBind);
+ var ipEndPoint = whiteBind!.EndPoint as IPEndPoint;
+ Assert.NotNull(ipEndPoint);
+ Assert.Equal(IPAddress.Loopback, ipEndPoint!.Address);
Assert.Equal(18444, ipEndPoint.Port);
Assert.Equal("", whiteBind.Permissions);
config.AddOrUpdate("whitebind=127.0.0.1:0");
whiteBind = translator.TryGetWhiteBind();
- ipEndPoint = whiteBind.EndPoint as IPEndPoint;
- Assert.Equal(IPAddress.Loopback, ipEndPoint.Address);
+ Assert.NotNull(whiteBind);
+ ipEndPoint = whiteBind!.EndPoint as IPEndPoint;
+ Assert.NotNull(ipEndPoint);
+ Assert.Equal(IPAddress.Loopback, ipEndPoint!.Address);
Assert.Equal(0, ipEndPoint.Port);
Assert.Equal("", whiteBind.Permissions);
config.AddOrUpdate("whitebind=127.0.0.1");
whiteBind = translator.TryGetWhiteBind();
- ipEndPoint = whiteBind.EndPoint as IPEndPoint;
- Assert.Equal(IPAddress.Loopback, ipEndPoint.Address);
+ Assert.NotNull(whiteBind);
+ ipEndPoint = whiteBind!.EndPoint as IPEndPoint;
+ Assert.NotNull(ipEndPoint);
+ Assert.Equal(IPAddress.Loopback, ipEndPoint!.Address);
// Default port.
Assert.Equal(8333, ipEndPoint.Port);
@@ -104,15 +110,19 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
config.AddOrUpdate("whitebind=foo@127.0.0.1");
whiteBind = translator.TryGetWhiteBind();
- ipEndPoint = whiteBind.EndPoint as IPEndPoint;
- Assert.Equal(IPAddress.Loopback, ipEndPoint.Address);
+ Assert.NotNull(whiteBind);
+ ipEndPoint = whiteBind!.EndPoint as IPEndPoint;
+ Assert.NotNull(ipEndPoint);
+ Assert.Equal(IPAddress.Loopback, ipEndPoint!.Address);
Assert.Equal(8333, ipEndPoint.Port);
Assert.Equal("foo", whiteBind.Permissions);
config.AddOrUpdate("whitebind=foo,boo@127.0.0.1");
whiteBind = translator.TryGetWhiteBind();
- ipEndPoint = whiteBind.EndPoint as IPEndPoint;
- Assert.Equal(IPAddress.Loopback, ipEndPoint.Address);
+ Assert.NotNull(whiteBind);
+ ipEndPoint = whiteBind!.EndPoint as IPEndPoint;
+ Assert.NotNull(ipEndPoint);
+ Assert.Equal(IPAddress.Loopback, ipEndPoint!.Address);
Assert.Equal(8333, ipEndPoint.Port);
Assert.Equal("foo,boo", whiteBind.Permissions);

MODIFY
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
@@ -58,7 +58,7 @@ namespace WalletWasabi.Tests.UnitTests
Assert.NotEqual(manager.EncryptedSecret, differentManager.EncryptedSecret);
Assert.NotEqual(manager.ExtPubKey, differentManager.ExtPubKey);
- var manager5 = new KeyManager(manager2.EncryptedSecret, manager2.ChainCode, password: null);
+ var manager5 = new KeyManager(manager2.EncryptedSecret, manager2.ChainCode, password: null!);
Assert.Equal(manager2.ChainCode, manager5.ChainCode);
Assert.Equal(manager2.EncryptedSecret, manager5.EncryptedSecret);
Assert.Equal(manager2.ExtPubKey, manager5.ExtPubKey);
@@ -149,7 +149,7 @@ namespace WalletWasabi.Tests.UnitTests
var random = new Random();
var k1 = manager.GenerateNewKey(SmartLabel.Empty, KeyState.Clean, true);
- var k2 = manager.GenerateNewKey(null, KeyState.Clean, true);
+ var k2 = manager.GenerateNewKey(label: null!, KeyState.Clean, true);
Assert.Equal(SmartLabel.Empty, k1.Label);
Assert.Equal(SmartLabel.Empty, k2.Label);
@@ -207,7 +207,7 @@ namespace WalletWasabi.Tests.UnitTests
File.Delete(filePath);
}
- if (Directory.Exists(dir))
+ if (dir is not null && Directory.Exists(dir))
{
if (Directory.GetFiles(dir).Length == 0)
{

MODIFY
WalletWasabi.Tests/UnitTests/SmartHeaderTests.cs
WalletWasabi.Tests/UnitTests/SmartHeaderTests.cs
@@ -15,8 +15,8 @@ namespace WalletWasabi.Tests.UnitTests
new SmartHeader(uint256.Zero, uint256.One, 1, blockTime);
new SmartHeader(uint256.Zero, uint256.One, 1, blockTime);
- Assert.Throws<ArgumentNullException>(() => new SmartHeader(null, uint256.One, 1, blockTime));
- Assert.Throws<ArgumentNullException>(() => new SmartHeader(uint256.Zero, null, 1, blockTime));
+ Assert.Throws<ArgumentNullException>(() => new SmartHeader(blockHash: null!, uint256.One, 1, blockTime));
+ Assert.Throws<ArgumentNullException>(() => new SmartHeader(uint256.Zero, prevHash: null!, 1, blockTime));
Assert.Throws<InvalidOperationException>(() => new SmartHeader(uint256.Zero, uint256.Zero, 1, blockTime));
}

MODIFY
WalletWasabi.Tests/UnitTests/SmartLabelTests.cs
WalletWasabi.Tests/UnitTests/SmartLabelTests.cs
@@ -16,10 +16,10 @@ namespace WalletWasabi.Tests.UnitTests
label = new SmartLabel("");
Assert.Equal("", label);
- label = new SmartLabel(null);
+ label = new SmartLabel(null!);
Assert.Equal("", label);
- label = new SmartLabel(null, null);
+ label = new SmartLabel(null!, null!);
Assert.Equal("", label);
label = new SmartLabel(" ");
@@ -55,7 +55,7 @@ namespace WalletWasabi.Tests.UnitTests
label = new SmartLabel(new List<string>() { " foo ", " bar " });
Assert.Equal("bar, foo", label);
- label = new SmartLabel(new List<string>() { "foo:", ":bar", null, ":buz:", ",", ": , :", "qux:quux", "corge,grault", "", " ", " , garply, waldo,", " : , : , fred , : , : plugh, : , : ," });
+ label = new SmartLabel(new List<string>() { "foo:", ":bar", null!, ":buz:", ",", ": , :", "qux:quux", "corge,grault", "", " ", " , garply, waldo,", " : , : , fred , : , : plugh, : , : ," });
Assert.Equal("bar, buz, corge, foo, fred, garply, grault, plugh, quux, qux, waldo", label);
label = new SmartLabel(",: foo::bar :buz:,: , :qux:quux, corge,grault , garply, waldo, : , : , fred , : , : plugh, : , : ,");
@@ -79,8 +79,8 @@ namespace WalletWasabi.Tests.UnitTests
var label3 = new SmartLabel("bar, buz");
Assert.NotEqual(label, label3);
- SmartLabel label4 = null;
- SmartLabel label5 = null;
+ SmartLabel label4 = null!;
+ SmartLabel label5 = null!;
Assert.Equal(label4, label5);
Assert.NotEqual(label, label4);
Assert.False(label.Equals(label4));

Fix a few warnings.