forked from cerc-io/ipld-eth-server
Remove pubsub and replace w/ polling head of chain (#122)
* Rename geth package structs to not be prefaced with package name * No longer need to dump schema since Travis uses migrate * Rearrange history package * Removed double request for receipt from block rewards * Remove Listener + Observers and Replace w/ Polling Head * Potential Short term Issue w/ Infura (ignore these tests for now)
This commit is contained in:
@@ -4,11 +4,10 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/fakes"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/history"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -19,35 +18,19 @@ func init() {
|
||||
|
||||
var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
|
||||
var listener blockchain_listener.BlockchainListener
|
||||
var observer *fakes.BlockchainObserver
|
||||
var blockchain *geth.GethBlockchain
|
||||
var blockchain *geth.Blockchain
|
||||
var repository *repositories.InMemory
|
||||
|
||||
BeforeEach(func() {
|
||||
observer = fakes.NewFakeBlockchainObserver()
|
||||
cfg, _ := config.NewConfig("private")
|
||||
blockchain = geth.NewGethBlockchain(cfg.Client.IPCPath)
|
||||
observers := []core.BlockchainObserver{observer}
|
||||
listener = blockchain_listener.NewBlockchainListener(blockchain, observers)
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
listener.Stop()
|
||||
blockchain = geth.NewBlockchain(cfg.Client.IPCPath)
|
||||
repository = repositories.NewInMemory()
|
||||
})
|
||||
|
||||
It("reads two blocks", func(done Done) {
|
||||
go listener.Start()
|
||||
|
||||
<-observer.WasNotified
|
||||
firstBlock := observer.LastBlock()
|
||||
Expect(firstBlock).NotTo(BeNil())
|
||||
|
||||
<-observer.WasNotified
|
||||
secondBlock := observer.LastBlock()
|
||||
Expect(secondBlock).NotTo(BeNil())
|
||||
|
||||
Expect(firstBlock.Number + 1).Should(Equal(secondBlock.Number))
|
||||
|
||||
validator := history.NewBlockValidator(blockchain, repository, 2)
|
||||
validator.ValidateBlocks()
|
||||
Expect(repository.BlockCount()).To(Equal(2))
|
||||
close(done)
|
||||
}, 15)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user