forked from cerc-io/ipld-eth-server
Get transactions (#45)
* Make transactions requests in parallel * Update transaction error handling
This commit is contained in:
@@ -4,9 +4,15 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
}
|
||||
|
||||
func TestHistory(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "History Suite")
|
||||
|
||||
@@ -18,7 +18,11 @@ func PopulateMissingBlocks(blockchain core.Blockchain, blockRepository datastore
|
||||
|
||||
func RetrieveAndUpdateBlocks(blockchain core.Blockchain, blockRepository datastore.BlockRepository, blockNumbers []int64) int {
|
||||
for _, blockNumber := range blockNumbers {
|
||||
block := blockchain.GetBlockByNumber(blockNumber)
|
||||
block, err := blockchain.GetBlockByNumber(blockNumber)
|
||||
if err != nil {
|
||||
log.Printf("failed to retrieve block number: %d\n", blockNumber)
|
||||
return 0
|
||||
}
|
||||
blockRepository.CreateOrUpdateBlock(block)
|
||||
}
|
||||
return len(blockNumbers)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package history_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@@ -100,4 +102,12 @@ var _ = Describe("Populating blocks", func() {
|
||||
Expect(blockRepository.CreateOrUpdateBlockCallCount).To(Equal(3))
|
||||
})
|
||||
|
||||
It("does not call repository create block when there is an error", func() {
|
||||
blockchain := fakes.NewBlockchain(errors.New("error getting block"))
|
||||
blocks := history.MakeRange(1, 10)
|
||||
history.RetrieveAndUpdateBlocks(blockchain, blockRepository, blocks)
|
||||
Expect(blockRepository.BlockCount()).To(Equal(0))
|
||||
Expect(blockRepository.CreateOrUpdateBlockCallCount).To(Equal(0))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -3,9 +3,6 @@ package history_test
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@@ -14,10 +11,6 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/history"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
}
|
||||
|
||||
var _ = Describe("Blocks validator", func() {
|
||||
|
||||
It("creates a ValidationWindow equal to (HEAD-windowSize, HEAD)", func() {
|
||||
|
||||
Reference in New Issue
Block a user