Add more mock test to TrezorOne
MODIFY
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/HwiProcessBridgeMock.cs
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/HwiProcessBridgeMock.cs
@@ -91,7 +91,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} setup"))
{
- if (Model == HardwareWalletModels.TrezorT)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.TrezorOne)
{
var response = "{\"error\": \"setup requires interactive mode\", \"code\": -9}";
var code = 0;
@@ -106,7 +106,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} --interactive setup"))
{
- if (Model == HardwareWalletModels.TrezorT)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.TrezorOne)
{
var response = successTrueResponse;
var code = 0;
@@ -121,7 +121,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} --interactive restore"))
{
- if (Model == HardwareWalletModels.TrezorT)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.TrezorOne)
{
var response = successTrueResponse;
var code = 0;
@@ -136,7 +136,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} promptpin"))
{
- if (Model == HardwareWalletModels.TrezorT)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.TrezorOne)
{
var response = "{\"error\": \"The PIN has already been sent to this device\", \"code\": -11}\r\n";
var code = 0;
@@ -151,7 +151,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} sendpin", true))
{
- if (Model == HardwareWalletModels.TrezorT)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.TrezorOne)
{
var response = "{\"error\": \"The PIN has already been sent to this device\", \"code\": -11}";
var code = 0;
@@ -166,7 +166,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareGetXbpubArguments(arguments, out string xpub))
{
- if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1 || Model == HardwareWalletModels.TrezorOne)
{
var response = $"{{\"xpub\": \"{xpub}\"}}\r\n";
var code = 0;
@@ -175,7 +175,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(out bool t1, arguments, $"{devicePathAndTypeArgumentString} displayaddress --path m/84h/0h/0h --wpkh", false))
{
- if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1 || Model == HardwareWalletModels.TrezorOne)
{
string response = t1
? "{\"address\": \"tb1q7zqqsmqx5ymhd7qn73lm96w5yqdkrmx7rtzlxy\"}\r\n"
@@ -186,7 +186,7 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
}
else if (CompareArguments(out bool t2, arguments, $"{devicePathAndTypeArgumentString} displayaddress --path m/84h/0h/0h/1 --wpkh", false))
{
- if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1)
+ if (Model == HardwareWalletModels.TrezorT || Model == HardwareWalletModels.ColdcardMk1 || Model == HardwareWalletModels.TrezorOne)
{
string response = t2
? "{\"address\": \"tb1qmaveee425a5xjkjcv7m6d4gth45jvtnjqhj3l6\"}\r\n"

MODIFY
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/MockedDeviceTests.cs
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/MockedDeviceTests.cs
@@ -127,6 +127,54 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
var devicePath = entry.Path;
await client.WipeAsync(deviceType, devicePath, cts.Token);
+ await client.SetupAsync(deviceType, devicePath, false, cts.Token);
+ await client.RestoreAsync(deviceType, devicePath, false, cts.Token);
+
+ // TrezorOne doesn't support it.
+ var promptpin = await Assert.ThrowsAsync<HwiException>(async () => await client.PromptPinAsync(deviceType, devicePath, cts.Token));
+ Assert.Equal("The PIN has already been sent to this device", promptpin.Message);
+ Assert.Equal(HwiErrorCode.DeviceAlreadyUnlocked, promptpin.ErrorCode);
+
+ var sendpin = await Assert.ThrowsAsync<HwiException>(async () => await client.SendPinAsync(deviceType, devicePath, 1111, cts.Token));
+ Assert.Equal("The PIN has already been sent to this device", sendpin.Message);
+ Assert.Equal(HwiErrorCode.DeviceAlreadyUnlocked, sendpin.ErrorCode);
+
+ KeyPath keyPath1 = KeyManager.DefaultAccountKeyPath;
+ KeyPath keyPath2 = KeyManager.DefaultAccountKeyPath.Derive(1);
+ ExtPubKey xpub1 = await client.GetXpubAsync(deviceType, devicePath, keyPath1, cts.Token);
+ ExtPubKey xpub2 = await client.GetXpubAsync(deviceType, devicePath, keyPath2, cts.Token);
+ var expecteXpub1 = NBitcoinHelpers.BetterParseExtPubKey("xpub6DHjDx4gzLV37gJWMxYJAqyKRGN46MT61RHVizdU62cbVUYu9L95cXKzX62yJ2hPbN11EeprS8sSn8kj47skQBrmycCMzFEYBQSntVKFQ5M");
+ var expecteXpub2 = NBitcoinHelpers.BetterParseExtPubKey("xpub6FJS1ne3STcKdQ9JLXNzZXidmCNZ9dxLiy7WVvsRkcmxjJsrDKJKEAXq4MGyEBM3vHEw2buqXezfNK5SNBrkwK7Fxjz1TW6xzRr2pUyMWFu");
+ Assert.Equal(expecteXpub1, xpub1);
+ Assert.Equal(expecteXpub2, xpub2);
+
+ BitcoinWitPubKeyAddress address1 = await client.DisplayAddressAsync(deviceType, devicePath, keyPath1, cts.Token);
+ BitcoinWitPubKeyAddress address2 = await client.DisplayAddressAsync(deviceType, devicePath, keyPath2, cts.Token);
+
+ BitcoinAddress expectedAddress1;
+ BitcoinAddress expectedAddress2;
+ if (network == Network.Main)
+ {
+ expectedAddress1 = BitcoinAddress.Create("bc1q7zqqsmqx5ymhd7qn73lm96w5yqdkrmx7fdevah", Network.Main);
+ expectedAddress2 = BitcoinAddress.Create("bc1qmaveee425a5xjkjcv7m6d4gth45jvtnj23fzyf", Network.Main);
+ }
+ else if (network == Network.TestNet)
+ {
+ expectedAddress1 = BitcoinAddress.Create("tb1q7zqqsmqx5ymhd7qn73lm96w5yqdkrmx7rtzlxy", Network.TestNet);
+ expectedAddress2 = BitcoinAddress.Create("tb1qmaveee425a5xjkjcv7m6d4gth45jvtnjqhj3l6", Network.TestNet);
+ }
+ else if (network == Network.RegTest)
+ {
+ expectedAddress1 = BitcoinAddress.Create("bcrt1q7zqqsmqx5ymhd7qn73lm96w5yqdkrmx7pzmj3d", Network.RegTest);
+ expectedAddress2 = BitcoinAddress.Create("bcrt1qmaveee425a5xjkjcv7m6d4gth45jvtnjz7tugn", Network.RegTest);
+ }
+ else
+ {
+ throw new NotSupportedException($"{network} not supported.");
+ }
+
+ Assert.Equal(expectedAddress1, address1);
+ Assert.Equal(expectedAddress2, address2);
}
}
@@ -216,7 +264,6 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
Assert.Equal(expectedAddress1, address1);
Assert.Equal(expectedAddress2, address2);
-
}
}

Add more mock test to TrezorOne