3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 19:25:51 +00:00

Fix hdw unit tests after I broke them.

This commit is contained in:
Mike Hearn 2013-07-11 14:19:48 +02:00
parent c98badcf1c
commit d2232ed4aa
4 changed files with 3 additions and 61 deletions

View File

@ -14,7 +14,7 @@
* 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.Base58;

View File

@ -14,11 +14,8 @@
* 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.spongycastle.util.encoders.Hex;

View File

@ -1,4 +1,4 @@
package com.google.bitcoin.crypto.hd;
package com.google.bitcoin.crypto;
import com.google.bitcoin.crypto.HDUtils;
import org.junit.Assert;

View File

@ -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());
}
}
}