Skip to content

Commit

Permalink
fix: issue in types
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksharmapoudel committed Jul 6, 2023
1 parent d133f8a commit eaf7524
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions relayer/chains/icon/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestUpdateClientHeader(t *testing.T) {

p := GetMockIconProvider(2, "dddd")

height := int64(201)
height := int64(401)
header, _ := p.GetBtpHeader(height)
proofContext, _ := p.GetProofContextByHeight(height - 1)

Expand All @@ -458,15 +458,13 @@ func TestUpdateClientHeader(t *testing.T) {
// NextProofContext: signedHeader.Header.NextProofContext,
}
networkSection := types.NewNetworkSection(&btpLocalHeader)
fmt.Printf("newtworkSection :%x \n", networkSection.Encode())
fmt.Printf("newtworkSection :%x \n", networkSection.Hash())
decision := types.NewNetworkTypeSectionDecision(getSrcNetworkId(3), 1, height, btpLocalHeader.Round,
types.NetworkTypeSection{
NextProofContextHash: btpLocalHeader.NextProofContextHash,
NetworkSectionsRoot: GetNetworkSectionRoot(&btpLocalHeader),
})

fmt.Println("decision value: ")

isValid, err := VerifyBtpProof(decision, signedHeader.Signatures, proofContext)
assert.NoError(t, err)

Expand Down
14 changes: 7 additions & 7 deletions relayer/chains/icon/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ type NetworkSection struct {
func NewNetworkSection(
header *BTPBlockHeader,
) *NetworkSection {
messageSn := (header.UpdateNumber - header.MessageCount) << 1
if header.NextProofContext != nil {
messageSn |= 1
}
// messageSn := (header.UpdateNumber + header.MessageCount) << 1
// if header.NextProofContext != nil {
// messageSn |= 1
// }

return &NetworkSection{
Nid: int64(header.NetworkID),
MessageSn: uint64(messageSn),
MessageSn: uint64(header.UpdateNumber),
Prev: header.PrevNetworkSectionHash,
MessageCount: int64(header.MessageCount),
MessageRoot: header.MessageRoot,
Expand Down Expand Up @@ -622,13 +622,13 @@ func (h *NetworkTypeSectionDecision) Encode() []byte {
}

func (h *NetworkTypeSectionDecision) Hash() []byte {
return relayer_common.Sha3keccak256(codec.RLP.MustMarshalToBytes(h))
return relayer_common.Sha3keccak256(h.Encode())
}

func (h *NetworkTypeSection) Encode() []byte {
return codec.RLP.MustMarshalToBytes(h)
}

func (h *NetworkTypeSection) Hash() []byte {
return (codec.RLP.MustMarshalToBytes(h))
return relayer_common.Sha3keccak256(h.Encode())
}

0 comments on commit eaf7524

Please sign in to comment.