forked from cerc-io/ipld-eth-server
Add Vat heal integration test
This commit is contained in:
@@ -17,9 +17,9 @@ package vat_heal
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Converter interface {
|
||||
@@ -36,9 +36,9 @@ func (VatHealConverter) ToModels(ethLogs []types.Log) ([]VatHealModel, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
urn := common.BytesToAddress(ethLog.Topics[1].Bytes()[:common.AddressLength])
|
||||
v := common.BytesToAddress(ethLog.Topics[2].Bytes()[:common.AddressLength])
|
||||
radInt, err := strconv.ParseInt(ethLog.Topics[3].Hex(), 0, 64)
|
||||
urn := common.BytesToAddress(ethLog.Topics[1].Bytes())
|
||||
v := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
radInt := ethLog.Topics[3].Big()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func (VatHealConverter) ToModels(ethLogs []types.Log) ([]VatHealModel, error) {
|
||||
model := VatHealModel{
|
||||
Urn: urn.String(),
|
||||
V: v.String(),
|
||||
Rad: int(radInt),
|
||||
Rad: radInt.String(),
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
Raw: rawLogJson,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ package vat_heal
|
||||
type VatHealModel struct {
|
||||
Urn string
|
||||
V string
|
||||
Rad int
|
||||
Rad string
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
Raw []byte `db:"raw_log"`
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (repository VatHealRepository) Create(headerId int64, models []VatHealModel
|
||||
|
||||
for _, model := range models {
|
||||
_, err := tx.Exec(`INSERT INTO maker.vat_heal (header_id, urn, v, rad, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6)`,
|
||||
VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`,
|
||||
headerId, model.Urn, model.V, model.Rad, model.TransactionIndex, model.Raw)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
Reference in New Issue
Block a user