copy nano s's kata to s+'s
MODIFY
WalletWasabi.Tests/AcceptanceTests/HwiKatas.cs
WalletWasabi.Tests/AcceptanceTests/HwiKatas.cs
@@ -290,6 +290,89 @@ public class HwiKatas
Assert.Equal(TransactionCheckResult.Success, checkResult);
}
+ [Fact]
+ public async Task LedgerNanoSPlusKataAsync()
+ {
+ // --- USER INTERACTIONS ---
+ //
+ // Connect and initialize your Nano S+ with the following seed phrase:
+ // more maid moon upgrade layer alter marine screen benefit way cover alcohol
+ // Run this test.
+ // displayaddress request(derivation path): approve
+ // displayaddress request: reject
+ // displayaddress request(derivation path): approve
+ // displayaddress request: approve
+ // displayaddress request(derivation path): approve
+ // displayaddress request: approve
+ // signtx request: reject
+ // signtx request: accept
+ // confirm transaction: accept and send
+ //
+ // --- USER INTERACTIONS ---
+
+ var network = Network.Main;
+ var client = new HwiClient(network);
+ using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
+ var enumerate = await client.EnumerateAsync(cts.Token);
+ HwiEnumerateEntry entry = Assert.Single(enumerate);
+ Assert.NotNull(entry.Path);
+ Assert.Equal(HardwareWalletModels.Ledger_Nano_S_Plus, entry.Model);
+ Assert.NotNull(entry.Fingerprint);
+ Assert.Null(entry.Code);
+ Assert.Null(entry.Error);
+ Assert.Null(entry.SerialNumber);
+ Assert.False(entry.NeedsPassphraseSent);
+ Assert.False(entry.NeedsPinSent);
+
+ string devicePath = entry.Path;
+ HardwareWalletModels deviceType = entry.Model;
+ HDFingerprint fingerprint = entry.Fingerprint!.Value;
+
+ await Assert.ThrowsAsync<HwiException>(async () => await client.SetupAsync(deviceType, devicePath, false, cts.Token));
+
+ await Assert.ThrowsAsync<HwiException>(async () => await client.RestoreAsync(deviceType, devicePath, false, cts.Token));
+
+ await Assert.ThrowsAsync<HwiException>(async () => await client.PromptPinAsync(deviceType, devicePath, cts.Token));
+
+ await Assert.ThrowsAsync<HwiException>(async () => await client.SendPinAsync(deviceType, devicePath, 1111, cts.Token));
+
+ KeyPath keyPath1 = KeyManager.GetAccountKeyPath(network).Derive("0/0");
+ KeyPath keyPath2 = KeyManager.GetAccountKeyPath(network).Derive("0/1");
+ ExtPubKey xpub1 = await client.GetXpubAsync(deviceType, devicePath, keyPath1, cts.Token);
+ ExtPubKey xpub2 = await client.GetXpubAsync(deviceType, devicePath, keyPath2, cts.Token);
+ Assert.NotNull(xpub1);
+ Assert.NotNull(xpub2);
+ Assert.NotEqual(xpub1, xpub2);
+
+ // USER SHOULD REFUSE ACTION
+ await Assert.ThrowsAsync<HwiException>(async () => await client.DisplayAddressAsync(deviceType, devicePath, keyPath1, cts.Token));
+
+ // USER: CONFIRM
+ BitcoinWitPubKeyAddress address1 = await client.DisplayAddressAsync(deviceType, devicePath, keyPath1, cts.Token);
+ // USER: CONFIRM
+ BitcoinWitPubKeyAddress address2 = await client.DisplayAddressAsync(fingerprint, keyPath2, cts.Token);
+ Assert.NotNull(address1);
+ Assert.NotNull(address2);
+ Assert.NotEqual(address1, address2);
+ var expectedAddress1 = xpub1.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
+ var expectedAddress2 = xpub2.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
+ Assert.Equal(expectedAddress1, address1);
+ Assert.Equal(expectedAddress2, address2);
+
+ // USER: REFUSE
+ var ex = await Assert.ThrowsAsync<HwiException>(async () => await client.SignTxAsync(deviceType, devicePath, Psbt, cts.Token));
+ Assert.Equal(HwiErrorCode.UnknownError, ex.ErrorCode);
+
+ // USER: CONFIRM
+ PSBT signedPsbt = await client.SignTxAsync(deviceType, devicePath, Psbt, cts.Token);
+
+ Transaction signedTx = signedPsbt.GetOriginalTransaction();
+ Assert.Equal(Psbt.GetOriginalTransaction().GetHash(), signedTx.GetHash());
+
+ var checkResult = signedTx.Check();
+ Assert.Equal(TransactionCheckResult.Success, checkResult);
+ }
+
[Fact]
public async Task LedgerNanoXKataAsync()
{

copy nano s's kata to s+'s