Skip to content

Commit

Permalink
refactor(WalletParserTests.cs): Remove unused code and fix variable n…
Browse files Browse the repository at this point in the history
…ames for clarity

The changes in this commit remove unused code and fix variable names in the WalletParserTests.cs file.

The following changes were made:
- Removed the unused wallet1HotWalletImported variable for Native Segwit, Nested Segwit, Legacy, and Taproot hot wallets.
- Renamed the wallet1ColdWallet variable to walletColdWallet for clarity.
- Updated the variable names in the GetOutputDescriptor method calls to reflect the changes.

These changes improve the readability and maintainability of the code.
  • Loading branch information
markettes committed Oct 26, 2023
1 parent 1b9a049 commit 6a662e3
Showing 1 changed file with 7 additions and 81 deletions.
88 changes: 7 additions & 81 deletions test/NodeGuard.Tests/Helpers/WalletParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,6 @@ public void GetOutputDescriptor_NativeSegwits()
}
}
};

// Testing NodeGuard imported Native Segwit hot wallet
var wallet1HotWalletImported = new Wallet()
{
IsBIP39Imported = true,
IsHotWallet = true,
WalletAddressType = WalletAddressType.NativeSegwit,
MofN = 1,
Keys = new List<Key>() {
new() {
XPUB = "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB",
Path = "48'/0'/0'",
MasterFingerprint = "ed0210c8",
}
}
};

// Testing NodeGuard created Native Segwit cold wallet
var wallet1ColdWallet = new Wallet()
Expand Down Expand Up @@ -220,13 +204,11 @@ public void GetOutputDescriptor_NativeSegwits()

// Act
var outputDescriptor1 = WalletParser.GetOutputDescriptor(wallet1HotWalletCreated, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1HotWalletImported, "mainnet");
var outputDescriptor3 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");

// Assert
outputDescriptor1.Should().Contain("wpkh([ed0210c8/48'/0'/0']xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*)#");
outputDescriptor2.Should().Contain("wpkh(xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*)#");
outputDescriptor3.Should().Contain(
outputDescriptor2.Should().Contain(
"wsh(sortedmulti(2," +
"[ed0210c8/48'/0'/0]xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*," +
"[ed0210c8/48'/0'/1]xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/0/*," +
Expand Down Expand Up @@ -256,22 +238,6 @@ public void GetOutputDescriptor_NestedSegwits()
}
};

// Testing NodeGuard imported Nested Segwit hot wallet
var wallet1HotWalletImported = new Wallet()
{
IsBIP39Imported = true,
IsHotWallet = true,
WalletAddressType = WalletAddressType.NestedSegwit,
MofN = 1,
Keys = new List<Key>() {
new() {
XPUB = "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB",
Path = "48'/0'/0'",
MasterFingerprint = "ed0210c8",
}
}
};

// Testing NodeGuard created Nested Segwit cold wallet
var wallet1ColdWallet = new Wallet()
{
Expand Down Expand Up @@ -303,13 +269,11 @@ public void GetOutputDescriptor_NestedSegwits()

//Act
var outputDescriptor1 = WalletParser.GetOutputDescriptor(wallet1HotWalletCreated, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1HotWalletImported, "mainnet");
var outputDescriptor3 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");

// Assert
outputDescriptor1.Should().Contain("sh(wpkh([ed0210c8/48'/0'/0']xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*))#");
outputDescriptor2.Should().Contain("sh(wpkh(xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*))#");
outputDescriptor3.Should().Contain(
outputDescriptor2.Should().Contain(
"sh(sortedmulti(2," +
"[ed0210c8/48'/0'/0]xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*," +
"[ed0210c8/48'/0'/1]xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/0/*," +
Expand Down Expand Up @@ -341,24 +305,6 @@ public void GetOutputDescriptor_Legacy()
}
};

// Testing NodeGuard imported Legacy hot wallet
var wallet1HotWalletImported = new Wallet()
{
IsBIP39Imported = true,
IsHotWallet = true,
WalletAddressType = WalletAddressType.Legacy,
MofN = 1,
Keys = new List<Key>()
{
new()
{
XPUB = "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB",
Path = "48'/0'/0'",
MasterFingerprint = "ed0210c8",
}
}
};

// Testing NodeGuard created Legacy cold wallet
var wallet1ColdWallet = new Wallet()
{
Expand Down Expand Up @@ -390,13 +336,11 @@ public void GetOutputDescriptor_Legacy()

// Act
var outputDescriptor1 = WalletParser.GetOutputDescriptor(wallet1HotWalletCreated, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1HotWalletImported, "mainnet");
var outputDescriptor3 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");
var outputDescriptor2 = WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");

// Assert
outputDescriptor1.Should().Contain("pkh([ed0210c8/48'/0'/0']xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*)#");
outputDescriptor2.Should().Contain("pkh(xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*)#");
outputDescriptor3.Should().Contain(
outputDescriptor2.Should().Contain(
"sortedmulti(2," +
"[ed0210c8/48'/0'/0]xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/0/*," +
"[ed0210c8/48'/0'/1]xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/0/*," +
Expand Down Expand Up @@ -426,22 +370,6 @@ public void GetOutputDescriptor_Taproot()
}
};

// Testing NodeGuard imported Taproot hot wallet
var wallet1HotWalletImported = new Wallet()
{
IsBIP39Imported = true,
IsHotWallet = true,
WalletAddressType = WalletAddressType.Taproot,
MofN = 1,
Keys = new List<Key>() {
new() {
XPUB = "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB",
Path = "48'/0'/0'",
MasterFingerprint = "ed0210c8",
}
}
};

// Testing NodeGuard created Taproot cold wallet
var wallet1ColdWallet = new Wallet()
{
Expand Down Expand Up @@ -473,12 +401,10 @@ public void GetOutputDescriptor_Taproot()

// Act
var taprootFunction1 = () => WalletParser.GetOutputDescriptor(wallet1HotWalletCreated, "mainnet");
var taprootFunction2 = () => WalletParser.GetOutputDescriptor(wallet1HotWalletImported, "mainnet");
var taprootFunction3 = () => WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");
var taprootFunction2 = () => WalletParser.GetOutputDescriptor(wallet1ColdWallet, "mainnet");

// Assert
taprootFunction1.Should().Throw<NotImplementedException>();
taprootFunction2.Should().Throw<NotImplementedException>();
taprootFunction3.Should().Throw<NotImplementedException>();
}
}

0 comments on commit 6a662e3

Please sign in to comment.