-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HWW Validate String Path Platform specific fixes #12781
Open
Whem
wants to merge
7
commits into
WalletWasabi:master
Choose a base branch
from
Whem:hww_validation_string_fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f7b7b72
fix every platform
Whem 6779d6f
fix windows part
Whem a858c73
separate to platform validate string
Whem fe5e12a
fixes mocktests
Whem 3eda40a
rename to speakable method name of runtime extension
Whem 671aae2
delete runtimeextension and use osplatform as raw
Whem a25f279
Update WalletWasabi.Tests/Helpers/HwiValidationHelper.cs
Whem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace WalletWasabi.Tests.Helpers; | ||
|
||
public static class RuntimeExtension | ||
{ | ||
public static bool Running(this OSPlatform val) | ||
{ | ||
return RuntimeInformation.IsOSPlatform(val); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
using NBitcoin; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using WalletWasabi.Blockchain.Keys; | ||
|
@@ -562,7 +563,7 @@ public async Task JadeMockTestsAsync(Network network) | |
IEnumerable<HwiEnumerateEntry> enumerate = await client.EnumerateAsync(cts.Token); | ||
HwiEnumerateEntry entry = Assert.Single(enumerate); | ||
Assert.Equal(HardwareWalletModels.Jade, entry.Model); | ||
Assert.True(HwiValidationHelper.ValidatePathString(entry.Model, "COM3")); | ||
Assert.True(HwiValidationHelper.ValidatePathString(entry.Model, "COM3", OSPlatform.Windows)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Assert.Equal("COM3", entry.Path); | ||
Assert.False(entry.NeedsPassphraseSent); | ||
Assert.False(entry.NeedsPinSent); | ||
|
@@ -654,7 +655,7 @@ public async Task BitBox02BtcOnlyMockTestsAsync(Network network) | |
Assert.Single(enumerate); | ||
HwiEnumerateEntry entry = enumerate.Single(); | ||
Assert.Equal(HardwareWalletModels.BitBox02_BTCOnly, entry.Model); | ||
Assert.True(HwiValidationHelper.ValidatePathString(entry.Model, @"\\?\hid#vid_03eb&pid_2403#6&229ae20&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}")); | ||
Assert.True(HwiValidationHelper.ValidatePathString(entry.Model, @"\\?\hid#vid_03eb&pid_2403#6&229ae20&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}", OSPlatform.Windows)); | ||
Assert.Equal(@"\\?\hid#vid_03eb&pid_2403#6&229ae20&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}", entry.Path); | ||
Assert.False(entry.NeedsPassphraseSent); | ||
Assert.False(entry.NeedsPinSent); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this new parameter anymore, it can be reverted. Same for the mocked tests.
Also, you can remove these extra checks
|| (osPlatform != null && osPlatform == OSPlatform.Windows)
.No need for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock tests are only compatible with Windows operating system. You can check predefined paths. In that case, osplatform parameter is needed as the mocktest may fail.
https://github.com/zkSNACKs/WalletWasabi/blob/0516c1831ae3ac780df277d43360a2d778c94df8/WalletWasabi.Tests/UnitTests/Hwi/MockedDeviceTests.cs#L657
It's important to note that at this time we do not have the capability to separate mock tests for multiple platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not write code only for the tests, please remove this parameter,
If the test is working only on Windows, then disable it on other platforms:
Here you are forcing the tests to act like they were running on Windows which is an extremely bad practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HwiKatas test is compatible with all platforms. However, the predefined data used in the mock test is specifically designed for Windows.
Initially, I thought that passing Windows as a parameter in the mocktest would display the expected results since it's only a mock test and not real data.
However, if required, I could expand the mock bridge test to a platform-specific approach.