Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
keep default res
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Nov 4, 2022
1 parent ab63975 commit 05a5e3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
13 changes: 8 additions & 5 deletions rpc/backend/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNu

// GetHexProofs returns list of hex data of proof op
func GetHexProofs(proof *crypto.ProofOps) []string {
if proof == nil {
return []string{""}
}
var proofs []string
// check for proof
if proof != nil {
for _, p := range proof.Ops {
if len(p.Data) > 0 {
proofs = append(proofs, hexutil.Encode(p.Data))
}
for _, p := range proof.Ops {
proof := ""
if len(p.Data) > 0 {
proof = hexutil.Encode(p.Data)
}
proofs = append(proofs, proof)
}
return proofs
}
Expand Down
7 changes: 4 additions & 3 deletions rpc/backend/account_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func mookProofs(num int, withData bool) *crypto.ProofOps {
}

func (suite *BackendTestSuite) TestGetHexProofs() {
defaultRes := []string{""}
testCases := []struct {
name string
proof *crypto.ProofOps
Expand All @@ -403,12 +404,12 @@ func (suite *BackendTestSuite) TestGetHexProofs() {
{
"no proof provided",
mookProofs(0, false),
nil,
defaultRes,
},
{
"no proof data provided",
mookProofs(0, false),
nil,
mookProofs(1, false),
defaultRes,
},
{
"valid proof provided",
Expand Down

0 comments on commit 05a5e3e

Please sign in to comment.