integration test for vat flux
This commit is contained in:
parent
b38c29ce43
commit
21088eb3a2
59
pkg/transformers/integration_tests/vat_flux.go
Normal file
59
pkg/transformers/integration_tests/vat_flux.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2018 Vulcanize
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package integration_tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux"
|
||||||
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("VatFlux Transformer", func() {
|
||||||
|
It("transforms VatFlux log events", func() {
|
||||||
|
blockNumber := int64(9004474)
|
||||||
|
config := vat_flux.VatFluxConfig
|
||||||
|
config.StartingBlockNumber = blockNumber
|
||||||
|
config.EndingBlockNumber = blockNumber
|
||||||
|
|
||||||
|
rpcClient, ethClient, err := getClients(ipc)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
blockchain, err := getBlockChain(rpcClient, ethClient)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
db := test_config.NewTestDB(blockchain.Node())
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
|
||||||
|
err = persistHeader(rpcClient, db, blockNumber)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
initializer := vat_flux.VatFluxTransformerInitializer{Config: config}
|
||||||
|
transformer := initializer.NewVatFluxTransformer(db, blockchain)
|
||||||
|
err = transformer.Execute()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
var dbResult []vat_flux.VatFluxModel
|
||||||
|
err = db.Select(&dbResult, `SELECT ilk, src, dst, rad from maker.vat_flux`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(len(dbResult)).To(Equal(1))
|
||||||
|
Expect(dbResult[0].Ilk).To(Equal("REP"))
|
||||||
|
Expect(dbResult[0].Src).To(Equal("0xC0851F73CC8DD5c0765E71980eC7E7Fd1EF74434"))
|
||||||
|
Expect(dbResult[0].Dst).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||||
|
Expect(dbResult[0].Rad).To(Equal("1800000000000000000000000000000000000000000000"))
|
||||||
|
Expect(dbResult[0].TransactionIndex).To(Equal(uint(0)))
|
||||||
|
})
|
||||||
|
})
|
@ -28,7 +28,7 @@ var VatFluxLog = types.Log{
|
|||||||
Address: common.HexToAddress("0x239e6f0ab02713f1f8aa90ebeded9fc66dc96cd6"),
|
Address: common.HexToAddress("0x239e6f0ab02713f1f8aa90ebeded9fc66dc96cd6"),
|
||||||
Topics: []common.Hash{
|
Topics: []common.Hash{
|
||||||
common.HexToHash("0xa6e4182100000000000000000000000000000000000000000000000000000000"),
|
common.HexToHash("0xa6e4182100000000000000000000000000000000000000000000000000000000"),
|
||||||
common.HexToHash("0x0000000000000000000000007340e006f4135BA6970D43bf43d88DCAD4e7a8CA"),
|
common.HexToHash("0x5245500000000000000000000000000000000000000000000000000000000000"),
|
||||||
common.HexToHash("0x0000000000000000000000007FA9EF6609Ca7921112231f8f195138ebba29770"),
|
common.HexToHash("0x0000000000000000000000007FA9EF6609Ca7921112231f8f195138ebba29770"),
|
||||||
common.HexToHash("0x00000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf"),
|
common.HexToHash("0x00000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf"),
|
||||||
},
|
},
|
||||||
@ -43,7 +43,7 @@ var VatFluxLog = types.Log{
|
|||||||
|
|
||||||
var rawFluxLog, _ = json.Marshal(VatFluxLog)
|
var rawFluxLog, _ = json.Marshal(VatFluxLog)
|
||||||
var VatFluxModel = vat_flux.VatFluxModel{
|
var VatFluxModel = vat_flux.VatFluxModel{
|
||||||
Ilk: "0x7340e006f4135BA6970D43bf43d88DCAD4e7a8CA",
|
Ilk: "REP",
|
||||||
Src: "0x7FA9EF6609Ca7921112231f8f195138ebba29770",
|
Src: "0x7FA9EF6609Ca7921112231f8f195138ebba29770",
|
||||||
Dst: "0x93086347c52a8878af71bB818509d484c6a2e1bF",
|
Dst: "0x93086347c52a8878af71bB818509d484c6a2e1bF",
|
||||||
Rad: "123",
|
Rad: "123",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package vat_flux
|
package vat_flux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@ -37,7 +38,7 @@ func (VatFluxConverter) ToModels(ethLogs []types.Log) ([]VatFluxModel, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ilk := common.BytesToAddress(ethLog.Topics[1].Bytes())
|
ilk := string(bytes.Trim(ethLog.Topics[1].Bytes(), "\x00"))
|
||||||
src := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
src := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||||
dst := common.BytesToAddress(ethLog.Topics[3].Bytes())
|
dst := common.BytesToAddress(ethLog.Topics[3].Bytes())
|
||||||
radBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data)
|
radBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data)
|
||||||
@ -53,7 +54,7 @@ func (VatFluxConverter) ToModels(ethLogs []types.Log) ([]VatFluxModel, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model := VatFluxModel{
|
model := VatFluxModel{
|
||||||
Ilk: ilk.String(),
|
Ilk: ilk,
|
||||||
Src: src.String(),
|
Src: src.String(),
|
||||||
Dst: dst.String(),
|
Dst: dst.String(),
|
||||||
Rad: rad,
|
Rad: rad,
|
||||||
|
Loading…
Reference in New Issue
Block a user