Skip to content

Commit

Permalink
fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentysc committed Nov 29, 2024
1 parent 4a4e193 commit 12d65c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
5 changes: 3 additions & 2 deletions infrastructure/tendermint/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/crypto-com/chain-indexing/usecase/model/genesis"

"github.com/crypto-com/chain-indexing/external/tmcosmosutils"
"github.com/crypto-com/chain-indexing/external/utctime"

"github.com/crypto-com/chain-indexing/usecase/model"
jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -73,7 +74,7 @@ func ParseBlockResp(rawRespReader io.Reader) (*model.Block, *model.RawBlock, err
return &model.Block{
Height: height,
Hash: resp.Result.BlockID.Hash,
Time: resp.Result.Block.Header.Time,
Time: utctime.FromTime(resp.Result.Block.Header.Time),
AppHash: resp.Result.Block.Header.AppHash,
ProposerAddress: resp.Result.Block.Header.ProposerAddress,
Txs: resp.Result.Block.Data.Txs,
Expand All @@ -95,7 +96,7 @@ func parseBlockSignatures(rawSignatures []model.RawBlockSignature) []model.Block
signatures = append(signatures, model.BlockSignature{
BlockIdFlag: rawSignature.BlockIDFlag,
ValidatorAddress: rawSignature.ValidatorAddress,
Timestamp: rawSignature.Timestamp,
Timestamp: utctime.FromTime(rawSignature.Timestamp),
Signature: *rawSignature.Signature,
})
}
Expand Down
24 changes: 13 additions & 11 deletions usecase/model/block.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import (
"time"

"github.com/crypto-com/chain-indexing/external/utctime"
"github.com/luci/go-render/render"
)
Expand Down Expand Up @@ -41,10 +43,10 @@ type BlockEvidence struct {
Hash string `json:"hash"`
} `json:"parts"`
} `json:"block_id"`
Timestamp utctime.UTCTime `json:"timestamp"`
ValidatorAddress string `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Signature string `json:"signature"`
Timestamp time.Time `json:"timestamp"`
ValidatorAddress string `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Signature string `json:"signature"`
} `json:"vote_a"`
VoteB struct {
Type int `json:"type"`
Expand All @@ -57,14 +59,14 @@ type BlockEvidence struct {
Hash string `json:"hash"`
} `json:"parts"`
} `json:"block_id"`
Timestamp utctime.UTCTime `json:"timestamp"`
ValidatorAddress string `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Signature string `json:"signature"`
Timestamp time.Time `json:"timestamp"`
ValidatorAddress string `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Signature string `json:"signature"`
} `json:"vote_b"`
// TODO: Breaking changes to snake case in the future
TotalVotingPower string `json:"TotalVotingPower"`
ValidatorPower string `json:"ValidatorPower"`
Timestamp utctime.UTCTime `json:"Timestamp"`
TotalVotingPower string `json:"TotalVotingPower"`
ValidatorPower string `json:"ValidatorPower"`
Timestamp time.Time `json:"Timestamp"`
} `json:"value"`
}
17 changes: 9 additions & 8 deletions usecase/model/rawblock.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package model

import (
"github.com/crypto-com/chain-indexing/external/utctime"
"time"

"github.com/luci/go-render/render"
)

Expand All @@ -19,9 +20,9 @@ type RawBlock struct {
Version struct {
Block string `json:"block"`
} `json:"version"`
ChainID string `json:"chain_id"`
Height string `json:"height"`
Time utctime.UTCTime `json:"time"`
ChainID string `json:"chain_id"`
Height string `json:"height"`
Time time.Time `json:"time"`
LastBlockID struct {
Hash string `json:"hash"`
Parts struct {
Expand Down Expand Up @@ -66,8 +67,8 @@ func (rawBlock *RawBlock) String() string {

// RawBlockSignature defines the structure for signatures in /block API
type RawBlockSignature struct {
BlockIDFlag int `json:"block_id_flag"`
ValidatorAddress string `json:"validator_address"`
Timestamp utctime.UTCTime `json:"timestamp"`
Signature *string `json:"signature"`
BlockIDFlag int `json:"block_id_flag"`
ValidatorAddress string `json:"validator_address"`
Timestamp time.Time `json:"timestamp"`
Signature *string `json:"signature"`
}

0 comments on commit 12d65c3

Please sign in to comment.