mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 11:36:15 +01:00
Merge 938cb1dae6
into 1090649211
This commit is contained in:
commit
cc6b45fb6a
1 changed files with 70 additions and 0 deletions
70
core/src/test/java/org/bitcoinj/wallet/WalletsTest.java
Normal file
70
core/src/test/java/org/bitcoinj/wallet/WalletsTest.java
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
package org.bitcoinj.wallet;
|
||||||
|
|
||||||
|
import org.bitcoinj.base.Address;
|
||||||
|
import org.bitcoinj.base.Coin;
|
||||||
|
import org.bitcoinj.base.ScriptType;
|
||||||
|
import org.bitcoinj.core.Block;
|
||||||
|
import org.bitcoinj.core.Transaction;
|
||||||
|
import org.bitcoinj.testing.TestWithWallet;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
import static org.bitcoinj.base.Coin.valueOf;
|
||||||
|
import static org.bitcoinj.testing.FakeTxBuilder.*;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class WalletsTest extends TestWithWallet {
|
||||||
|
|
||||||
|
protected Wallet wallet2;
|
||||||
|
protected Address myAddress2;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
@Override
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
|
||||||
|
wallet2 = Wallet.createDeterministic(TESTNET, ScriptType.P2PKH, KeyChainGroupStructure.BIP32);
|
||||||
|
myAddress2 = wallet2.freshReceiveAddress(ScriptType.P2PKH);
|
||||||
|
chain.addWallet(wallet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sharedTransactionCorrectDepth() throws Exception {
|
||||||
|
|
||||||
|
// ARRANGE //
|
||||||
|
Coin v1 = valueOf(5, 0);
|
||||||
|
Coin v2 = valueOf(0, 50);
|
||||||
|
Coin v3 = valueOf(0, 25);
|
||||||
|
|
||||||
|
Transaction t1 = createFakeTxWithChangeAddress(TESTNET, v1, myAddress, myAddress2);
|
||||||
|
Transaction t2 = createFakeTxWithChangeAddress(TESTNET, v2, myAddress, myAddress2);
|
||||||
|
Transaction t3 = createFakeTxWithChangeAddress(TESTNET, v3, myAddress, myAddress2);
|
||||||
|
|
||||||
|
Block genesis = blockStore.getChainHead().getHeader();
|
||||||
|
Block b1 = makeSolvedTestBlock(genesis, t1);
|
||||||
|
Block b2 = makeSolvedTestBlock(b1, t2);
|
||||||
|
Block b3 = makeSolvedTestBlock(b2, t3);
|
||||||
|
|
||||||
|
// ACT //
|
||||||
|
chain.add(b1);
|
||||||
|
chain.add(b2);
|
||||||
|
chain.add(b3);
|
||||||
|
|
||||||
|
// ASSERT //
|
||||||
|
Transaction tx1 = wallet.getTransaction(t1.getTxId());
|
||||||
|
Transaction tx2 = wallet.getTransaction(t2.getTxId());
|
||||||
|
Transaction tx3 = wallet.getTransaction(t3.getTxId());
|
||||||
|
|
||||||
|
assertEquals(3, tx1.getConfidence().getDepthInBlocks());
|
||||||
|
assertEquals(2, tx2.getConfidence().getDepthInBlocks());
|
||||||
|
assertEquals(1, tx3.getConfidence().getDepthInBlocks());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue