forked from gnolang/gno
-
-
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.
feat: add basic integration test to gnoclient
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
- Loading branch information
Showing
1 changed file
with
39 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,51 @@ | ||
package gnoclient | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gnolang/gno/gno.land/pkg/gnoland" | ||
"github.com/gnolang/gno/gno.land/pkg/integration" | ||
rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client" | ||
"github.com/gnolang/gno/tm2/pkg/crypto/keys" | ||
"github.com/gnolang/gno/tm2/pkg/log" | ||
"github.com/jaekwon/testify/require" | ||
) | ||
|
||
func newInMemorySigner(t *testing.T, chainid string) *SignerFromKeybase { | ||
t.Helper() | ||
|
||
mmeonic := integration.DefaultAccount_Seed | ||
name := integration.DefaultAccount_Name | ||
|
||
kb := keys.NewInMemory() | ||
_, err := kb.CreateAccount(name, mmeonic, "", "", uint32(0), uint32(0)) | ||
require.NoError(t, err) | ||
|
||
return &SignerFromKeybase{ | ||
Keybase: kb, // Stores keys in memory or on disk | ||
Account: name, // Account name or bech32 format | ||
Password: "", // Password for encryption | ||
ChainID: chainid, // Chain ID for transaction signing | ||
} | ||
} | ||
|
||
func TestClient_Request(t *testing.T) { | ||
config, _ := integration.TestingNodeConfig(t, gnoland.MustGuessGnoRootDir()) | ||
node, remoteAddr := integration.TestingInMemoryNode(t, log.NewNopLogger(), config) | ||
defer node.Stop() | ||
|
||
signer := newInMemorySigner(t, config.TMConfig.ChainID()) | ||
|
||
client := Client{ | ||
// Remote: "localhost:12345", | ||
// ChainID: "test", | ||
Signer: signer, | ||
RPCClient: rpcclient.NewHTTP(remoteAddr, "/websocket"), | ||
} | ||
_ = client | ||
|
||
data, res, err := client.Render("gno.land/r/demo/boards", "") | ||
require.NoError(t, err) | ||
fmt.Println("data", data) | ||
fmt.Println("res", res) | ||
|
||
// TODO: xxx | ||
} |