-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from make-software/feature/CMW-810/add_support…
…_node_v1.5.5 Feature/cmw 810/add support node v1.5.5
- Loading branch information
Showing
4 changed files
with
89 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/make-software/casper-go-sdk/casper" | ||
"github.com/make-software/casper-go-sdk/rpc" | ||
) | ||
|
||
func GetRpcClient() rpc.Client { | ||
url, found := os.LookupEnv("NODE_URL") | ||
if !found { | ||
panic("NODE_URL env variable is not set") | ||
} | ||
return rpc.NewClient(rpc.NewHttpHandler(url, http.DefaultClient)) | ||
} | ||
|
||
func Test_DefaultClient_GetAccountInfo_ByPublicKey(t *testing.T) { | ||
pubKey, err := casper.NewPublicKey("01018525deae6091abccab6704a0fa44e12c495eec9e8fe6929862e1b75580e715") | ||
require.NoError(t, err) | ||
res, err := GetRpcClient().GetAccountInfo(context.Background(), nil, rpc.AccountIdentifier{PublicKey: &pubKey}) | ||
require.NoError(t, err) | ||
assert.Equal(t, "account-hash-bf06bdb1616050cea5862333d1f4787718f1011c95574ba92378419eefeeee59", res.Account.AccountHash.ToPrefixedString()) | ||
} | ||
|
||
func Test_DefaultClient_GetAccountInfo_ByAccountKey(t *testing.T) { | ||
accountKey, err := casper.NewAccountHash("account-hash-bf06bdb1616050cea5862333d1f4787718f1011c95574ba92378419eefeeee59") | ||
require.NoError(t, err) | ||
res, err := GetRpcClient().GetAccountInfo(context.Background(), nil, rpc.AccountIdentifier{AccountHash: &accountKey}) | ||
require.NoError(t, err) | ||
assert.Equal(t, "account-hash-bf06bdb1616050cea5862333d1f4787718f1011c95574ba92378419eefeeee59", res.Account.AccountHash.ToPrefixedString()) | ||
} | ||
|
||
func Test_DefaultClient_QueryStateByStateHash(t *testing.T) { | ||
accountKey := "account-hash-bf06bdb1616050cea5862333d1f4787718f1011c95574ba92378419eefeeee59" | ||
res, err := GetRpcClient().QueryGlobalStateByStateHash(context.Background(), nil, accountKey, nil) | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, res.StoredValue.Account.AccountHash) | ||
} |