ipld-eth-server/integration_test/geth_blockchain_test.go
Matt K 6decf0b54b 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)
2018-01-05 11:55:00 -06:00

60 lines
1.6 KiB
Go

package integration_test
import (
"io/ioutil"
"log"
"github.com/8thlight/vulcanizedb/pkg/config"
"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"
)
func init() {
log.SetOutput(ioutil.Discard)
}
var _ = Describe("Reading from the Geth blockchain", func() {
var blockchain *geth.Blockchain
var repository *repositories.InMemory
BeforeEach(func() {
cfg, _ := config.NewConfig("private")
blockchain = geth.NewBlockchain(cfg.Client.IPCPath)
repository = repositories.NewInMemory()
})
It("reads two blocks", func(done Done) {
validator := history.NewBlockValidator(blockchain, repository, 2)
validator.ValidateBlocks()
Expect(repository.BlockCount()).To(Equal(2))
close(done)
}, 15)
It("retrieves the genesis block and first block", func(done Done) {
genesisBlock := blockchain.GetBlockByNumber(int64(0))
firstBlock := blockchain.GetBlockByNumber(int64(1))
lastBlockNumber := blockchain.LastBlock()
Expect(genesisBlock.Number).To(Equal(int64(0)))
Expect(firstBlock.Number).To(Equal(int64(1)))
Expect(lastBlockNumber.Int64()).To(BeNumerically(">", 0))
close(done)
}, 15)
It("retrieves the node info", func(done Done) {
node := blockchain.Node()
devNetworkGenesisBlock := "0xe5be92145a301820111f91866566e3e99ee344d155569e4556a39bc71238f3bc"
devNetworkNodeId := float64(1)
Expect(node.GenesisBlock).To(Equal(devNetworkGenesisBlock))
Expect(node.NetworkId).To(Equal(devNetworkNodeId))
close(done)
}, 15)
})