Skip to content

Commit

Permalink
feat: add basic integration test to gnoclient
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Nov 23, 2023
1 parent 8d451c0 commit e2537eb
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions gno.land/pkg/gnoclient/client_test.go
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
}

0 comments on commit e2537eb

Please sign in to comment.