Skip to content

Commit

Permalink
fix tests with derivation paths matching other networks
Browse files Browse the repository at this point in the history
  • Loading branch information
craigraw committed Mar 7, 2024
1 parent e43b783 commit f0bd07b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion drongo
Submodule drongo updated 1 files
+1 −0 build.gradle
8 changes: 8 additions & 0 deletions src/test/java/com/sparrowwallet/sparrow/io/StorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;

Expand All @@ -15,6 +16,7 @@
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());
Expand Down Expand Up @@ -64,6 +66,7 @@ public void multipleLoadTest() throws IOException, MnemonicException, StorageExc

@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());
Expand All @@ -80,4 +83,9 @@ public void saveWallet() throws IOException, MnemonicException, StorageException
wallet = temp2Storage.loadEncryptedWallet("pass").getWallet();
Assertions.assertTrue(wallet.isValid());
}

@AfterEach
void tearDown() {
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, "false");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0bd07b

Please sign in to comment.