Tests that given a starting canonical chain of a given size, it can be extended with various length chains.
(t *testing.T)
| 172 | // Tests that given a starting canonical chain of a given size, it can be extended |
| 173 | // with various length chains. |
| 174 | func TestExtendCanonicalBlocks(t *testing.T) { |
| 175 | length := 5 |
| 176 | |
| 177 | db := database.NewMemDatabase() |
| 178 | processor, err := newCanonical(fakeDpor(db), length, db) |
| 179 | // Make first chain starting from genesis |
| 180 | if err != nil { |
| 181 | t.Fatalf("failed to make new canonical chain: %v", err) |
| 182 | } |
| 183 | defer processor.Stop() |
| 184 | |
| 185 | // Define the difficulty comparator |
| 186 | better := func(td1, td2 *big.Int) { |
| 187 | if td2.Cmp(td1) <= 0 { |
| 188 | t.Errorf("total difficulty mismatch: have %v, expected more than %v", td2, td1) |
| 189 | } |
| 190 | } |
| 191 | // Start fork from current height |
| 192 | testFork(t, processor, length, 1, better) |
| 193 | testFork(t, processor, length, 2, better) |
| 194 | testFork(t, processor, length, 5, better) |
| 195 | testFork(t, processor, length, 10, better) |
| 196 | } |
| 197 | |
| 198 | // Tests that given a starting canonical chain of a given size, creating shorter |
| 199 | // forks do not take canonical ownership. |
nothing calls this directly
no test coverage detected