-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer accepting orphan block headers
- Loading branch information
1 parent
be97085
commit 1306558
Showing
3 changed files
with
41 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package co.rsk.bitcoinj.core; | ||
|
||
import co.rsk.bitcoinj.store.BtcBlockStore; | ||
import co.rsk.bitcoinj.store.BtcMemoryBlockStore; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static co.rsk.bitcoinj.core.TransactionOutputTest.PARAMS; | ||
import static co.rsk.bitcoinj.core.Utils.HEX; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
public class BtcBlockChainTest { | ||
|
||
BtcAbstractBlockChain blockchain; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
final BtcBlockStore blockStore = new BtcMemoryBlockStore(PARAMS); | ||
blockchain = new BtcBlockChain(new Context(PARAMS), blockStore); | ||
} | ||
|
||
@Test | ||
public void orphanBlockNotStored() { | ||
BtcBlock block = new BtcBlock( | ||
PARAMS, 2l, Sha256Hash.of(HEX.decode("0011")), | ||
Sha256Hash.ZERO_HASH, PARAMS.genesisBlock.getTime().getTime() + 1, PARAMS.genesisBlock.getDifficultyTarget(), | ||
0, new ArrayList<BtcTransaction>()); | ||
assertFalse(blockchain.add(block.cloneAsHeader())); | ||
} | ||
|
||
} |