3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 02:35:52 +00:00

WalletTest: Add test for roundtripping a wallet via its mnemonic code.

This commit is contained in:
Andreas Schildbach 2019-02-19 13:06:36 +01:00
parent 246fc5ae55
commit 883ea24483

View File

@ -3699,4 +3699,16 @@ public class WalletTest extends TestWithWallet {
assertNull(wallet.findKeyFromAddress(LegacyAddress.fromKey(UNITTEST, p2wpkhKey)));
assertEquals(p2wpkhKey, wallet.findKeyFromAddress(SegwitAddress.fromKey(UNITTEST, p2wpkhKey)));
}
@Test
public void roundtripViaMnemonicCode() {
Wallet wallet = Wallet.createDeterministic(UNITTEST, Script.ScriptType.P2WPKH);
List<String> mnemonicCode = wallet.getKeyChainSeed().getMnemonicCode();
final DeterministicSeed clonedSeed = new DeterministicSeed(mnemonicCode, null, "",
wallet.getEarliestKeyCreationTime());
Wallet clone = Wallet.fromSeed(UNITTEST, clonedSeed, Script.ScriptType.P2WPKH);
assertEquals(wallet.currentReceiveKey(), clone.currentReceiveKey());
assertEquals(wallet.freshReceiveAddress(Script.ScriptType.P2PKH),
clone.freshReceiveAddress(Script.ScriptType.P2PKH));
}
}