ipld-eth-server/pkg/eth/ipld_fetcher_test.go

67 lines
2.3 KiB
Go
Raw Normal View History

2019-08-23 21:34:54 +00:00
// VulcanizeDB
// Copyright © 2019 Vulcanize
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package eth_test
2019-08-23 21:34:54 +00:00
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/ipld-eth-server/pkg/eth/mocks"
2019-08-23 21:34:54 +00:00
2020-09-02 15:19:25 +00:00
eth2 "github.com/vulcanize/ipld-eth-indexer/pkg/eth"
"github.com/vulcanize/ipld-eth-indexer/pkg/postgres"
2020-08-31 15:47:06 +00:00
"github.com/vulcanize/ipld-eth-server/pkg/eth"
"github.com/vulcanize/ipld-eth-server/pkg/shared"
2019-08-23 21:34:54 +00:00
)
var (
db *postgres.DB
2020-08-31 15:47:06 +00:00
pubAndIndexer *eth2.IPLDPublisher
fetcher *eth.IPLDFetcher
2019-08-23 21:34:54 +00:00
)
var _ = Describe("IPLDFetcher", func() {
Describe("Fetch", func() {
2019-08-23 21:34:54 +00:00
BeforeEach(func() {
var err error
db, err = shared.SetupDB()
Expect(err).ToNot(HaveOccurred())
2020-08-31 15:47:06 +00:00
pubAndIndexer = eth2.NewIPLDPublisher(db)
2020-10-20 15:48:35 +00:00
err = pubAndIndexer.Publish(mocks.MockConvertedPayload)
2019-08-23 21:34:54 +00:00
Expect(err).ToNot(HaveOccurred())
fetcher = eth.NewIPLDFetcher(db)
})
AfterEach(func() {
eth.TearDownDB(db)
2019-08-23 21:34:54 +00:00
})
It("Fetches and returns IPLDs for the CIDs provided in the CIDWrapper", func() {
2020-08-31 15:47:06 +00:00
iplds, err := fetcher.Fetch(*mocks.MockCIDWrapper)
2019-08-23 21:34:54 +00:00
Expect(err).ToNot(HaveOccurred())
2020-08-31 15:47:06 +00:00
Expect(iplds).ToNot(BeNil())
2020-10-20 15:48:35 +00:00
Expect(iplds.TotalDifficulty).To(Equal(mocks.MockConvertedPayload.TotalDifficulty))
Expect(iplds.BlockNumber).To(Equal(mocks.MockConvertedPayload.Block.Number()))
Expect(iplds.Header).To(Equal(mocks.MockIPLDs.Header))
Expect(len(iplds.Uncles)).To(Equal(0))
Expect(iplds.Transactions).To(Equal(mocks.MockIPLDs.Transactions))
Expect(iplds.Receipts).To(Equal(mocks.MockIPLDs.Receipts))
Expect(iplds.StateNodes).To(Equal(mocks.MockIPLDs.StateNodes))
Expect(iplds.StorageNodes).To(Equal(mocks.MockIPLDs.StorageNodes))
2019-08-23 21:34:54 +00:00
})
})
})