forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rpc): different result from
eth_getProof
comparing with Ethereum (
evmos#1431) * align with eth_getProof for more info, see https://eips.ethereum.org/EIPS/eip-1186 * add GetHexProofs * add change doc * keep default res * fix lint * add e2e test * Apply suggestions from code review * fix lint * nix run -f ./nix gomod2nix
- Loading branch information
Showing
7 changed files
with
114 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package backend | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/tendermint/tendermint/proto/tendermint/crypto" | ||
) | ||
|
||
func mookProofs(num int, withData bool) *crypto.ProofOps { | ||
var proofOps *crypto.ProofOps | ||
if num > 0 { | ||
proofOps = new(crypto.ProofOps) | ||
for i := 0; i < num; i++ { | ||
proof := crypto.ProofOp{} | ||
if withData { | ||
proof.Data = []byte("\n\031\n\003KEY\022\005VALUE\032\013\010\001\030\001 \001*\003\000\002\002") | ||
} | ||
proofOps.Ops = append(proofOps.Ops, proof) | ||
} | ||
} | ||
return proofOps | ||
} | ||
|
||
func (suite *BackendTestSuite) TestGetHexProofs() { | ||
defaultRes := []string{""} | ||
testCases := []struct { | ||
name string | ||
proof *crypto.ProofOps | ||
exp []string | ||
}{ | ||
{ | ||
"no proof provided", | ||
mookProofs(0, false), | ||
defaultRes, | ||
}, | ||
{ | ||
"no proof data provided", | ||
mookProofs(1, false), | ||
defaultRes, | ||
}, | ||
{ | ||
"valid proof provided", | ||
mookProofs(1, true), | ||
[]string{"0x0a190a034b4559120556414c55451a0b0801180120012a03000202"}, | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.name), func() { | ||
suite.Require().Equal(tc.exp, GetHexProofs(tc.proof)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters