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

lmittmann / w3 / 7496150241

12 Jan 2024 12:19AM UTC coverage: 77.601%. Remained the same
7496150241

Pull #99

github

web-flow
build(deps): bump github.com/ethereum/go-ethereum in /examples

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.13.8 to 1.13.10.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](https://github.com/ethereum/go-ethereum/compare/v1.13.8...v1.13.10)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #99: build(deps): bump github.com/ethereum/go-ethereum from 1.13.8 to 1.13.10 in /examples

1805 of 2326 relevant lines covered (77.6%)

1420.88 hits per line

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

65.0
/w3vm/db.go
1
package w3vm
2

3
import (
4
        "errors"
5
        "math/big"
6

7
        "github.com/ethereum/go-ethereum/common"
8
        gethState "github.com/ethereum/go-ethereum/core/state"
9
        "github.com/ethereum/go-ethereum/core/types"
10
        "github.com/ethereum/go-ethereum/ethdb"
11
        "github.com/ethereum/go-ethereum/trie"
12
        "github.com/ethereum/go-ethereum/trie/trienode"
13
        "github.com/lmittmann/w3/internal/crypto"
14
)
15

16
var errNotFound = errors.New("not found")
17

18
// db implements the [state.Database] and [state.Trie] interfaces.
19
type db struct {
20
        fetcher Fetcher
21
}
22

23
func newDB(fetcher Fetcher) *db {
50✔
24
        return &db{
50✔
25
                fetcher: fetcher,
50✔
26
        }
50✔
27
}
50✔
28

29
////////////////////////////////////////////////////////////////////////////////////////////////////
30
// state.Database methods //////////////////////////////////////////////////////////////////////////
31
////////////////////////////////////////////////////////////////////////////////////////////////////
32

33
func (db *db) OpenTrie(root common.Hash) (gethState.Trie, error) { return db, nil }
50✔
34

35
func (db *db) OpenStorageTrie(stateRoot common.Hash, addr common.Address, root common.Hash, trie gethState.Trie) (gethState.Trie, error) {
4,198✔
36
        return db, nil
4,198✔
37
}
4,198✔
38

39
func (*db) CopyTrie(gethState.Trie) gethState.Trie { panic("not implemented") }
×
40

41
func (db *db) ContractCode(addr common.Address, codeHash common.Hash) ([]byte, error) {
7,335✔
42
        if db.fetcher == nil {
7,335✔
43
                return []byte{}, nil
×
44
        }
×
45

46
        code, err := db.fetcher.Code(addr)
7,335✔
47
        if err != nil {
7,335✔
48
                return nil, errNotFound
×
49
        }
×
50
        return code, nil
7,335✔
51
}
52

53
func (db *db) ContractCodeSize(addr common.Address, codeHash common.Hash) (int, error) {
2,074✔
54
        code, err := db.ContractCode(addr, codeHash)
2,074✔
55
        if err != nil {
2,074✔
56
                return 0, err
×
57
        }
×
58
        return len(code), nil
2,074✔
59
}
60

61
func (*db) DiskDB() ethdb.KeyValueStore { panic("not implemented") }
×
62

63
func (*db) TrieDB() *trie.Database { panic("not implemented") }
×
64

65
////////////////////////////////////////////////////////////////////////////////////////////////////
66
// state.Trie methods //////////////////////////////////////////////////////////////////////////////
67
////////////////////////////////////////////////////////////////////////////////////////////////////
68

69
func (*db) GetKey([]byte) []byte { panic("not implemented") }
×
70

71
func (db *db) GetStorage(addr common.Address, key []byte) ([]byte, error) {
34,133✔
72
        if db.fetcher == nil {
34,138✔
73
                return []byte{}, nil
5✔
74
        }
5✔
75

76
        storageKey := common.BytesToHash(key)
34,128✔
77
        storageVal, err := db.fetcher.StorageAt(addr, storageKey)
34,128✔
78
        if err != nil {
34,128✔
79
                return nil, err
×
80
        }
×
81
        return storageVal.Bytes(), nil
34,128✔
82
}
83

84
func (db *db) GetAccount(addr common.Address) (*types.StateAccount, error) {
11,363✔
85
        if db.fetcher == nil {
11,381✔
86
                return &types.StateAccount{
18✔
87
                        Balance:  new(big.Int),
18✔
88
                        CodeHash: types.EmptyCodeHash[:],
18✔
89
                }, nil
18✔
90
        }
18✔
91

92
        nonce, err := db.fetcher.Nonce(addr)
11,345✔
93
        if err != nil {
11,349✔
94
                return nil, err
4✔
95
        }
4✔
96
        balance, err := db.fetcher.Balance(addr)
11,341✔
97
        if err != nil {
11,341✔
98
                return nil, err
×
99
        }
×
100
        code, err := db.fetcher.Code(addr)
11,341✔
101
        if err != nil {
11,341✔
102
                return nil, err
×
103
        }
×
104

105
        var codeHash []byte
11,341✔
106
        if len(code) == 0 {
17,416✔
107
                codeHash = types.EmptyCodeHash[:]
6,075✔
108
        } else {
11,341✔
109
                codeHash = crypto.Keccak256(code)
5,266✔
110
        }
5,266✔
111

112
        return &types.StateAccount{
11,341✔
113
                Nonce:    nonce,
11,341✔
114
                Balance:  balance,
11,341✔
115
                CodeHash: codeHash,
11,341✔
116
        }, nil
11,341✔
117
}
118

119
func (*db) UpdateStorage(addr common.Address, key, value []byte) error { panic("not implemented") }
×
120

121
func (*db) UpdateAccount(addr common.Address, acc *types.StateAccount) error {
×
122
        panic("not implemented")
×
123
}
124

125
func (*db) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error {
×
126
        panic("not implemented")
×
127
}
128

129
func (*db) DeleteStorage(addr common.Address, key []byte) error { panic("not implemented") }
×
130

131
func (*db) DeleteAccount(addr common.Address) error { panic("not implemented") }
×
132

133
func (*db) Hash() common.Hash { panic("not implemented") }
×
134

135
func (*db) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error) {
×
136
        panic("not implemented")
×
137
}
138

139
func (*db) NodeIterator(startKey []byte) (trie.NodeIterator, error) { panic("not implemented") }
×
140

141
func (*db) Prove(key []byte, proofDb ethdb.KeyValueWriter) error { panic("not implemented") }
×
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