MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestSignAndVerify

Function TestSignAndVerify

types/block_test.go:33–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestSignAndVerify(t *testing.T) {
34 block, err := CreateRandomBlock(genesisHash, false)
35
36 if err != nil {
37 t.Fatalf("error occurred: %v", err)
38 }
39
40 if err = block.Verify(); err != nil {
41 t.Fatalf("error occurred: %v", err)
42 }
43
44 block.SignedHeader.HSV.DataHash[0]++
45
46 if err = errors.Cause(block.Verify()); err != verifier.ErrHashValueNotMatch {
47 t.Fatalf("unexpected error: %v", err)
48 }
49
50 block.Acks = append(block.Acks, &SignedAckHeader{
51 DefaultHashSignVerifierImpl: verifier.DefaultHashSignVerifierImpl{
52 DataHash: hash.Hash{0x01},
53 },
54 })
55
56 if err = block.Verify(); err != ErrMerkleRootVerification {
57 t.Fatalf("unexpected error: %v", err)
58 }
59}
60
61func TestHeaderMarshalUnmarshaler(t *testing.T) {
62 block, err := CreateRandomBlock(genesisHash, false)

Callers

nothing calls this directly

Calls 3

CreateRandomBlockFunction · 0.85
FatalfMethod · 0.80
VerifyMethod · 0.65

Tested by

no test coverage detected