mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
upgrade junit tests from 4 to 5
This commit is contained in:
parent
22310cd8c9
commit
1d50b4f296
11 changed files with 197 additions and 208 deletions
|
@ -135,7 +135,8 @@ dependencies {
|
|||
implementation('com.github.hervegirod:fxsvgimage:1.0b2')
|
||||
implementation('com.sparrowwallet:toucan:0.9.0')
|
||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0')
|
||||
testImplementation('org.junit.vintage:junit-vintage-engine:5.10.0')
|
||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.10.0')
|
||||
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
|
||||
}
|
||||
|
||||
compileJava {
|
||||
|
@ -156,6 +157,7 @@ processResources {
|
|||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED'
|
||||
}
|
||||
|
||||
|
@ -701,5 +703,4 @@ extraJavaModuleInfo {
|
|||
module('jcommander-1.81.jar', 'com.beust.jcommander', '1.81') {
|
||||
exports('com.beust.jcommander')
|
||||
}
|
||||
module('hamcrest-core-1.3.jar', 'org.hamcrest.core', '1.3')
|
||||
}
|
2
drongo
2
drongo
|
@ -1 +1 @@
|
|||
Subproject commit e82e5c8218e67cb46e4a988a0f234a797e7b5453
|
||||
Subproject commit d993c97cc37f95d17383b9bc88630e1b17b0bb93
|
|
@ -5,8 +5,8 @@ import com.sparrowwallet.drongo.policy.PolicyType;
|
|||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import com.sparrowwallet.drongo.wallet.WalletModel;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -18,16 +18,16 @@ public class CaravanMultisigTest extends IoTest {
|
|||
public void importWallet1() throws ImportException {
|
||||
CaravanMultisig ccMultisig = new CaravanMultisig();
|
||||
Wallet wallet = ccMultisig.importWallet(getInputStream("caravan-multisig-export-1.json"), null);
|
||||
Assert.assertEquals("Test Wallet", wallet.getName());
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wsh(sortedmulti(2,mercury,venus,earth))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assert.assertEquals("8188029f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals(WalletModel.TREZOR_1, wallet.getKeystores().get(0).getWalletModel());
|
||||
Assert.assertEquals("xpub6EMVvcTUbaABdaPLaVWE72CjcN72URa5pKK1knrKLz1hKaDwUkgddc3832a8MHEpLyuow7MfjMRomt2iMtwPH4pWrFLft4JsquHjeZfKsYp", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals("Test Wallet", wallet.getName());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wsh(sortedmulti(2,mercury,venus,earth))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals("8188029f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals(WalletModel.TREZOR_1, wallet.getKeystores().get(0).getWalletModel());
|
||||
Assertions.assertEquals("xpub6EMVvcTUbaABdaPLaVWE72CjcN72URa5pKK1knrKLz1hKaDwUkgddc3832a8MHEpLyuow7MfjMRomt2iMtwPH4pWrFLft4JsquHjeZfKsYp", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -40,6 +40,6 @@ public class CaravanMultisigTest extends IoTest {
|
|||
byte[] exportedBytes = baos.toByteArray();
|
||||
String original = new String(walletBytes);
|
||||
String exported = new String(exportedBytes);
|
||||
Assert.assertEquals(original, exported);
|
||||
Assertions.assertEquals(original, exported);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.sparrowwallet.sparrow.io;
|
|||
import com.sparrowwallet.drongo.ExtendedKey;
|
||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CoboVaultSinglesigTest extends IoTest {
|
||||
@Test
|
||||
|
@ -12,22 +12,16 @@ public class CoboVaultSinglesigTest extends IoTest {
|
|||
CoboVaultSinglesig coboSingleSig = new CoboVaultSinglesig();
|
||||
Keystore keystore = coboSingleSig.getKeystore(ScriptType.P2WPKH, getInputStream("cobo-singlesig-keystore-1.json"), null);
|
||||
|
||||
Assert.assertEquals("Cobo Vault", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("73c5da0a", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Cobo Vault", keystore.getLabel());
|
||||
Assertions.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("73c5da0a", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test(expected = ImportException.class)
|
||||
@Test
|
||||
public void testIncorrectScriptType() throws ImportException {
|
||||
CoboVaultSinglesig coboSingleSig = new CoboVaultSinglesig();
|
||||
Keystore keystore = coboSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cobo-singlesig-keystore-1.json"), null);
|
||||
|
||||
Assert.assertEquals("Cobo Vault", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("73c5da0a", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertThrows(ImportException.class, () -> coboSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cobo-singlesig-keystore-1.json"), null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import com.sparrowwallet.drongo.policy.PolicyType;
|
|||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Locale;
|
||||
|
@ -20,17 +20,17 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
Network.set(Network.TESTNET);
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2SH_P2WSH, getInputStream("cc-multisig-keystore-1.json"), null);
|
||||
Assert.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assert.assertEquals("m/48'/1'/0'/1'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("Upub5T4XUooQzDXL58NCHk8ZCw9BsRSLCtnyHeZEExAq1XdnBFXiXVrHFuvvmh3TnCR7XmKHxkwqdACv68z7QKT1vwru9L1SZSsw8B2fuBvtSa6"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assertions.assertEquals("m/48'/1'/0'/1'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("Upub5T4XUooQzDXL58NCHk8ZCw9BsRSLCtnyHeZEExAq1XdnBFXiXVrHFuvvmh3TnCR7XmKHxkwqdACv68z7QKT1vwru9L1SZSsw8B2fuBvtSa6"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test(expected = ImportException.class)
|
||||
@Test
|
||||
public void importKeystore1IncorrectScriptType() throws ImportException {
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cc-multisig-keystore-1.json"), null);
|
||||
Assertions.assertThrows(ImportException.class, () -> ccMultisig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cc-multisig-keystore-1.json"), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -38,11 +38,11 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
Network.set(Network.TESTNET);
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2SH, getInputStream("cc-multisig-keystore-2.json"), null);
|
||||
Assert.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assert.assertEquals("m/45'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("6ba6cfd0", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("tpubD9429UXFGCTKJ9NdiNK4rC5ygqSUkginycYHccqSg5gkmyQ7PZRHNjk99M6a6Y3NY8ctEUUJvCu6iCCui8Ju3xrHRu3Ez1CKB4ZFoRZDdP9"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assertions.assertEquals("m/45'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("6ba6cfd0", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("tpubD9429UXFGCTKJ9NdiNK4rC5ygqSUkginycYHccqSg5gkmyQ7PZRHNjk99M6a6Y3NY8ctEUUJvCu6iCCui8Ju3xrHRu3Ez1CKB4ZFoRZDdP9"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -50,23 +50,23 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
Network.set(Network.TESTNET);
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2WSH, getInputStream("cc-multisig-keystore-2.json"), null);
|
||||
Assert.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assert.assertEquals("m/48'/1'/0'/2'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("6ba6cfd0", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("Vpub5nUnvPehg1VYQh13dGznx1P9moac3SNUrn3qhU9r85RhXabYbSSBNsNNwyR7akozAZJw1SZmRRjry1zY8PWMuw8Ga1vQZ5qzPjKyTDQwtzs"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assertions.assertEquals("m/48'/1'/0'/2'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("6ba6cfd0", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("Vpub5nUnvPehg1VYQh13dGznx1P9moac3SNUrn3qhU9r85RhXabYbSSBNsNNwyR7akozAZJw1SZmRRjry1zY8PWMuw8Ga1vQZ5qzPjKyTDQwtzs"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importWallet1() throws ImportException {
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Wallet wallet = ccMultisig.importWallet(getInputStream("cc-multisig-export-1.txt"), null);
|
||||
Assert.assertEquals("CC-2-of-4", wallet.getName());
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals("CC-2-of-4", wallet.getName());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,29 +74,29 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
Network.set(Network.TESTNET);
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Wallet wallet = ccMultisig.importWallet(getInputStream("cc-multisig-export-2.txt"), null);
|
||||
Assert.assertEquals("CC-2-of-4", wallet.getName());
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals("CC-2-of-4", wallet.getName());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importWalletMultiDeriv() throws ImportException {
|
||||
ColdcardMultisig ccMultisig = new ColdcardMultisig();
|
||||
Wallet wallet = ccMultisig.importWallet(getInputStream("cc-multisig-export-multideriv.txt"), null);
|
||||
Assert.assertEquals("el-CC-3-of-3-sb-2", wallet.getName());
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wsh(sortedmulti(3,coldcard1,coldcard2,coldcard3))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("06b57041", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertEquals("ca9a2b19", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/47'/0'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals("el-CC-3-of-3-sb-2", wallet.getName());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wsh(sortedmulti(3,coldcard1,coldcard2,coldcard3))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("06b57041", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals("ca9a2b19", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/47'/0'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -109,7 +109,7 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
byte[] exportedBytes = baos.toByteArray();
|
||||
String original = new String(walletBytes);
|
||||
String exported = new String(exportedBytes);
|
||||
Assert.assertEquals(original.replaceAll("created on [0-9A-F]+", ""), exported.replace("created by Sparrow", ""));
|
||||
Assertions.assertEquals(original.replaceAll("created on [0-9A-F]+", ""), exported.replace("created by Sparrow", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -122,10 +122,10 @@ public class ColdcardMultisigTest extends IoTest {
|
|||
byte[] exportedBytes = baos.toByteArray();
|
||||
String original = new String(walletBytes);
|
||||
String exported = new String(exportedBytes);
|
||||
Assert.assertEquals(original.replaceAll("Exported from Electrum", ""), exported.replace("Coldcard Multisig setup file (created by Sparrow)\n#", ""));
|
||||
Assertions.assertEquals(original.replaceAll("Exported from Electrum", ""), exported.replace("Coldcard Multisig setup file (created by Sparrow)\n#", ""));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
Network.set(null);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import com.sparrowwallet.drongo.ExtendedKey;
|
|||
import com.sparrowwallet.drongo.Network;
|
||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ColdcardSinglesigTest extends IoTest {
|
||||
@Test
|
||||
|
@ -15,11 +15,11 @@ public class ColdcardSinglesigTest extends IoTest {
|
|||
ColdcardSinglesig ccSingleSig = new ColdcardSinglesig();
|
||||
Keystore keystore = ccSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cc-singlesig-keystore-1.json"), null);
|
||||
|
||||
Assert.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assert.assertEquals("m/49'/1'/123'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("tpubDCDqt7XXvhAdy1MpSze5nMJA9x8DrdRaKALRRPasfxyHpiqWWEAr9cbDBQ9BcX7cB3up98Pk97U2QQ3xrvQsi5dNPmRYYhdcsKY9wwEY87T"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assertions.assertEquals("m/49'/1'/123'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("tpubDCDqt7XXvhAdy1MpSze5nMJA9x8DrdRaKALRRPasfxyHpiqWWEAr9cbDBQ9BcX7cB3up98Pk97U2QQ3xrvQsi5dNPmRYYhdcsKY9wwEY87T"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -28,14 +28,14 @@ public class ColdcardSinglesigTest extends IoTest {
|
|||
ColdcardSinglesig ccSingleSig = new ColdcardSinglesig();
|
||||
Keystore keystore = ccSingleSig.getKeystore(ScriptType.P2WPKH, getInputStream("cc-singlesig-keystore-1.json"), null);
|
||||
|
||||
Assert.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/1'/123'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("tpubDC7jGaaSE66VDB6VhEDFYQSCAyugXmfnMnrMVyHNzW9wryyTxvha7TmfAHd7GRXrr2TaAn2HXn9T8ep4gyNX1bzGiieqcTUNcu2poyntrET"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Coldcard", keystore.getLabel());
|
||||
Assertions.assertEquals("m/84'/1'/123'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("0f056943", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("tpubDC7jGaaSE66VDB6VhEDFYQSCAyugXmfnMnrMVyHNzW9wryyTxvha7TmfAHd7GRXrr2TaAn2HXn9T8ep4gyNX1bzGiieqcTUNcu2poyntrET"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
Network.set(null);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import com.sparrowwallet.drongo.policy.PolicyType;
|
|||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.MnemonicException;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -22,14 +22,14 @@ public class ElectrumTest extends IoTest {
|
|||
Electrum electrum = new Electrum();
|
||||
Wallet wallet = electrum.importWallet(getInputStream("electrum-singlesig-wallet.json"), null);
|
||||
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -41,14 +41,14 @@ public class ElectrumTest extends IoTest {
|
|||
electrum.exportWallet(wallet, baos, null);
|
||||
|
||||
wallet = electrum.importWallet(new ByteArrayInputStream(baos.toByteArray()), null);
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -57,16 +57,16 @@ public class ElectrumTest extends IoTest {
|
|||
Electrum electrum = new Electrum();
|
||||
Wallet wallet = electrum.importWallet(getInputStream("electrum-multisig-wallet.json"), null);
|
||||
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertEquals("7bb026be", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals("7bb026be", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,16 +79,16 @@ public class ElectrumTest extends IoTest {
|
|||
electrum.exportWallet(wallet, baos, null);
|
||||
|
||||
wallet = electrum.importWallet(new ByteArrayInputStream(baos.toByteArray()), null);
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertEquals("7bb026be", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals("7bb026be", wallet.getKeystores().get(2).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(2).getKeyDerivation().getDerivationPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -97,14 +97,14 @@ public class ElectrumTest extends IoTest {
|
|||
byte[] walletBytes = ByteStreams.toByteArray(getInputStream("electrum-encrypted"));
|
||||
Wallet wallet = electrum.importWallet(new ByteArrayInputStream(walletBytes), "pass");
|
||||
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("f881eac5", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub69iSRreMB6fu24sU8Tdxv7yYGqzPkDwPkwqUfKJTxW3p8afW7XvTewVCapuX3dQjdD197iF65WcjYaNpFbwWT3RyuZ1KJ3ToJNVWKWyAJ6f", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("f881eac5", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub69iSRreMB6fu24sU8Tdxv7yYGqzPkDwPkwqUfKJTxW3p8afW7XvTewVCapuX3dQjdD197iF65WcjYaNpFbwWT3RyuZ1KJ3ToJNVWKWyAJ6f", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -114,22 +114,22 @@ public class ElectrumTest extends IoTest {
|
|||
Wallet wallet = electrum.importWallet(new ByteArrayInputStream(walletBytes), null);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
electrum.exportWallet(wallet, baos, null);
|
||||
Assert.assertEquals("e14c40c638e2c83d1f20e5ee9cd744bc2ba1ef64fa939926f3778fc8735e891f56852f687b32bbd044f272d2831137e3eeba61fd1f285fa73dcc97d9f2be3cd1", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getSeedBytes()));
|
||||
Assertions.assertEquals("e14c40c638e2c83d1f20e5ee9cd744bc2ba1ef64fa939926f3778fc8735e891f56852f687b32bbd044f272d2831137e3eeba61fd1f285fa73dcc97d9f2be3cd1", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getSeedBytes()));
|
||||
|
||||
wallet = electrum.importWallet(new ByteArrayInputStream(baos.toByteArray()), null);
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("59c5474f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub68YmVxWbxqjpxbUqqaPrgkBQPBSJuq6gEaL22uuytSEojtS2x5eLPN2uspUuyigtnMkoHrFSF1KwoXPwjzuaUjErUwztxfHquAwuaQhSd9J", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertEquals(wallet.getKeystores().get(0).getSeed().getMnemonicString().asString(), "coach fan denial rifle frost rival join install one wasp cool antique");
|
||||
Assert.assertEquals("e14c40c638e2c83d1f20e5ee9cd744bc2ba1ef64fa939926f3778fc8735e891f56852f687b32bbd044f272d2831137e3eeba61fd1f285fa73dcc97d9f2be3cd1", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getSeedBytes()));
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("59c5474f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub68YmVxWbxqjpxbUqqaPrgkBQPBSJuq6gEaL22uuytSEojtS2x5eLPN2uspUuyigtnMkoHrFSF1KwoXPwjzuaUjErUwztxfHquAwuaQhSd9J", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals(wallet.getKeystores().get(0).getSeed().getMnemonicString().asString(), "coach fan denial rifle frost rival join install one wasp cool antique");
|
||||
Assertions.assertEquals("e14c40c638e2c83d1f20e5ee9cd744bc2ba1ef64fa939926f3778fc8735e891f56852f687b32bbd044f272d2831137e3eeba61fd1f285fa73dcc97d9f2be3cd1", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getSeedBytes()));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
Network.set(null);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.sparrowwallet.sparrow.io;
|
|||
import com.sparrowwallet.drongo.ExtendedKey;
|
||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class KeystoneSinglesigTest extends IoTest {
|
||||
@Test
|
||||
|
@ -12,22 +12,16 @@ public class KeystoneSinglesigTest extends IoTest {
|
|||
KeystoneSinglesig keystoneSingleSig = new KeystoneSinglesig();
|
||||
Keystore keystore = keystoneSingleSig.getKeystore(ScriptType.P2WPKH, getInputStream("keystone-singlesig-keystore-1.txt"), null);
|
||||
|
||||
Assert.assertEquals("Keystone", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("5271c071", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rcabYFcdr41zyUNRWRyHYs2Sm86E5XV8RjjRzTFYsiCngteeZnkwaF2xuhjmM6kpHjuNpFW42BMhzPmFwXt48e1FhddMB7xidZzN4SF24K"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Keystone", keystore.getLabel());
|
||||
Assertions.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("5271c071", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("zpub6rcabYFcdr41zyUNRWRyHYs2Sm86E5XV8RjjRzTFYsiCngteeZnkwaF2xuhjmM6kpHjuNpFW42BMhzPmFwXt48e1FhddMB7xidZzN4SF24K"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
}
|
||||
|
||||
@Test(expected = ImportException.class)
|
||||
@Test
|
||||
public void testIncorrectScriptType() throws ImportException {
|
||||
KeystoneSinglesig keystoneSingleSig = new KeystoneSinglesig();
|
||||
Keystore keystore = keystoneSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("keystone-singlesig-keystore-1.txt"), null);
|
||||
|
||||
Assert.assertEquals("Keystone", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("5271c071", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rcabYFcdr41zyUNRWRyHYs2Sm86E5XV8RjjRzTFYsiCngteeZnkwaF2xuhjmM6kpHjuNpFW42BMhzPmFwXt48e1FhddMB7xidZzN4SF24K"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertThrows(ImportException.class, () -> keystoneSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("keystone-singlesig-keystore-1.txt"), null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.sparrowwallet.drongo.OutputDescriptor;
|
|||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -20,11 +20,11 @@ public class SpecterDIYTest extends IoTest {
|
|||
SpecterDIY specterDIY = new SpecterDIY();
|
||||
Keystore keystore = specterDIY.getKeystore(ScriptType.P2WPKH, getInputStream("specter-diy-keystore.txt"), null);
|
||||
|
||||
Assert.assertEquals("Specter DIY", keystore.getLabel());
|
||||
Assert.assertEquals("m/84'/1'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("b317ec86", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals(ExtendedKey.fromDescriptor("vpub5YHLPnkkpPW1ecL7Di7Gv2wDHDtBNqRdt17gMULpxJ27ZA1MmW7xbZjdg1S7d5JKaJ8CiZEmRUHrEB6CGuLomA6ioVa1Pcke6fEb5CzDBU1"), keystore.getExtendedPublicKey());
|
||||
Assert.assertTrue(keystore.isValid());
|
||||
Assertions.assertEquals("Specter DIY", keystore.getLabel());
|
||||
Assertions.assertEquals("m/84'/1'/0'", keystore.getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("b317ec86", keystore.getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals(ExtendedKey.fromDescriptor("vpub5YHLPnkkpPW1ecL7Di7Gv2wDHDtBNqRdt17gMULpxJ27ZA1MmW7xbZjdg1S7d5JKaJ8CiZEmRUHrEB6CGuLomA6ioVa1Pcke6fEb5CzDBU1"), keystore.getExtendedPublicKey());
|
||||
Assertions.assertTrue(keystore.isValid());
|
||||
Network.set(Network.MAINNET);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,6 @@ public class SpecterDIYTest extends IoTest {
|
|||
String original = new String(walletBytes);
|
||||
String exported = new String(baos.toByteArray());
|
||||
|
||||
Assert.assertEquals(original, exported);
|
||||
Assertions.assertEquals(original, exported);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.sparrowwallet.sparrow.io;
|
|||
import com.sparrowwallet.drongo.policy.PolicyType;
|
||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -14,14 +14,14 @@ public class SpecterDesktopTest extends IoTest {
|
|||
SpecterDesktop specterDesktop = new SpecterDesktop();
|
||||
Wallet wallet = specterDesktop.importWallet(getInputStream("specter-wallet.json"), null);
|
||||
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("sh(wpkh(keystore1))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("4df18faa", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6BgwyseZdeGJj2vB3FPHSGPxR1LLkr8AsAJqedrgjwBXKXXVWkH31fhwtQXgrM7uMrWjLwXhuDhhenNAh5eBdUSjrHkrKfaXutcJdAfgQ8D", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("sh(wpkh(keystore1))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("4df18faa", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6BgwyseZdeGJj2vB3FPHSGPxR1LLkr8AsAJqedrgjwBXKXXVWkH31fhwtQXgrM7uMrWjLwXhuDhhenNAh5eBdUSjrHkrKfaXutcJdAfgQ8D", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -29,13 +29,13 @@ public class SpecterDesktopTest extends IoTest {
|
|||
SpecterDesktop specterDesktop = new SpecterDesktop();
|
||||
Wallet wallet = specterDesktop.importWallet(getInputStream("specter-multisig-wallet.json"), null);
|
||||
|
||||
Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assert.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("wsh(sortedmulti(3,keystore1,keystore2,keystore3,keystore4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assert.assertEquals("ca9a2b19", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6EhbRDNhmMX863W8RujJyAMw1vtM4MHXnsk14paK1ZBEH75k44gWqfaraXCrzg6w9pzC2yLc28vAdUfpB9ShuEB1HA9xMs6BjmRi4PKbt1K", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertEquals(PolicyType.MULTI, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WSH, wallet.getScriptType());
|
||||
Assertions.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("wsh(sortedmulti(3,keystore1,keystore2,keystore3,keystore4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT));
|
||||
Assertions.assertEquals("ca9a2b19", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6EhbRDNhmMX863W8RujJyAMw1vtM4MHXnsk14paK1ZBEH75k44gWqfaraXCrzg6w9pzC2yLc28vAdUfpB9ShuEB1HA9xMs6BjmRi4PKbt1K", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.sparrowwallet.drongo.protocol.ScriptType;
|
|||
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||
import com.sparrowwallet.drongo.wallet.MnemonicException;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class StorageTest extends IoTest {
|
|||
public void loadWallet() throws IOException, MnemonicException, StorageException {
|
||||
Storage storage = new Storage(getFile("sparrow-single-wallet"));
|
||||
Wallet wallet = storage.loadEncryptedWallet("pass").getWallet();
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -40,19 +40,19 @@ public class StorageTest extends IoTest {
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
|
||||
Assert.assertEquals("testd2", wallet.getName());
|
||||
Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assert.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assert.assertEquals("pkh(60bcd3a7)", wallet.getDefaultPolicy().getMiniscript().getScript());
|
||||
Assert.assertEquals("60bcd3a7", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assert.assertEquals("m/84'/0'/3'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assert.assertEquals("xpub6BrhGFTWPd3DXo8s2BPxHHzCmBCyj8QvamcEUaq8EDwnwXpvvcU9LzpJqENHcqHkqwTn2vPhynGVoEqj3PAB3NxnYZrvCsSfoCniJKaggdy", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assert.assertEquals("af6ebd81714c301c3a71fe11a7a9c99ccef4b33d4b36582220767bfa92768a2aa040f88b015b2465f8075a8b9dbf892a7d6e6c49932109f2cbc05ba0bd7f355fbcc34c237f71be5fb4dd7f8184e44cb0", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getEncryptedData().getEncryptedBytes()));
|
||||
Assert.assertNull(wallet.getKeystores().get(0).getSeed().getMnemonicCode());
|
||||
Assert.assertEquals("bc1q2mkrttcuzryrdyn9vtu3nfnt3jlngwn476ktus", wallet.getFreshNode(KeyPurpose.RECEIVE).getAddress().toString());
|
||||
Assertions.assertEquals("testd2", wallet.getName());
|
||||
Assertions.assertEquals(PolicyType.SINGLE, wallet.getPolicyType());
|
||||
Assertions.assertEquals(ScriptType.P2WPKH, wallet.getScriptType());
|
||||
Assertions.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired());
|
||||
Assertions.assertEquals("pkh(60bcd3a7)", wallet.getDefaultPolicy().getMiniscript().getScript());
|
||||
Assertions.assertEquals("60bcd3a7", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint());
|
||||
Assertions.assertEquals("m/84'/0'/3'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath());
|
||||
Assertions.assertEquals("xpub6BrhGFTWPd3DXo8s2BPxHHzCmBCyj8QvamcEUaq8EDwnwXpvvcU9LzpJqENHcqHkqwTn2vPhynGVoEqj3PAB3NxnYZrvCsSfoCniJKaggdy", wallet.getKeystores().get(0).getExtendedPublicKey().toString());
|
||||
Assertions.assertEquals("af6ebd81714c301c3a71fe11a7a9c99ccef4b33d4b36582220767bfa92768a2aa040f88b015b2465f8075a8b9dbf892a7d6e6c49932109f2cbc05ba0bd7f355fbcc34c237f71be5fb4dd7f8184e44cb0", Utils.bytesToHex(wallet.getKeystores().get(0).getSeed().getEncryptedData().getEncryptedBytes()));
|
||||
Assertions.assertNull(wallet.getKeystores().get(0).getSeed().getMnemonicCode());
|
||||
Assertions.assertEquals("bc1q2mkrttcuzryrdyn9vtu3nfnt3jlngwn476ktus", wallet.getFreshNode(KeyPurpose.RECEIVE).getAddress().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -66,7 +66,7 @@ public class StorageTest extends IoTest {
|
|||
public void saveWallet() throws IOException, MnemonicException, StorageException {
|
||||
Storage storage = new Storage(getFile("sparrow-single-wallet"));
|
||||
Wallet wallet = storage.loadEncryptedWallet("pass").getWallet();
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
|
||||
File tempWallet = File.createTempFile("sparrow", "tmp");
|
||||
tempWallet.deleteOnExit();
|
||||
|
@ -78,6 +78,6 @@ public class StorageTest extends IoTest {
|
|||
|
||||
Storage temp2Storage = new Storage(tempWallet);
|
||||
wallet = temp2Storage.loadEncryptedWallet("pass").getWallet();
|
||||
Assert.assertTrue(wallet.isValid());
|
||||
Assertions.assertTrue(wallet.isValid());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue