Get transactions (#45)

* Make transactions requests in parallel

* Update transaction error handling
This commit is contained in:
Matt K
2018-03-27 16:06:12 -05:00
committed by GitHub
parent 88210e436a
commit 8a9395819c
38 changed files with 2303 additions and 64 deletions
+6
View File
@@ -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")
+5 -1
View File
@@ -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)
+10
View File
@@ -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))
})
})
-7
View File
@@ -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() {