fix tests with derivation paths matching other networks

This commit is contained in:
Craig Raw 2024-03-07 08:13:48 +02:00
parent e43b783664
commit f0bd07b4b7
4 changed files with 11 additions and 3 deletions

View file

@ -160,7 +160,7 @@ processResources {
test { test {
useJUnitPlatform() 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 { application {

2
drongo

@ -1 +1 @@
Subproject commit 6868b026fbc1c5093bbad7db32b14e00c78717f2 Subproject commit 987aadd4a60aa65650ebec6bb23eed40c0031b22

View file

@ -7,6 +7,7 @@ import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.MnemonicException; import com.sparrowwallet.drongo.wallet.MnemonicException;
import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.drongo.wallet.Wallet;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -15,6 +16,7 @@ import java.io.*;
public class StorageTest extends IoTest { public class StorageTest extends IoTest {
@Test @Test
public void loadWallet() throws IOException, MnemonicException, StorageException { 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")); Storage storage = new Storage(getFile("sparrow-single-wallet"));
Wallet wallet = storage.loadEncryptedWallet("pass").getWallet(); Wallet wallet = storage.loadEncryptedWallet("pass").getWallet();
Assertions.assertTrue(wallet.isValid()); Assertions.assertTrue(wallet.isValid());
@ -64,6 +66,7 @@ public class StorageTest extends IoTest {
@Test @Test
public void saveWallet() throws IOException, MnemonicException, StorageException { 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")); Storage storage = new Storage(getFile("sparrow-single-wallet"));
Wallet wallet = storage.loadEncryptedWallet("pass").getWallet(); Wallet wallet = storage.loadEncryptedWallet("pass").getWallet();
Assertions.assertTrue(wallet.isValid()); Assertions.assertTrue(wallet.isValid());
@ -80,4 +83,9 @@ public class StorageTest extends IoTest {
wallet = temp2Storage.loadEncryptedWallet("pass").getWallet(); wallet = temp2Storage.loadEncryptedWallet("pass").getWallet();
Assertions.assertTrue(wallet.isValid()); Assertions.assertTrue(wallet.isValid());
} }
@AfterEach
void tearDown() {
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, "false");
}
} }

View file

@ -2,7 +2,7 @@
# #
Name: CC-2-of-4 Name: CC-2-of-4
Policy: 2 of 4 Policy: 2 of 4
Derivation: m/48'/1'/0'/2' Derivation: m/48'/0'/0'/2'
Format: P2WSH Format: P2WSH
0F056943: xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z 0F056943: xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z