MCPcopy Create free account
hub / github.com/CPChain/chain / TestBrokenBlockChain

Function TestBrokenBlockChain

core/blockchain_test.go:283–298  ·  view source on GitHub ↗

Tests that chains missing links do not get accepted by the processor.

(t *testing.T)

Source from the content-addressed store, hash-verified

281
282// Tests that chains missing links do not get accepted by the processor.
283func TestBrokenBlockChain(t *testing.T) {
284 t.Skip("===TestBrokenBlockChain broken block chain not reported")
285 db := database.NewMemDatabase()
286 blockchain, err := newCanonical(fakeDpor(db), 10, db)
287 // Make chain starting from genesis
288 if err != nil {
289 t.Fatalf("failed to make new canonical chain: %v", err)
290 }
291 defer blockchain.Stop()
292
293 // Create a forked chain, and try to insert with a missing link
294 chain := makeBlockChain(blockchain.CurrentBlock(), 5, fakeDpor(db), db, forkSeed)[1:]
295 if err := testBlockChainImport(chain, blockchain); err == nil {
296 t.Errorf("broken block chain not reported")
297 }
298}
299
300// Tests that reorganising a long difficult chain after a short easy one
301// overwrites the canonical numbers and links in the database.

Callers

nothing calls this directly

Calls 6

newCanonicalFunction · 0.85
fakeDporFunction · 0.85
makeBlockChainFunction · 0.85
testBlockChainImportFunction · 0.85
StopMethod · 0.65
CurrentBlockMethod · 0.65

Tested by

no test coverage detected