Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bindings/tests/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ func (te *TestEnvironment) initialize() error {
te.cleanup()
return fmt.Errorf("timeout waiting for Sui node to be ready")
default:
client := sui.NewSuiClient(fmt.Sprintf("http://localhost:%d", te.rpcPort))
client := sui.NewSuiClientWithCustomClient(fmt.Sprintf("http://localhost:%d", te.rpcPort), &http.Client{
Timeout: HTTPClientTimeout,
})
_, err := client.SuiGetChainIdentifier(context.Background())
if err == nil {
return nil
Expand All @@ -192,7 +194,9 @@ func (te *TestEnvironment) cleanup() {
}

func createClient() sui.ISuiAPI {
return sui.NewSuiClient(fmt.Sprintf("http://localhost:%d", instance.rpcPort))
return sui.NewSuiClientWithCustomClient(fmt.Sprintf("http://localhost:%d", instance.rpcPort), &http.Client{
Timeout: HTTPClientTimeout,
})
}

func createAccount(t *testing.T) (utils.SuiSigner, error) {
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/offramp/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/hex"
"fmt"
"math/big"
"net/http"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -40,6 +41,7 @@ const (
evmReceiverAddress = "0x80226fc0ee2b096224eeac085bb9a8cba1146f7d"
SUI_CHAIN_SELECTOR = 2
ETHEREUM_CHAIN_SELECTOR = 1
HTTPClientTimeout = 30 * time.Second
)

var ConfigDigest = []byte{
Expand All @@ -64,7 +66,9 @@ func setupClients(t *testing.T, lggr logger.Logger) (rel.SuiSigner, sui.ISuiAPI,
})

// Create the client.
client := sui.NewSuiClient(testutils.LocalUrl)
client := sui.NewSuiClientWithCustomClient(testutils.LocalUrl, &http.Client{
Timeout: HTTPClientTimeout,
})

// Generate key pair and create a signer.
pk, _, _, err := testutils.GenerateAccountKeyPair(t)
Expand Down
35 changes: 9 additions & 26 deletions integration-tests/onramp/environment/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,23 @@ type EnvironmentSettings struct {
Client sui.ISuiAPI
}

// SetupClients creates and configures Sui client and signer for testing.
// It generates a new key pair, creates a signer, and funds the signer address.
func SetupClients(t *testing.T, lggr logger.Logger) (rel.SuiSigner, sui.ISuiAPI) {
// BasicSetUp performs basic environment setup including account creation, client setup,
// and bundle initialization. This is the foundation for all test environments.
func BasicSetUp(t *testing.T, lggr logger.Logger, keystoreInstance *testutils.TestKeystore) (string, []byte, rel.SuiSigner, sui.ISuiAPI, sui_ops.OpTxDeps, cld_ops.Bundle) {
t.Helper()

client := sui.NewSuiClient(testutils.LocalUrl)
gasLimit := int64(200000000000)
ptbClient, _, _, accountAddress, _, publicKeyBytes, _, _ := testutils.SetupTestEnv(t, context.Background(), lggr, gasLimit)

// Generate key pair and create a signer.
// Generate key pair and create a signer - use the same key for both signer and keystore
pk, _, _, err := testutils.GenerateAccountKeyPair(t)
require.NoError(t, err)
signer := rel.NewPrivateKeySigner(pk)

// Fund the signer for contract deployment
signerAddress, err := signer.GetAddress()
accountAddress, err = signer.GetAddress()
require.NoError(t, err)
for range 3 {
err = testutils.FundWithFaucet(lggr, "localnet", signerAddress)
require.NoError(t, err)
}

return signer, client
}

// BasicSetUp performs basic environment setup including account creation, client setup,
// and bundle initialization. This is the foundation for all test environments.
func BasicSetUp(t *testing.T, lggr logger.Logger, keystoreInstance *testutils.TestKeystore) (string, []byte, rel.SuiSigner, sui.ISuiAPI, sui_ops.OpTxDeps, cld_ops.Bundle) {
t.Helper()

accountAddress, publicKeyBytes := testutils.GetAccountAndKeyFromSui(keystoreInstance)

signer, client := SetupClients(t, lggr)

deps := sui_ops.OpTxDeps{
Client: client,
Client: ptbClient.GetClient(),
Signer: signer,
GetCallOpts: func() *bind.CallOpts {
b := uint64(500_000_000)
Expand All @@ -114,7 +97,7 @@ func BasicSetUp(t *testing.T, lggr logger.Logger, keystoreInstance *testutils.Te
reporter,
)

return accountAddress, publicKeyBytes, signer, client, deps, bundle
return accountAddress, publicKeyBytes, signer, ptbClient.GetClient(), deps, bundle
}

// UpdatePrices sets token prices in the fee quoter contract.
Expand Down
Loading
Loading