forked from cerc-io/ipld-eth-server
Update GetStorageValueMetadata
This commit is contained in:
parent
51915f7506
commit
d30b4ea4f2
@ -30,17 +30,27 @@ const (
|
||||
type Key string
|
||||
|
||||
type StorageValueMetadata struct {
|
||||
Name string
|
||||
Keys map[Key]string
|
||||
Type ValueType
|
||||
Name string
|
||||
Keys map[Key]string
|
||||
Type ValueType
|
||||
PackedNames map[int]string //name of each item packed and their order
|
||||
PackedTypes map[int]ValueType //type of each item packed and their order
|
||||
PackedNames map[int]string //name of each item packed and their order
|
||||
}
|
||||
|
||||
func GetStorageValueMetadata(name string, keys map[Key]string, t ValueType) StorageValueMetadata {
|
||||
func GetStorageValueMetadata(name string, keys map[Key]string, valueType ValueType) StorageValueMetadata {
|
||||
return getMetadata(name, keys, valueType, nil, nil)
|
||||
}
|
||||
|
||||
func GetStorageValueMetadataForPackedSlot(name string, keys map[Key]string, valueType ValueType, packedNames map[int]string, packedTypes map[int]ValueType) StorageValueMetadata {
|
||||
return getMetadata(name, keys, valueType, packedNames, packedTypes)
|
||||
}
|
||||
|
||||
func getMetadata(name string, keys map[Key]string, t ValueType, packedNames map[int]string, packedTypes map[int]ValueType) StorageValueMetadata {
|
||||
return StorageValueMetadata{
|
||||
Name: name,
|
||||
Keys: keys,
|
||||
Type: t,
|
||||
Name: name,
|
||||
Keys: keys,
|
||||
Type: t,
|
||||
PackedNames: packedNames,
|
||||
PackedTypes: packedTypes,
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Storage value metadata getter", func() {
|
||||
It("returns a storage value metadata instance with corresponding fields assigned", func() {
|
||||
It("returns storage value metadata for a single storage variable", func() {
|
||||
metadataName := "fake_name"
|
||||
metadataKeys := map[utils.Key]string{"key": "value"}
|
||||
metadataType := utils.Uint256
|
||||
@ -19,4 +19,21 @@ var _ = Describe("Storage value metadata getter", func() {
|
||||
}
|
||||
Expect(utils.GetStorageValueMetadata(metadataName, metadataKeys, metadataType)).To(Equal(expectedMetadata))
|
||||
})
|
||||
|
||||
It("returns metadata for a packed storage slot variables", func() {
|
||||
metadataName := "fake_name"
|
||||
metadataKeys := map[utils.Key]string{"key": "value"}
|
||||
metadataType := utils.Uint256
|
||||
metadataPackedNames := map[int]string{0: "name"}
|
||||
metadataPackedTypes := map[int]utils.ValueType{0: utils.Uint48}
|
||||
|
||||
expectedMetadata := utils.StorageValueMetadata{
|
||||
Name: metadataName,
|
||||
Keys: metadataKeys,
|
||||
Type: metadataType,
|
||||
PackedTypes: metadataPackedTypes,
|
||||
PackedNames: metadataPackedNames,
|
||||
}
|
||||
Expect(utils.GetStorageValueMetadataForPackedSlot(metadataName, metadataKeys, metadataType, metadataPackedNames, metadataPackedTypes)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user