@@ -5,9 +5,31 @@ import (
5
5
. "github.com/onsi/ginkgo"
6
6
. "github.com/onsi/gomega"
7
7
"github.com/vulcanize/vulcanizedb/libraries/shared/storage"
8
+ "github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
8
9
)
9
10
10
11
var _ = Describe ("Mappings" , func () {
12
+ Describe ("AddHashedKeys" , func () {
13
+ It ("returns a copy of the map with an additional slot for the hashed version of every key" , func () {
14
+ fakeMap := map [common.Hash ]utils.StorageValueMetadata {}
15
+ fakeStorageKey := common .HexToHash ("72c72de6b203d67cb6cd54fc93300109fcc6fd6eac88e390271a3d548794d800" )
16
+ var fakeMappingKey utils.Key = "fakeKey"
17
+ fakeMetadata := utils.StorageValueMetadata {
18
+ Name : "fakeName" ,
19
+ Keys : map [utils.Key ]string {fakeMappingKey : "fakeValue" },
20
+ Type : utils .Uint48 ,
21
+ }
22
+ fakeMap [fakeStorageKey ] = fakeMetadata
23
+
24
+ result := storage .AddHashedKeys (fakeMap )
25
+
26
+ Expect (len (result )).To (Equal (2 ))
27
+ expectedHashedStorageKey := common .HexToHash ("2165edb4e1c37b99b60fa510d84f939dd35d5cd1d1c8f299d6456ea09df65a76" )
28
+ Expect (fakeMap [fakeStorageKey ]).To (Equal (fakeMetadata ))
29
+ Expect (fakeMap [expectedHashedStorageKey ]).To (Equal (fakeMetadata ))
30
+ })
31
+ })
32
+
11
33
Describe ("GetMapping" , func () {
12
34
It ("returns the storage key for a mapping when passed the mapping's index on the contract and the desired value's key" , func () {
13
35
// ex. solidity:
0 commit comments