forked from cerc-io/ipld-eth-server
goimports -w; comments; refactor test
This commit is contained in:
parent
2a98a30ee9
commit
a59bd06a37
@ -17,19 +17,19 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/statediff"
|
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"plugin"
|
"plugin"
|
||||||
syn "sync"
|
syn "sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
||||||
|
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
||||||
p2 "github.com/vulcanize/vulcanizedb/pkg/plugin"
|
p2 "github.com/vulcanize/vulcanizedb/pkg/plugin"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/plugin/helpers"
|
"github.com/vulcanize/vulcanizedb/pkg/plugin/helpers"
|
||||||
"github.com/vulcanize/vulcanizedb/utils"
|
"github.com/vulcanize/vulcanizedb/utils"
|
||||||
|
@ -18,13 +18,13 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
st "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
st "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||||
ft "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/full/transformer"
|
ft "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/full/transformer"
|
||||||
ht "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/header/transformer"
|
ht "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/header/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/utils"
|
"github.com/vulcanize/vulcanizedb/utils"
|
||||||
|
@ -18,21 +18,21 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ethereum/go-ethereum/statediff"
|
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
|
||||||
"plugin"
|
"plugin"
|
||||||
syn "sync"
|
syn "sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
||||||
|
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
||||||
storageUtils "github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
storageUtils "github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
||||||
|
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
||||||
"github.com/vulcanize/vulcanizedb/utils"
|
"github.com/vulcanize/vulcanizedb/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,10 +19,11 @@ package chunker_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFactories(t *testing.T) {
|
func TestFactories(t *testing.T) {
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package chunker
|
package chunker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Chunker interface {
|
type Chunker interface {
|
||||||
|
@ -19,10 +19,11 @@ package event_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFactories(t *testing.T) {
|
func TestFactories(t *testing.T) {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package event_test
|
package event_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
|
||||||
@ -25,7 +27,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"math/rand"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Transformer", func() {
|
var _ = Describe("Transformer", func() {
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package fetcher
|
package fetcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
"github.com/vulcanize/vulcanizedb/pkg/fs"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CsvTailStorageFetcher struct {
|
type CsvTailStorageFetcher struct {
|
||||||
|
@ -18,6 +18,9 @@ package fetcher_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/hpcloud/tail"
|
"github.com/hpcloud/tail"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@ -25,8 +28,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Csv Tail Storage Fetcher", func() {
|
var _ = Describe("Csv Tail Storage Fetcher", func() {
|
||||||
|
@ -19,10 +19,11 @@ package fetcher_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFactories(t *testing.T) {
|
func TestFactories(t *testing.T) {
|
||||||
|
@ -18,6 +18,7 @@ package logs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/chunker"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/chunker"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package logs_test
|
package logs_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@ -27,7 +29,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Log delegator", func() {
|
var _ = Describe("Log delegator", func() {
|
||||||
|
@ -18,6 +18,7 @@ package logs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package logs_test
|
package logs_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@ -27,7 +29,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"math/rand"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Log extractor", func() {
|
var _ = Describe("Log extractor", func() {
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package logs_test
|
package logs_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
@ -19,10 +19,11 @@ package repository_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFactories(t *testing.T) {
|
func TestFactories(t *testing.T) {
|
||||||
|
@ -31,18 +31,22 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IBackFiller is the backfilling interface
|
||||||
type IBackFiller interface {
|
type IBackFiller interface {
|
||||||
BackFill(bfa BackFillerArgs) (map[common.Hash][]utils.StorageDiff, error)
|
BackFill(bfa BackFillerArgs) (map[common.Hash][]utils.StorageDiff, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BatchClient is an interface to a batch-fetching geth rpc client; created to allow mock insertion
|
||||||
type BatchClient interface {
|
type BatchClient interface {
|
||||||
BatchCall(batch []client.BatchElem) error
|
BatchCall(batch []client.BatchElem) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BackFiller is the backfilling struct
|
||||||
type BackFiller struct {
|
type BackFiller struct {
|
||||||
client BatchClient
|
client BatchClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BackFillerArgs are used to pass configuration params to the backfiller
|
||||||
type BackFillerArgs struct {
|
type BackFillerArgs struct {
|
||||||
// mapping of hashed addresses to a list of the storage key hashes we want to collect at that address
|
// mapping of hashed addresses to a list of the storage key hashes we want to collect at that address
|
||||||
WantedStorage map[common.Hash][]common.Hash
|
WantedStorage map[common.Hash][]common.Hash
|
||||||
@ -52,6 +56,7 @@ type BackFillerArgs struct {
|
|||||||
|
|
||||||
const method = "statediff_stateDiffAt"
|
const method = "statediff_stateDiffAt"
|
||||||
|
|
||||||
|
// NewStorageBackFiller returns a IBackFiller
|
||||||
func NewStorageBackFiller(bc BatchClient) IBackFiller {
|
func NewStorageBackFiller(bc BatchClient) IBackFiller {
|
||||||
return &BackFiller{
|
return &BackFiller{
|
||||||
client: bc,
|
client: bc,
|
||||||
|
@ -33,12 +33,12 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockClient struct {
|
type mockClient struct {
|
||||||
MappedStateDiffAt map[uint64][]byte
|
MappedStateDiffAt map[uint64][]byte
|
||||||
MappedErrors map[uint64]error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MockClient) SetReturnDiffAt(height uint64, diffPayload statediff.Payload) error {
|
// SetReturnDiffAt method to set what statediffs the mock client returns
|
||||||
|
func (mc *mockClient) SetReturnDiffAt(height uint64, diffPayload statediff.Payload) error {
|
||||||
if mc.MappedStateDiffAt == nil {
|
if mc.MappedStateDiffAt == nil {
|
||||||
mc.MappedStateDiffAt = make(map[uint64][]byte)
|
mc.MappedStateDiffAt = make(map[uint64][]byte)
|
||||||
}
|
}
|
||||||
@ -50,15 +50,9 @@ func (mc *MockClient) SetReturnDiffAt(height uint64, diffPayload statediff.Paylo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MockClient) SetReturnErrorAt(height uint64, err error) {
|
// BatchCall mockClient method to simulate batch call to geth
|
||||||
if mc.MappedErrors == nil {
|
func (mc *mockClient) BatchCall(batch []client.BatchElem) error {
|
||||||
mc.MappedErrors = make(map[uint64]error)
|
if mc.MappedStateDiffAt == nil {
|
||||||
}
|
|
||||||
mc.MappedErrors[height] = err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mc *MockClient) BatchCall(batch []client.BatchElem) error {
|
|
||||||
if mc.MappedStateDiffAt == nil || mc.MappedErrors == nil {
|
|
||||||
return errors.New("mockclient needs to be initialized with statediff payloads and errors")
|
return errors.New("mockclient needs to be initialized with statediff payloads and errors")
|
||||||
}
|
}
|
||||||
for _, batchElem := range batch {
|
for _, batchElem := range batch {
|
||||||
@ -73,22 +67,25 @@ func (mc *MockClient) BatchCall(batch []client.BatchElem) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
batchElem.Error = mc.MappedErrors[blockHeight]
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("BackFiller", func() {
|
var _ = Describe("BackFiller", func() {
|
||||||
Describe("BackFill", func() {
|
Describe("BackFill", func() {
|
||||||
It("Batch calls statediff_stateDiffAt", func() {
|
var (
|
||||||
mc := new(MockClient)
|
mc *mockClient
|
||||||
|
backFiller storage.IBackFiller
|
||||||
|
)
|
||||||
|
BeforeEach(func() {
|
||||||
|
mc = new(mockClient)
|
||||||
setDiffAtErr1 := mc.SetReturnDiffAt(test_data.BlockNumber.Uint64(), test_data.MockStatediffPayload)
|
setDiffAtErr1 := mc.SetReturnDiffAt(test_data.BlockNumber.Uint64(), test_data.MockStatediffPayload)
|
||||||
Expect(setDiffAtErr1).ToNot(HaveOccurred())
|
Expect(setDiffAtErr1).ToNot(HaveOccurred())
|
||||||
setDiffAtErr2 := mc.SetReturnDiffAt(test_data.BlockNumber2.Uint64(), test_data.MockStatediffPayload2)
|
setDiffAtErr2 := mc.SetReturnDiffAt(test_data.BlockNumber2.Uint64(), test_data.MockStatediffPayload2)
|
||||||
Expect(setDiffAtErr2).ToNot(HaveOccurred())
|
Expect(setDiffAtErr2).ToNot(HaveOccurred())
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber.Uint64(), nil)
|
backFiller = storage.NewStorageBackFiller(mc)
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber2.Uint64(), nil)
|
})
|
||||||
backFiller := storage.NewStorageBackFiller(mc)
|
It("Batch calls statediff_stateDiffAt", func() {
|
||||||
backFillArgs := storage.BackFillerArgs{
|
backFillArgs := storage.BackFillerArgs{
|
||||||
WantedStorage: map[common.Hash][]common.Hash{
|
WantedStorage: map[common.Hash][]common.Hash{
|
||||||
test_data.ContractLeafKey: {common.BytesToHash(test_data.StorageKey)},
|
test_data.ContractLeafKey: {common.BytesToHash(test_data.StorageKey)},
|
||||||
@ -127,14 +124,6 @@ var _ = Describe("BackFiller", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("Only returns storage for provided addresses (address hashes)", func() {
|
It("Only returns storage for provided addresses (address hashes)", func() {
|
||||||
mc := new(MockClient)
|
|
||||||
setDiffAtErr1 := mc.SetReturnDiffAt(test_data.BlockNumber.Uint64(), test_data.MockStatediffPayload)
|
|
||||||
Expect(setDiffAtErr1).ToNot(HaveOccurred())
|
|
||||||
setDiffAtErr2 := mc.SetReturnDiffAt(test_data.BlockNumber2.Uint64(), test_data.MockStatediffPayload2)
|
|
||||||
Expect(setDiffAtErr2).ToNot(HaveOccurred())
|
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber.Uint64(), nil)
|
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber2.Uint64(), nil)
|
|
||||||
backFiller := storage.NewStorageBackFiller(mc)
|
|
||||||
backFillArgs := storage.BackFillerArgs{
|
backFillArgs := storage.BackFillerArgs{
|
||||||
WantedStorage: map[common.Hash][]common.Hash{
|
WantedStorage: map[common.Hash][]common.Hash{
|
||||||
test_data.ContractLeafKey: {common.BytesToHash(test_data.StorageKey)},
|
test_data.ContractLeafKey: {common.BytesToHash(test_data.StorageKey)},
|
||||||
@ -151,14 +140,6 @@ var _ = Describe("BackFiller", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("Only returns storage for provided storage keys", func() {
|
It("Only returns storage for provided storage keys", func() {
|
||||||
mc := new(MockClient)
|
|
||||||
setDiffAtErr1 := mc.SetReturnDiffAt(test_data.BlockNumber.Uint64(), test_data.MockStatediffPayload)
|
|
||||||
Expect(setDiffAtErr1).ToNot(HaveOccurred())
|
|
||||||
setDiffAtErr2 := mc.SetReturnDiffAt(test_data.BlockNumber2.Uint64(), test_data.MockStatediffPayload2)
|
|
||||||
Expect(setDiffAtErr2).ToNot(HaveOccurred())
|
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber.Uint64(), nil)
|
|
||||||
mc.SetReturnErrorAt(test_data.BlockNumber2.Uint64(), nil)
|
|
||||||
backFiller := storage.NewStorageBackFiller(mc)
|
|
||||||
backFillArgs := storage.BackFillerArgs{
|
backFillArgs := storage.BackFillerArgs{
|
||||||
WantedStorage: map[common.Hash][]common.Hash{
|
WantedStorage: map[common.Hash][]common.Hash{
|
||||||
test_data.ContractLeafKey: nil,
|
test_data.ContractLeafKey: nil,
|
||||||
|
@ -19,10 +19,11 @@ package storage_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFactories(t *testing.T) {
|
func TestFactories(t *testing.T) {
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
package utils_test
|
package utils_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/statediff"
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
@ -25,8 +28,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/test_data"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/test_data"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"math/big"
|
|
||||||
"math/rand"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Storage row parsing", func() {
|
var _ = Describe("Storage row parsing", func() {
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package utils_test
|
package utils_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
package test_data
|
package test_data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"math/rand"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var startingBlockNumber = rand.Int63()
|
var startingBlockNumber = rand.Int63()
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package watcher
|
package watcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/chunker"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/chunker"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
||||||
@ -27,7 +29,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const NoNewDataPause = time.Second * 7
|
const NoNewDataPause = time.Second * 7
|
||||||
|
@ -18,6 +18,7 @@ package watcher_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
||||||
|
@ -18,6 +18,8 @@ package watcher
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
||||||
@ -25,7 +27,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/storage/utils"
|
||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IStorageWatcher interface {
|
type IStorageWatcher interface {
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
package watcher_test
|
package watcher_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -27,9 +31,6 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"github.com/vulcanize/vulcanizedb/test_config"
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Storage Watcher", func() {
|
var _ = Describe("Storage Watcher", func() {
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package watcher_test
|
package watcher_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user