• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 15249422085

26 May 2025 08:11AM UTC coverage: 57.977% (-11.0%) from 69.015%
15249422085

push

github

web-flow
Merge pull request #9853 from lightningnetwork/elle-graphSQL8-prep

graph/db: init SQLStore caches and batch schedulers

9 of 34 new or added lines in 4 files covered. (26.47%)

29283 existing lines in 458 files now uncovered.

96475 of 166402 relevant lines covered (57.98%)

1.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.67
/lntypes/hash.go
1
package lntypes
2

3
import (
4
        "encoding/hex"
5
        "fmt"
6
)
7

8
// HashSize of array used to store hashes.
9
const HashSize = 32
10

11
// ZeroHash is a predefined hash containing all zeroes.
12
var ZeroHash Hash
13

14
// Hash is used in several of the lightning messages and common structures. It
15
// typically represents a payment hash.
16
type Hash [HashSize]byte
17

18
// String returns the Hash as a hexadecimal string.
19
func (hash Hash) String() string {
2✔
20
        return hex.EncodeToString(hash[:])
2✔
21
}
2✔
22

23
// MakeHash returns a new Hash from a byte slice.  An error is returned if
24
// the number of bytes passed in is not HashSize.
25
func MakeHash(newHash []byte) (Hash, error) {
2✔
26
        nhlen := len(newHash)
2✔
27
        if nhlen != HashSize {
2✔
UNCOV
28
                return Hash{}, fmt.Errorf("invalid hash length of %v, want %v",
×
UNCOV
29
                        nhlen, HashSize)
×
UNCOV
30
        }
×
31

32
        var hash Hash
2✔
33
        copy(hash[:], newHash)
2✔
34

2✔
35
        return hash, nil
2✔
36
}
37

38
// MakeHashFromStr creates a Hash from a hex hash string.
UNCOV
39
func MakeHashFromStr(newHash string) (Hash, error) {
×
UNCOV
40
        // Return error if hash string is of incorrect length.
×
UNCOV
41
        if len(newHash) != HashSize*2 {
×
42
                return Hash{}, fmt.Errorf("invalid hash string length of %v, "+
×
43
                        "want %v", len(newHash), HashSize*2)
×
44
        }
×
45

UNCOV
46
        hash, err := hex.DecodeString(newHash)
×
UNCOV
47
        if err != nil {
×
48
                return Hash{}, err
×
49
        }
×
50

UNCOV
51
        return MakeHash(hash)
×
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc