From f0bd07b4b7fd86459e1412bb90cfeb16360ef7d4 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 7 Mar 2024 08:13:48 +0200 Subject: [PATCH] fix tests with derivation paths matching other networks --- build.gradle | 2 +- drongo | 2 +- .../java/com/sparrowwallet/sparrow/io/StorageTest.java | 8 ++++++++ .../com/sparrowwallet/sparrow/io/cc-multisig-export-1.txt | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b8b0de83..10fcfb71 100644 --- a/build.gradle +++ b/build.gradle @@ -160,7 +160,7 @@ processResources { test { useJUnitPlatform() - jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED' + jvmArgs = ["--add-opens=java.base/java.io=ALL-UNNAMED", "--add-opens=java.base/java.io=com.google.gson"] } application { diff --git a/drongo b/drongo index 6868b026..987aadd4 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 6868b026fbc1c5093bbad7db32b14e00c78717f2 +Subproject commit 987aadd4a60aa65650ebec6bb23eed40c0031b22 diff --git a/src/test/java/com/sparrowwallet/sparrow/io/StorageTest.java b/src/test/java/com/sparrowwallet/sparrow/io/StorageTest.java index 97101c5c..4b6ef525 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/StorageTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/StorageTest.java @@ -7,6 +7,7 @@ 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.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -15,6 +16,7 @@ import java.io.*; public class StorageTest extends IoTest { @Test public void loadWallet() throws IOException, MnemonicException, StorageException { + System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, "true"); Storage storage = new Storage(getFile("sparrow-single-wallet")); Wallet wallet = storage.loadEncryptedWallet("pass").getWallet(); Assertions.assertTrue(wallet.isValid()); @@ -64,6 +66,7 @@ public class StorageTest extends IoTest { @Test public void saveWallet() throws IOException, MnemonicException, StorageException { + System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, "true"); Storage storage = new Storage(getFile("sparrow-single-wallet")); Wallet wallet = storage.loadEncryptedWallet("pass").getWallet(); Assertions.assertTrue(wallet.isValid()); @@ -80,4 +83,9 @@ public class StorageTest extends IoTest { wallet = temp2Storage.loadEncryptedWallet("pass").getWallet(); Assertions.assertTrue(wallet.isValid()); } + + @AfterEach + void tearDown() { + System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, "false"); + } } diff --git a/src/test/resources/com/sparrowwallet/sparrow/io/cc-multisig-export-1.txt b/src/test/resources/com/sparrowwallet/sparrow/io/cc-multisig-export-1.txt index 6868af5f..06dc0999 100644 --- a/src/test/resources/com/sparrowwallet/sparrow/io/cc-multisig-export-1.txt +++ b/src/test/resources/com/sparrowwallet/sparrow/io/cc-multisig-export-1.txt @@ -2,7 +2,7 @@ # Name: CC-2-of-4 Policy: 2 of 4 -Derivation: m/48'/1'/0'/2' +Derivation: m/48'/0'/0'/2' Format: P2WSH 0F056943: xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z