Skip to content

Commit 713f331

Browse files
Merge branch 'main' into PRODCRE-538-add-billing-service-to-local-stack
2 parents fe68fdc + 227e5cf commit 713f331

File tree

31 files changed

+557
-225
lines changed

31 files changed

+557
-225
lines changed

book/src/framework/components/blockchains/ton.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,29 @@ The genesis container supports additional environment variables that can be conf
2828
The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed.
2929
More info on parameters can be found here <https://github.com/neodix42/mylocalton-docker/wiki/Genesis-setup-parameters>.
3030

31+
## Network Configuration
32+
33+
The framework provides direct access to TON liteserver connections through pre-formatted liteserver URLs. The `ExternalHTTPUrl` and `InternalHTTPUrl` contain ready-to-use liteserver connection strings in the format `liteserver://publickey@host:port`, eliminating the need to fetch and parse separate configuration files.
34+
3135
## Default Ports
3236

33-
The TON implementation exposes essential services:
37+
The TON implementation exposes essential services through port mapping:
3438

35-
* TON Simple HTTP Server: Port 8000
36-
* TON Lite Server: Port derived from base port + 100
39+
* **TON Simple HTTP Server**: External dynamic port → Internal port 8000
40+
* **TON Lite Server**: External dynamic port → Internal dynamic port (base + 100 offset)
3741

38-
> Note: `tonutils-go` library is used for TON blockchain interactions, which requires a TON Lite Server connection. `tonutils-go` queries config file to determine the Lite Server connection details, which are provided by the MyLocalTon Docker environment.
42+
The framework automatically handles port mapping and provides ready-to-use liteserver connection URLs.
3943

44+
> Note: `tonutils-go` library is used for TON blockchain interactions, which requires a TON Lite Server connection. The framework provides direct liteserver:// URLs that can be used immediately without additional configuration parsing.
4045
4146
## Usage
4247

4348
```go
4449
package examples
4550

4651
import (
52+
"context"
53+
"fmt"
4754
"strings"
4855
"testing"
4956

@@ -60,6 +67,34 @@ type CfgTon struct {
6067
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
6168
}
6269

70+
// getConnectionPoolFromLiteserverURL parses a liteserver:// URL and creates a connection pool
71+
func getConnectionPoolFromLiteserverURL(ctx context.Context, liteserverURL string) (*liteclient.ConnectionPool, error) {
72+
// Parse the liteserver URL, expected format: liteserver://publickey@host:port
73+
if !strings.HasPrefix(liteserverURL, "liteserver://") {
74+
return nil, fmt.Errorf("invalid liteserver URL format: expected liteserver:// prefix")
75+
}
76+
77+
// Remove the liteserver:// prefix
78+
urlPart := strings.TrimPrefix(liteserverURL, "liteserver://")
79+
80+
// Split by @ to separate publickey and host:port
81+
parts := strings.Split(urlPart, "@")
82+
if len(parts) != 2 {
83+
return nil, fmt.Errorf("invalid liteserver URL format: expected publickey@host:port")
84+
}
85+
86+
publicKey := parts[0]
87+
hostPort := parts[1]
88+
89+
connectionPool := liteclient.NewConnectionPool()
90+
err := connectionPool.AddConnection(ctx, hostPort, publicKey)
91+
if err != nil {
92+
return nil, fmt.Errorf("failed to add liteserver connection: %w", err)
93+
}
94+
95+
return connectionPool, nil
96+
}
97+
6398
func TestTonSmoke(t *testing.T) {
6499
in, err := framework.Load[CfgTon](t)
65100
require.NoError(t, err)
@@ -72,18 +107,14 @@ func TestTonSmoke(t *testing.T) {
72107
var client ton.APIClientWrapped
73108

74109
t.Run("setup:connect", func(t *testing.T) {
75-
// Create a connection pool
76-
connectionPool := liteclient.NewConnectionPool()
77-
78-
// Get the network configuration from the global config URL
79-
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), fmt.Sprintf("http://%s/localhost.global.config.json", bc.Nodes[0].ExternalHTTPUrl))
80-
require.NoError(t, cferr, "Failed to get config from URL")
81-
82-
// Add connections from the config
83-
caerr := connectionPool.AddConnectionsFromConfig(t.Context(), cfg)
84-
require.NoError(t, caerr, "Failed to add connections from config")
85-
86-
// Create an API client with retry functionality
110+
// bc.Nodes[0].ExternalHTTPUrl now contains: "liteserver://publickey@host:port"
111+
liteserverURL := bc.Nodes[0].ExternalHTTPUrl
112+
113+
// Create connection pool from liteserver URL
114+
connectionPool, err := getConnectionPoolFromLiteserverURL(t.Context(), liteserverURL)
115+
require.NoError(t, err, "Failed to create connection pool from liteserver URL")
116+
117+
// Create API client
87118
client = ton.NewAPIClient(connectionPool).WithRetry()
88119

89120
t.Run("setup:faucet", func(t *testing.T) {

framework/.changeset/v0.10.17.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Expose a function that is used to name containers in simple node set

framework/.changeset/v0.10.18.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Call teardown when a WASP virtual user test is finished to ensure cleanup

framework/.changeset/v0.10.19.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Configure Geth chain id

framework/.changeset/v0.10.20.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Update TON/MyLocalTON 3.7 Default Settings

framework/.changeset/v0.10.21.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Update TON network output to embed LiteServer configuration directly

framework/.changeset/v0.10.22.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Update TON network output to return liteserver URL directly

framework/.changeset/v0.10.23.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes TON port mappping, update examples and docs

framework/.changeset/v0.10.24.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- On chain metrics scrape targets
2+
- Allow to specify custom names for blockchain containers

framework/components/blockchain/aptos.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
const (
1818
DefaultAptosAPIPort = "8080"
1919
DefaultAptosFaucetPort = "8081"
20-
DefaultAptosArm64Image = "ghcr.io/friedemannf/aptos-tools:aptos-node-v1.30.2-rc"
21-
DefaultAptosX86_64Image = "aptoslabs/tools:aptos-node-v1.27.2"
20+
DefaultAptosArm64Image = "ghcr.io/friedemannf/aptos-tools:aptos-node-v1.34.3-hotfix"
21+
DefaultAptosX86_64Image = "aptoslabs/tools:aptos-node-v1.34.3-hotfix"
2222
)
2323

2424
var (

0 commit comments

Comments
 (0)