Skip to content

Commit 5c02c35

Browse files
authored
Merge branch 'main' into citool/self-hosted-runners
2 parents 44a3a49 + bc44590 commit 5c02c35

File tree

95 files changed

+30434
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+30434
-656
lines changed

.github/workflows/framework-golden-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ jobs:
4343
config: smoke_solana.toml
4444
count: 1
4545
timeout: 10m
46+
- name: TestTonSmoke
47+
config: smoke_ton.toml
48+
count: 1
49+
timeout: 10m
4650
- name: TestUpgrade
4751
config: upgrade.toml
4852
count: 1

.github/workflows/test.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
test:
16+
- path: framework
17+
vm: ubuntu-latest
18+
regex: TestStorageMutations
1619
- path: framework
1720
vm: ubuntu-latest
1821
regex: TestSmoke
@@ -78,6 +81,10 @@ jobs:
7881
restore-keys: |
7982
go-modules-${{ matrix.test.path }}-${{ runner.os }}-test
8083
go-modules-${{ matrix.test.path }}-${{ runner.os }}
84+
- name: Install Foundry
85+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
86+
with:
87+
version: stable
8188
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
8289
with:
8390
github-token: ${{ secrets.GITHUB_TOKEN }}

book/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
- [Sui](framework/components/blockchains/sui.md)
4747
- [TRON](framework/components/blockchains/tron.md)
4848
- [ZKSync](framework/components/blockchains/zksync.md)
49+
- [Ton](framework/components/blockchains/ton.md)
4950
- [Optimism Stack]()
5051
- [Arbitrum Stack]()
5152
- [Chainlink](framework/components/chainlink.md)
@@ -61,6 +62,7 @@
6162
- [Performance]()
6263
- [Chaos](./framework/chaos/chaos.md)
6364
- [Fork Testing](./framework/fork.md)
65+
- [Fork Testing (Mutating Storage)](./framework/fork_storage.md)
6466
- [Libraries](./libraries.md)
6567
- [Seth](./libs/seth.md)
6668
- [WASP](./libs/wasp/overview.md)
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# TON Blockchain Client
2+
3+
TON (The Open Network) support in the framework utilizes MyLocalTon Docker Compose environment to provide a local TON blockchain for testing purposes.
4+
5+
## Configuration
6+
7+
```toml
8+
[blockchain_a]
9+
type = "ton"
10+
# By default uses MyLocalTon Docker Compose file
11+
docker_compose_file_url = "https://raw.githubusercontent.com/neodix42/mylocalton-docker/main/docker-compose.yaml"
12+
# Optional: Specify only core services needed for testing (useful in CI environments)
13+
ton_core_services = [
14+
"genesis",
15+
"tonhttpapi",
16+
"event-cache",
17+
"index-postgres",
18+
"index-worker",
19+
"index-api"
20+
]
21+
```
22+
23+
## Default Ports
24+
25+
The TON implementation exposes several services:
26+
27+
- TON Lite Server: Port 40004
28+
- TON HTTP API: Port 8081
29+
- TON Simple HTTP Server: Port 8000
30+
- TON Explorer: Port 8080
31+
32+
> **Note**: By default, only the lite client service is exposed externally. Other services may need additional configuration to be accessible outside the Docker network.
33+
34+
## Validator Configuration
35+
36+
By default, the MyLocalTon environment starts with only one validator enabled. If multiple validators are needed (up to 6 are supported), the Docker Compose file must be provided with modified version with corresponding service definition in toml file before starting the environment.
37+
38+
## Usage
39+
40+
```go
41+
package examples
42+
43+
import (
44+
"strings"
45+
"testing"
46+
47+
"github.com/stretchr/testify/require"
48+
"github.com/xssnick/tonutils-go/liteclient"
49+
"github.com/xssnick/tonutils-go/ton"
50+
"github.com/xssnick/tonutils-go/ton/wallet"
51+
52+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
53+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
54+
)
55+
56+
type CfgTon struct {
57+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
58+
}
59+
60+
func TestTonSmoke(t *testing.T) {
61+
in, err := framework.Load[CfgTon](t)
62+
require.NoError(t, err)
63+
64+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
65+
require.NoError(t, err)
66+
67+
var client ton.APIClientWrapped
68+
69+
t.Run("setup:connect", func(t *testing.T) {
70+
// Create a connection pool
71+
connectionPool := liteclient.NewConnectionPool()
72+
73+
// Get the network configuration from the global config URL
74+
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), fmt.Sprintf("http://%s/localhost.global.config.json", bc.Nodes[0].ExternalHTTPUrl))
75+
require.NoError(t, cferr, "Failed to get config from URL")
76+
77+
// Add connections from the config
78+
caerr := connectionPool.AddConnectionsFromConfig(t.Context(), cfg)
79+
require.NoError(t, caerr, "Failed to add connections from config")
80+
81+
// Create an API client with retry functionality
82+
client = ton.NewAPIClient(connectionPool).WithRetry()
83+
84+
t.Run("setup:faucet", func(t *testing.T) {
85+
// Create a wallet from the pre-funded high-load wallet seed
86+
rawHlWallet, err := wallet.FromSeed(client, strings.Fields(blockchain.DefaultTonHlWalletMnemonic), wallet.HighloadV2Verified)
87+
require.NoError(t, err, "failed to create highload wallet")
88+
89+
// Create a workchain -1 (masterchain) wallet
90+
mcFunderWallet, err := wallet.FromPrivateKeyWithOptions(client, rawHlWallet.PrivateKey(), wallet.HighloadV2Verified, wallet.WithWorkchain(-1))
91+
require.NoError(t, err, "failed to create highload wallet")
92+
93+
// Get subwallet with ID 42
94+
funder, err := mcFunderWallet.GetSubwallet(uint32(42))
95+
require.NoError(t, err, "failed to get highload subwallet")
96+
97+
// Verify the funder address matches the expected default
98+
require.Equal(t, funder.Address().StringRaw(), blockchain.DefaultTonHlWalletAddress, "funder address mismatch")
99+
100+
// Check the funder balance
101+
master, err := client.GetMasterchainInfo(t.Context())
102+
require.NoError(t, err, "failed to get masterchain info for funder balance check")
103+
funderBalance, err := funder.GetBalance(t.Context(), master)
104+
require.NoError(t, err, "failed to get funder balance")
105+
require.Equal(t, funderBalance.Nano().String(), "1000000000000000", "funder balance mismatch")
106+
})
107+
})
108+
}
109+
```
110+
111+
## Test Private Keys
112+
113+
The framework includes a pre-funded high-load wallet for testing purposes. This wallet type can send up to 254 messages per 1 external message, making it efficient for test scenarios.
114+
115+
Default High-Load Wallet:
116+
```
117+
Address: -1:5ee77ced0b7ae6ef88ab3f4350d8872c64667ffbe76073455215d3cdfab3294b
118+
Mnemonic: twenty unfair stay entry during please water april fabric morning length lumber style tomorrow melody similar forum width ride render void rather custom coin
119+
```
120+
121+
## Available Pre-funded Wallets
122+
123+
MyLocalTon Docker environment comes with several pre-funded wallets that can be used for testing:
124+
125+
1. Genesis Wallet (V3R2, WalletId: 42)
126+
2. Validator Wallets (1-5) (V3R2, WalletId: 42)
127+
3. Faucet Wallet (V3R2, WalletId: 42, Balance: 1 million TON)
128+
4. Faucet Highload Wallet (Highload V2, QueryId: 0, Balance: 1 million TON)
129+
5. Basechain Faucet Wallet (V3R2, WalletId: 42, Balance: 1 million TON)
130+
6. Basechain Faucet Highload Wallet (Highload V2, QueryId: 0, Balance: 1 million TON)
131+
132+
For the complete list of addresses and mnemonics, refer to the [MyLocalTon Docker documentation](https://github.com/neodix42/mylocalton-docker).

book/src/framework/fork_storage.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Fork Testing (Mutating Storage)
2+
3+
We provide API to use `anvil_setStorageAt` more easily so in case you can't edit EVM smart contracts code you can still mutate your contract values.
4+
5+
You need to build your contract layout first
6+
```
7+
forge build || forge inspect Counter storageLayout --json > layout.json
8+
```
9+
10+
And then you can use `AnvilSetStorageAt` to override contract's storage data
11+
```
12+
r := rpc.New(rpcURL, nil)
13+
err = r.AnvilSetStorageAt([]interface{}{contractAddr, slot, data})
14+
```
15+
See [examples](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/evm_storage/layout_api_test.go) of how you can use API to encode/mutate different values.
16+
17+
Keep in mind that values <32 bytes are packed together, see `encodeCustomStructFunc` example and `offset` example to understnad how to change them properly.
18+
19+
```
20+
cd framework/evm_storage
21+
./setup.sh
22+
go test -v -run TestLayoutAPI
23+
./teardown.sh
24+
```
25+
26+
Read more about Solidity storage layout [here](https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#)

devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
77
"git@latest",
8-
"go@latest",
8+
"go@1.24.0",
99
"goreleaser@latest",
1010
"postgresql@15",
1111
"python@latest",

0 commit comments

Comments
 (0)