Skip to content

Commit

Permalink
Merge pull request #100 from Zilliqa/develop
Browse files Browse the repository at this point in the history
Fix: missing parameter of function `GenerateStorageKey `
  • Loading branch information
xiaohuo authored Jul 16, 2021
2 parents 7a254f7 + fc75dd9 commit 85a9cd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions account/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestPayload(t *testing.T) {
ToAddr: "4BAF5faDA8e5Db92C3d3242618c5B47133AE003C",
Amount: "10000000",
GasPrice: gasPrice,
GasLimit: "1",
GasLimit: "50",
Code: "",
Data: "",
Priority: false,
Expand All @@ -71,7 +71,7 @@ func TestWallet_SignWith(t *testing.T) {
Version: "65535",
Amount: "0",
GasPrice: "100000",
GasLimit: "1",
GasLimit: "50",
}
provider := provider2.NewProvider("https://dev-api.zilliqa.com/")
err := wallet.SignWith(tx, "9bfec715a6bd658fcb62b0f8cc9bfa2ade71434a", *provider)
Expand All @@ -96,7 +96,7 @@ func TestSendTransaction(t *testing.T) {
ToAddr: "4BAF5faDA8e5Db92C3d3242618c5B47133AE003C",
Amount: "10000000",
GasPrice: gasPrice,
GasLimit: "1",
GasLimit: "50",
Code: "",
Data: "",
Priority: false,
Expand Down Expand Up @@ -131,14 +131,14 @@ func TestBatchSendTransaction(t *testing.T) {
assert.Nil(t, err, err)

var transactions []*transaction.Transaction
for i := 0; i < 100; i++ {
for i := 0; i < 3; i++ {
txn := &transaction.Transaction{
Version: strconv.FormatInt(int64(util.Pack(333, 1)), 10),
SenderPubKey: "0246E7178DC8253201101E18FD6F6EB9972451D121FC57AA2A06DD5C111E58DC6A",
ToAddr: "4BAF5faDA8e5Db92C3d3242618c5B47133AE003C",
Amount: "10000000",
GasPrice: gasPrice,
GasLimit: "1",
GasLimit: "50",
Code: "",
Data: "",
Priority: false,
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestSendTransactionInsufficientAmount(t *testing.T) {
ToAddr: "4BAF5faDA8e5Db92C3d3242618c5B47133AE003C",
Amount: "2000000000000000000",
GasPrice: gasPrice,
GasLimit: "1",
GasLimit: "50",
Code: "",
Data: "",
Priority: false,
Expand Down
3 changes: 2 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package prover
import (
"errors"
"fmt"

"github.com/Zilliqa/gozilliqa-sdk/core"
"github.com/Zilliqa/gozilliqa-sdk/mpt"
"github.com/Zilliqa/gozilliqa-sdk/provider"
Expand Down Expand Up @@ -40,7 +41,7 @@ func (p *StateProver) VerifyStateProof(contractAddr string, vname string, indice
}

db2 := mpt.NewFromProof(proof2)
storageKey := core.GenerateStorageKey(vname, indices)
storageKey := core.GenerateStorageKey(contractAddr, vname, indices)
value, err3 := mpt.Verify(storageKey, db2, accountBase.StorageRoot)
if err3 != nil {
msg := fmt.Sprintf("%s - %s", "get value error", err3.Error())
Expand Down
6 changes: 4 additions & 2 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package prover

import (
"testing"

"github.com/Zilliqa/gozilliqa-sdk/core"
"github.com/Zilliqa/gozilliqa-sdk/provider"
"testing"
)

func TestStateProver_VerifyStateProof(t *testing.T) {
Expand All @@ -22,7 +23,8 @@ func TestStateProver_VerifyStateProof(t *testing.T) {
t.Log("current block number is: ", blockNum)
t.Log("account root hash from tx block: ", accountHash)

stateProof, err := sp.RpcClient.GetStateProof(contractAddr, vname, indices, &blockNum)
storageKey := core.GenerateStorageKey(contractAddr, vname, indices)
stateProof, err := sp.RpcClient.GetStateProof(contractAddr, string(storageKey), &blockNum)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 85a9cd9

Please sign in to comment.