mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
test shorter fork (fails)
This commit is contained in:
parent
8cf9ed0ea5
commit
918f152e1f
1 changed files with 26 additions and 0 deletions
|
|
@ -40,6 +40,32 @@ func makechain(cman *ChainManager, max int) *BlockChain {
|
||||||
return NewChain(blocks)
|
return NewChain(blocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShorterFork(t *testing.T) {
|
||||||
|
cman := NewChainManager()
|
||||||
|
cman.SetProcessor(fakeproc{})
|
||||||
|
|
||||||
|
TD = big.NewInt(1)
|
||||||
|
chainA := makechain(cman, 5)
|
||||||
|
|
||||||
|
TD = big.NewInt(1)
|
||||||
|
chainB := makechain(cman, 3)
|
||||||
|
|
||||||
|
td, err := cman.TestChain(chainA)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("unable to create new TD from chainA:", err)
|
||||||
|
}
|
||||||
|
cman.TD = td
|
||||||
|
|
||||||
|
td2, err := cman.TestChain(chainB)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("expected chainB not to give errors:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if td2.Cmp(td) >= 0 {
|
||||||
|
t.Error("expected chainB to have lower difficulty. Got", td2, "expected less than", td)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLongerFork(t *testing.T) {
|
func TestLongerFork(t *testing.T) {
|
||||||
cman := NewChainManager()
|
cman := NewChainManager()
|
||||||
cman.SetProcessor(fakeproc{})
|
cman.SetProcessor(fakeproc{})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue