2019-02-25 04:26:42 +00:00
|
|
|
package storage_test
|
2019-02-19 21:01:07 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
2019-02-25 04:26:42 +00:00
|
|
|
|
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage"
|
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
2019-02-19 21:01:07 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/test_config"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Storage queue", func() {
|
|
|
|
It("adds a storage row to the db", func() {
|
2019-02-25 04:26:42 +00:00
|
|
|
row := utils.StorageDiffRow{
|
2019-02-19 21:01:07 +00:00
|
|
|
Contract: common.HexToAddress("0x123456"),
|
|
|
|
BlockHash: common.HexToHash("0x678901"),
|
|
|
|
BlockHeight: 987,
|
|
|
|
StorageKey: common.HexToHash("0x654321"),
|
|
|
|
StorageValue: common.HexToHash("0x198765"),
|
|
|
|
}
|
|
|
|
db := test_config.NewTestDB(test_config.NewTestNode())
|
2019-02-25 04:26:42 +00:00
|
|
|
queue := storage.NewStorageQueue(db)
|
2019-02-19 21:01:07 +00:00
|
|
|
|
|
|
|
addErr := queue.Add(row)
|
|
|
|
|
|
|
|
Expect(addErr).NotTo(HaveOccurred())
|
2019-02-25 04:26:42 +00:00
|
|
|
var result utils.StorageDiffRow
|
2019-02-19 21:01:07 +00:00
|
|
|
getErr := db.Get(&result, `SELECT contract, block_hash, block_height, storage_key, storage_value FROM public.queued_storage`)
|
|
|
|
Expect(getErr).NotTo(HaveOccurred())
|
|
|
|
Expect(result).To(Equal(row))
|
|
|
|
})
|
|
|
|
})
|