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

Function TestLastBlock

core/blockchain_test.go:155–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func TestLastBlock(t *testing.T) {
156 db := database.NewMemDatabase()
157 blockchain, err := newCanonical(fakeDpor(db), 0, db)
158 if err != nil {
159 t.Fatalf("failed to create pristine chain: %v", err)
160 }
161 defer blockchain.Stop()
162
163 blocks := makeBlockChain(blockchain.CurrentBlock(), 1, fakeDpor(db), blockchain.db, 0)
164 if _, err := blockchain.InsertChain(blocks); err != nil {
165 t.Fatalf("Failed to insert block: %v", err)
166 }
167 if blocks[len(blocks)-1].Hash() != rawdb.ReadHeadBlockHash(blockchain.db) {
168 t.Fatalf("Write/Get HeadBlockHash failed")
169 }
170}
171
172// Tests that given a starting canonical chain of a given size, it can be extended
173// with various length chains.

Callers

nothing calls this directly

Calls 7

newCanonicalFunction · 0.85
fakeDporFunction · 0.85
makeBlockChainFunction · 0.85
StopMethod · 0.65
CurrentBlockMethod · 0.65
InsertChainMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected