MCPcopy Create free account
hub / github.com/chain/txvm / TestBlockPrev

Function TestBlockPrev

protocol/validation/validation_test.go:205–289  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func TestBlockPrev(t *testing.T) {
206 prev := &bc.BlockHeader{
207 Version: 3,
208 Height: 10,
209 TimestampMs: 1000,
210 RefsCount: 5,
211 NextPredicate: &bc.Predicate{},
212 }
213 prevHash := prev.Hash()
214
215 cases := []struct {
216 current *bc.BlockHeader
217 wantErr error
218 }{{
219 current: &bc.BlockHeader{
220 Version: 3,
221 Height: 11,
222 TimestampMs: 2000,
223 RefsCount: 6,
224 PreviousBlockId: &prevHash,
225 },
226 wantErr: nil,
227 }, {
228 current: &bc.BlockHeader{
229 Version: 2, // bad version
230 Height: 11,
231 TimestampMs: 2000,
232 RefsCount: 6,
233 PreviousBlockId: &prevHash,
234 },
235 wantErr: errVersionRegression,
236 }, {
237 current: &bc.BlockHeader{
238 Version: 3,
239 Height: 12,
240 TimestampMs: 2000,
241 RefsCount: 6,
242 PreviousBlockId: &prevHash,
243 },
244 wantErr: errMisorderedBlockHeight,
245 }, {
246 current: &bc.BlockHeader{
247 Version: 3,
248 Height: 11,
249 TimestampMs: 2000,
250 RefsCount: 6,
251 PreviousBlockId: &bc.Hash{},
252 },
253 wantErr: errMismatchedBlock,
254 }, {
255 current: &bc.BlockHeader{
256 Version: 3,
257 Height: 11,
258 TimestampMs: 1000,
259 RefsCount: 6,
260 PreviousBlockId: &prevHash,
261 },
262 wantErr: errMisorderedBlockTime,

Callers

nothing calls this directly

Calls 3

HashMethod · 0.95
RootFunction · 0.92
BlockPrevFunction · 0.85

Tested by

no test coverage detected