mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 23:03:04 +00:00
WalletTest: Heterogeneous is hard to spel corectly :) Also it's probably unfamiliar to non native speakers. Replace it with the simpler word "mixed".
This commit is contained in:
parent
4273dacc00
commit
89079fd8d4
@ -24,9 +24,7 @@ import com.google.bitcoin.crypto.KeyCrypterScrypt;
|
|||||||
import com.google.bitcoin.store.BlockStore;
|
import com.google.bitcoin.store.BlockStore;
|
||||||
import com.google.bitcoin.store.MemoryBlockStore;
|
import com.google.bitcoin.store.MemoryBlockStore;
|
||||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||||
import com.google.bitcoin.utils.Locks;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.util.concurrent.CycleDetectingLockFactory;
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
import org.bitcoinj.wallet.Protos;
|
import org.bitcoinj.wallet.Protos;
|
||||||
@ -70,7 +68,7 @@ public class WalletTest {
|
|||||||
private Wallet wallet;
|
private Wallet wallet;
|
||||||
private Wallet encryptedWallet;
|
private Wallet encryptedWallet;
|
||||||
// A wallet with an initial unencrypted private key and an encrypted private key.
|
// A wallet with an initial unencrypted private key and an encrypted private key.
|
||||||
private Wallet encryptedHetergeneousWallet;
|
private Wallet encryptedMixedWallet;
|
||||||
|
|
||||||
private BlockChain chain;
|
private BlockChain chain;
|
||||||
private BlockStore blockStore;
|
private BlockStore blockStore;
|
||||||
@ -107,7 +105,7 @@ public class WalletTest {
|
|||||||
|
|
||||||
wallet = new Wallet(params);
|
wallet = new Wallet(params);
|
||||||
encryptedWallet = new Wallet(params, keyCrypter);
|
encryptedWallet = new Wallet(params, keyCrypter);
|
||||||
encryptedHetergeneousWallet = new Wallet(params, keyCrypter);
|
encryptedMixedWallet = new Wallet(params, keyCrypter);
|
||||||
|
|
||||||
aesKey = keyCrypter.deriveKey(PASSWORD1);
|
aesKey = keyCrypter.deriveKey(PASSWORD1);
|
||||||
wrongAesKey = keyCrypter.deriveKey(WRONG_PASSWORD);
|
wrongAesKey = keyCrypter.deriveKey(WRONG_PASSWORD);
|
||||||
@ -117,8 +115,8 @@ public class WalletTest {
|
|||||||
myEncryptedKey = encryptedWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
myEncryptedKey = encryptedWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
||||||
myEncryptedAddress = myEncryptedKey.toAddress(params);
|
myEncryptedAddress = myEncryptedKey.toAddress(params);
|
||||||
|
|
||||||
encryptedHetergeneousWallet.addKey(myKey2);
|
encryptedMixedWallet.addKey(myKey2);
|
||||||
myEncryptedKey2 = encryptedHetergeneousWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
myEncryptedKey2 = encryptedMixedWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
||||||
myEncryptedAddress2 = myEncryptedKey2.toAddress(params);
|
myEncryptedAddress2 = myEncryptedKey2.toAddress(params);
|
||||||
|
|
||||||
blockStore = new MemoryBlockStore(params);
|
blockStore = new MemoryBlockStore(params);
|
||||||
@ -167,24 +165,21 @@ public class WalletTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void basicSpendingWithEncryptedHetergeneousWallet() throws Exception {
|
public void basicSpendingWithEncryptedMixedWallet() throws Exception {
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
encryptedHetergeneousWallet = new Wallet(params, keyCrypter);
|
encryptedMixedWallet = new Wallet(params, keyCrypter);
|
||||||
myKey2 = new ECKey();
|
myKey2 = new ECKey();
|
||||||
encryptedHetergeneousWallet.addKey(myKey2);
|
encryptedMixedWallet.addKey(myKey2);
|
||||||
myEncryptedKey2 = encryptedHetergeneousWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
myEncryptedKey2 = encryptedMixedWallet.addNewEncryptedKey(keyCrypter, aesKey);
|
||||||
myEncryptedAddress2 = myEncryptedKey2.toAddress(params);
|
myEncryptedAddress2 = myEncryptedKey2.toAddress(params);
|
||||||
basicSpendingCommon(encryptedHetergeneousWallet, myEncryptedAddress2, true);
|
basicSpendingCommon(encryptedMixedWallet, myEncryptedAddress2, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void basicSpendingCommon(Wallet wallet, Address toAddress, boolean testEncryption) throws Exception {
|
private void basicSpendingCommon(Wallet wallet, Address toAddress, boolean testEncryption) throws Exception {
|
||||||
// We'll set up a wallet that receives a coin, then sends a coin of
|
// We'll set up a wallet that receives a coin, then sends a coin of lesser value and keeps the change. We
|
||||||
// lesser value and keeps the change. We
|
// will attach a small fee. Because the Bitcoin protocol makes it difficult to determine the fee of an
|
||||||
// will attach a small fee. Because the Bitcoin protocol makes it
|
// arbitrary transaction in isolation, we'll check that the fee was set by examining the size of the change.
|
||||||
// difficult to determine the fee of an
|
|
||||||
// arbitrary transaction in isolation, we'll check that the fee was set
|
|
||||||
// by examining the size of the change.
|
|
||||||
|
|
||||||
// Receive some money as a pending transaction.
|
// Receive some money as a pending transaction.
|
||||||
receiveAPendingTransaction(wallet, toAddress);
|
receiveAPendingTransaction(wallet, toAddress);
|
||||||
@ -242,8 +237,7 @@ public class WalletTest {
|
|||||||
// Broadcast the transaction and commit.
|
// Broadcast the transaction and commit.
|
||||||
broadcastAndCommit(wallet, t2);
|
broadcastAndCommit(wallet, t2);
|
||||||
|
|
||||||
// Now check that we can spend the unconfirmed change, with a new change
|
// Now check that we can spend the unconfirmed change, with a new change address of our own selection.
|
||||||
// address of our own selection.
|
|
||||||
// (req.aesKey is null for unencrypted / the correct aesKey for encrypted.)
|
// (req.aesKey is null for unencrypted / the correct aesKey for encrypted.)
|
||||||
spendUnconfirmedChange(wallet, t2, req.aesKey);
|
spendUnconfirmedChange(wallet, t2, req.aesKey);
|
||||||
}
|
}
|
||||||
@ -1087,7 +1081,7 @@ public class WalletTest {
|
|||||||
@Test
|
@Test
|
||||||
public void encryptionDecryptionBasic() throws Exception {
|
public void encryptionDecryptionBasic() throws Exception {
|
||||||
encryptionDecryptionBasicCommon(encryptedWallet);
|
encryptionDecryptionBasicCommon(encryptedWallet);
|
||||||
encryptionDecryptionBasicCommon(encryptedHetergeneousWallet);
|
encryptionDecryptionBasicCommon(encryptedMixedWallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void encryptionDecryptionBasicCommon(Wallet wallet) {
|
private void encryptionDecryptionBasicCommon(Wallet wallet) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user