Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .github/workflows/relayer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
- name: Run integration tests
run: |
pushd integration-tests
cp tracetracking/.env.example tracetracking/.env
nix develop -c go test -v -count=1 -p=1 -timeout 30m ./...

build-pkgs:
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ go 1.24.2

require (
github.com/hashicorp/consul/sdk v0.16.2
github.com/joho/godotenv v1.5.1
github.com/smartcontractkit/chain-selectors v1.0.60
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250527164052-5a4fb8e255ff
github.com/smartcontractkit/chainlink-deployments-framework v0.10.0
github.com/smartcontractkit/chainlink-testing-framework/framework v0.9.6
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.4
github.com/smartcontractkit/chainlink-ton v0.0.0
github.com/smartcontractkit/freeport v0.1.0
github.com/stretchr/testify v1.10.0
github.com/xssnick/tonutils-go v1.13.0
)
Expand Down Expand Up @@ -126,6 +124,7 @@ require (
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartcontractkit/freeport v0.1.0 // indirect
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect
github.com/smartcontractkit/libocr v0.0.0-20250220133800-f3b940c4f298 // indirect
github.com/testcontainers/testcontainers-go v0.37.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgf
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
Expand Down Expand Up @@ -383,8 +381,8 @@ github.com/smartcontractkit/chainlink-common v0.7.1-0.20250527164052-5a4fb8e255f
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250527164052-5a4fb8e255ff/go.mod h1:TF9ZqBV0QA3X1T4BoLGp0FfJpOQOcQ+ggKu1MlsWKYw=
github.com/smartcontractkit/chainlink-deployments-framework v0.10.0 h1:DTLUJsC66GC7GHlx8VARpvRym7SnoJClWb+XKPvAves=
github.com/smartcontractkit/chainlink-deployments-framework v0.10.0/go.mod h1:pe1X7qw2h+bYH90OheAlZ/vYCq8SKOnFAXGWUmIIeSc=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.9.6 h1:vnUXO+Fhr7x30+ptRRv7/CqLwENnrWjZiLoTDYEw+iY=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.9.6/go.mod h1:q99H9vcMJDs6T+zsSI8XJZd6PUkZnyG3iaRbrYNUCTk=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.4 h1:ZCsiFaN9QYfNO3/1+TTRzMQeMx6uRead09pFx7OHacQ=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.4/go.mod h1:47sm4C5wBxR8VBAZoDRGSt5wJwDJN3vVeE36l5vQs1g=
github.com/smartcontractkit/freeport v0.1.0 h1:3MZHeti5m+tSTBCq5R8rhawFHxrnQZYBZVL+xgS1sPo=
github.com/smartcontractkit/freeport v0.1.0/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
Expand Down
2 changes: 0 additions & 2 deletions integration-tests/tracetracking/.env.example

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/tracetracking/.gitignore

This file was deleted.

294 changes: 146 additions & 148 deletions integration-tests/tracetracking/integration_test.go

Large diffs are not rendered by default.

74 changes: 12 additions & 62 deletions integration-tests/tracetracking/testutils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import (
"errors"
"fmt"
"math/big"
"os"
"path"
"strings"
"testing"

testutils "integration-tests/utils"

"github.com/joho/godotenv"
"github.com/stretchr/testify/require"

"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
ton "github.com/xssnick/tonutils-go/ton"
wallet "github.com/xssnick/tonutils-go/ton/wallet"
Expand All @@ -25,19 +22,21 @@ import (
func SetUpTest(t *testing.T, chainID uint64, initialAmount *big.Int, fundedAccountsCount uint) (accounts []tracetracking.SignedAPIClient) {
api := testutils.CreateAPIClient(t, chainID)

// Get wallet for operations
funderWallet := getWallet(t, api)

// Run the spec tests, which are fully chain agnostic
funder := tracetracking.NewSignedAPIClient(api, *funderWallet)
accounts = make([]tracetracking.SignedAPIClient, fundedAccountsCount)

initialCoinAmount := tlb.FromNanoTON(initialAmount)
recipients := make([]*address.Address, fundedAccountsCount)
amounts := make([]tlb.Coins, fundedAccountsCount)

accounts = make([]tracetracking.SignedAPIClient, fundedAccountsCount)
for i := range fundedAccountsCount {
accounts[i] = createAndFundWallet(t, api, funder, initialCoinAmount)
w := testutils.CreateRandomTonWallet(t, api, wallet.V3R2, wallet.WithWorkchain(0))
recipients[i] = w.Address()
amounts[i] = tlb.FromNanoTON(initialAmount)

accounts[i] = tracetracking.NewSignedAPIClient(api, *w)
}

testutils.FundTonWallets(t, api, recipients, amounts)

return accounts
}

Expand All @@ -54,18 +53,6 @@ func GetRandomWallet(client ton.APIClientWrapped, version wallet.Version, option
return pw, nil
}

func createAndFundWallet(t *testing.T, api *ton.APIClient, funder tracetracking.SignedAPIClient, initialCoinAmount tlb.Coins) tracetracking.SignedAPIClient {
aliceWallet, err := GetRandomWallet(api, wallet.V3R2, wallet.WithWorkchain(0))
require.NoError(t, err, "failed to create new wallet: %w", err)
transferToAlice, err := funder.Wallet.BuildTransfer(aliceWallet.WalletAddress(), initialCoinAmount, false, "deposit")
require.NoError(t, err, "failed to build transfer: %w", err)
result, err := funder.SendAndWaitForTrace(context.TODO(), *aliceWallet.WalletAddress(), transferToAlice)
require.NoError(t, err, "failed to send transaction: %w", err)
require.True(t, result.Success && !result.Bounced, "Transaction failed")
alice := tracetracking.NewSignedAPIClient(api, *aliceWallet)
return alice
}

func GetWalletSeqno(apiClient tracetracking.SignedAPIClient) (uint, error) {
return UintFrom(Get(apiClient, "seqno"))
}
Expand All @@ -92,43 +79,6 @@ func UintFrom(res *ton.ExecutionResult, err error) (uint, error) {
return uint(val.Int64()), nil //nolint:gosec // test purpose
}

func getWallet(t *testing.T, api ton.APIClientWrapped) *wallet.Wallet {
// Load .env file from the project root
repoRoot := testutils.GetRepoRootDir()
err := godotenv.Load(path.Join(repoRoot, "integration-tests/tracetracking/.env"))
if err != nil {
// It's okay if the .env file doesn't exist in some environments
// so we'll just log it instead of failing
t.Logf("Warning: Error loading .env file: %s", err)
}
// Get seed phrase from environment variable
seedPhrase := os.Getenv("SIGNER_WALLET_SEED_PHRASE")
require.NotEmpty(t, seedPhrase, "Environment variable SIGNER_WALLET_SEED_PHRASE not set or empty")

words := strings.Fields(seedPhrase)

// Create wallet from seed with password
w, err := wallet.FromSeed(api, words, wallet.V3R2)
require.NoError(t, err, "failed to create wallet from seed: %w", err)

baseFunderWallet, err := wallet.FromPrivateKeyWithOptions(api, w.PrivateKey(), wallet.V3R2, wallet.WithWorkchain(-1))
require.NoError(t, err, "failed to create base funder wallet: %w", err)

//TODO: This is hardcoded for MyLocalTon pre-funded wallet
funderWallet, err := baseFunderWallet.GetSubwallet(42)
require.NoError(t, err, "failed to get subwallet: %w", err)
t.Logf("Funder wallet address: %s", funderWallet.WalletAddress().StringRaw())

// Check Funder Balance
masterInfo, err := api.GetMasterchainInfo(context.Background())
require.NoError(t, err, "failed to get masterchain info for funder balance check: %w", err)
funderBalance, err := funderWallet.GetBalance(context.Background(), masterInfo)
require.NoError(t, err, "failed to get funder balance: %w", err)
t.Logf("Funder balance: %s", funderBalance.String())

return funderWallet
}

// returns balance of the account in nanotons
func GetBalance(apiClient tracetracking.SignedAPIClient) (*big.Int, error) {
ctx := apiClient.Client.Client().StickyContext(context.Background())
Expand All @@ -151,7 +101,7 @@ func GetBalance(apiClient tracetracking.SignedAPIClient) (*big.Int, error) {

func VerifyTransaction(t *testing.T, m *tracetracking.ReceivedMessage, initialBalance *big.Int, expectedNetTransfer *big.Int, finalBalance *big.Int) {
expectedBalance := big.NewInt(0).Sub(tracetracking.Sum(initialBalance, m.NetCreditResult()), tracetracking.Sum(m.StorageFeeCharged, m.TotalTransactionExecutionFee()))
fmt.Printf(`================
t.Logf(`================
Transaction summary
────────────────────────────────────
Fees:
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/txm/txm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestTxmLocal(t *testing.T) {
require.NotNil(t, nodeClient)
logger.Debugw("Started MyLocalTON")

wallet := test_utils.CreateTonWallet(t, nodeClient, config.WalletVersion, wallet.WithWorkchain(0))
wallet := test_utils.CreateRandomTonWallet(t, nodeClient, config.WalletVersion, wallet.WithWorkchain(0))
require.NotNil(t, wallet)
logger.Debugw("Created TON Wallet")

Expand Down
16 changes: 12 additions & 4 deletions integration-tests/utils/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

var once = &sync.Once{}

func CreateTonWallet(t *testing.T, client ton.APIClientWrapped, version wallet.VersionConfig, option wallet.Option) *wallet.Wallet {
func CreateRandomTonWallet(t *testing.T, client ton.APIClientWrapped, version wallet.VersionConfig, option wallet.Option) *wallet.Wallet {
seed := wallet.NewSeed()
rw, err := wallet.FromSeed(client, seed, version)
require.NoError(t, err, "failed to generate random wallet: %w", err)
Expand Down Expand Up @@ -154,16 +154,24 @@ func CreateAPIClient(t *testing.T, chainID uint64) *ton.APIClient {
bcInput := &blockchain.Input{
ChainID: strconv.FormatUint(chainID, 10),
Type: "ton",
Image: "ghcr.io/neodix42/mylocalton-docker:latest",
Port: strconv.Itoa(port),
CustomEnv: map[string]string{
"VERSION_CAPABILITIES": "11",
"NEXT_BLOCK_GENERATION_DELAY": "0.5",
},
}

bcOut, err := blockchain.NewBlockchainNetwork(bcInput)
require.NoError(t, err, "failed to create blockchain network")

t.Cleanup(func() {
ctfErr := framework.RemoveTestContainers()
require.NoError(t, ctfErr, "failed to remove test containers")
if bcOut.Container != nil && bcOut.Container.IsRunning() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
if cterr := bcOut.Container.Terminate(ctx); cterr != nil {
t.Logf("Container termination failed: %v", cterr)
}
}
freeport.Return([]int{port})
})

Expand Down
Loading