mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-16 04:05:50 +00:00
Fix hdw unit tests after I broke them.
This commit is contained in:
parent
c98badcf1c
commit
d2232ed4aa
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.bitcoin.crypto.hd;
|
package com.google.bitcoin.crypto;
|
||||||
|
|
||||||
import com.google.bitcoin.core.AddressFormatException;
|
import com.google.bitcoin.core.AddressFormatException;
|
||||||
import com.google.bitcoin.core.Base58;
|
import com.google.bitcoin.core.Base58;
|
@ -14,11 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.bitcoin.crypto.hd;
|
package com.google.bitcoin.crypto;
|
||||||
|
|
||||||
import com.google.bitcoin.crypto.DeterministicKey;
|
|
||||||
import com.google.bitcoin.crypto.HDKeyDerivation;
|
|
||||||
import com.google.bitcoin.crypto.HDUtils;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.google.bitcoin.crypto.hd;
|
package com.google.bitcoin.crypto;
|
||||||
|
|
||||||
import com.google.bitcoin.crypto.HDUtils;
|
import com.google.bitcoin.crypto.HDUtils;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2013 Matija Mazi.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.bitcoin.crypto.hd;
|
|
||||||
|
|
||||||
import com.google.bitcoin.crypto.DeterministicKey;
|
|
||||||
import com.google.bitcoin.crypto.HDKeyDerivation;
|
|
||||||
import com.google.bitcoin.crypto.hd.wallet.DeterministicKeyGenerator;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class DeterministicHierarchyTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test creating a sequence of derived keys using the internal and external chain.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testHierarchy() throws Exception {
|
|
||||||
DeterministicKey m = HDKeyDerivation.createMasterPrivateKey(new SecureRandom().generateSeed(32));
|
|
||||||
|
|
||||||
for (int iWallet = 0; iWallet < 3; iWallet++) {
|
|
||||||
DeterministicKey walletRootKey = HDKeyDerivation.deriveChildKey(m, iWallet);
|
|
||||||
DeterministicKeyGenerator hdWalletKeyGen = new DeterministicKeyGenerator(walletRootKey);
|
|
||||||
assertEquals(walletRootKey.getChildNumber().getChildNumber(), iWallet);
|
|
||||||
|
|
||||||
assertEquals(0L, hdWalletKeyGen.nextInternal().getChildNumber().getChildNumber());
|
|
||||||
assertEquals(1L, hdWalletKeyGen.nextInternal().getChildNumber().getChildNumber());
|
|
||||||
assertEquals(2L, hdWalletKeyGen.nextInternal().getChildNumber().getChildNumber());
|
|
||||||
|
|
||||||
assertEquals(0L, hdWalletKeyGen.nextExternal().getChildNumber().getChildNumber());
|
|
||||||
assertEquals(1L, hdWalletKeyGen.nextExternal().getChildNumber().getChildNumber());
|
|
||||||
assertEquals(2L, hdWalletKeyGen.nextExternal().getChildNumber().getChildNumber());
|
|
||||||
|
|
||||||
assertEquals(3L, hdWalletKeyGen.nextInternal().getChildNumber().getChildNumber());
|
|
||||||
|
|
||||||
assertEquals(3L, hdWalletKeyGen.nextExternal().getChildNumber().getChildNumber());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user