2019-10-04 18:54:37 +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 fetcher_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
2019-10-24 16:35:39 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/fetcher"
|
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/mocks"
|
2019-10-04 18:54:37 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/test_data"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("StateDiffFetcher", func() {
|
|
|
|
Describe("FetchStateDiffsAt", func() {
|
|
|
|
var (
|
2019-10-24 16:35:39 +00:00
|
|
|
mc *mocks.BackFillerClient
|
|
|
|
stateDiffFetcher fetcher.StateDiffFetcher
|
2019-10-04 18:54:37 +00:00
|
|
|
)
|
|
|
|
BeforeEach(func() {
|
2019-10-24 16:35:39 +00:00
|
|
|
mc = new(mocks.BackFillerClient)
|
2019-10-04 18:54:37 +00:00
|
|
|
setDiffAtErr1 := mc.SetReturnDiffAt(test_data.BlockNumber.Uint64(), test_data.MockStatediffPayload)
|
|
|
|
Expect(setDiffAtErr1).ToNot(HaveOccurred())
|
|
|
|
setDiffAtErr2 := mc.SetReturnDiffAt(test_data.BlockNumber2.Uint64(), test_data.MockStatediffPayload2)
|
|
|
|
Expect(setDiffAtErr2).ToNot(HaveOccurred())
|
|
|
|
stateDiffFetcher = fetcher.NewStateDiffFetcher(mc)
|
|
|
|
})
|
|
|
|
It("Batch calls statediff_stateDiffAt", func() {
|
|
|
|
blockHeights := []uint64{
|
|
|
|
test_data.BlockNumber.Uint64(),
|
|
|
|
test_data.BlockNumber2.Uint64(),
|
|
|
|
}
|
|
|
|
stateDiffPayloads, fetchErr := stateDiffFetcher.FetchStateDiffsAt(blockHeights)
|
|
|
|
Expect(fetchErr).ToNot(HaveOccurred())
|
|
|
|
Expect(len(stateDiffPayloads)).To(Equal(2))
|
2019-11-01 05:29:57 +00:00
|
|
|
Expect(stateDiffPayloads[0]).To(Equal(test_data.MockStatediffPayload))
|
|
|
|
Expect(stateDiffPayloads[1]).To(Equal(test_data.MockStatediffPayload2))
|
2019-10-04 18:54:37 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|