diff --git a/.github/workflows/relayer-build.yml b/.github/workflows/relayer-build.yml index d8a1d0e83..b41e548f7 100644 --- a/.github/workflows/relayer-build.yml +++ b/.github/workflows/relayer-build.yml @@ -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: diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 1a989178b..ecb82d0b8 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -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 ) @@ -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 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 8591b29e0..db44f5128 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -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= @@ -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= diff --git a/integration-tests/tracetracking/.env.example b/integration-tests/tracetracking/.env.example deleted file mode 100644 index d1350e6fd..000000000 --- a/integration-tests/tracetracking/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -# Default is a MyLocalTon already funded wallet -SIGNER_WALLET_SEED_PHRASE="viable model canvas decade neck soap turtle asthma bench crouch bicycle grief history envelope valid intact invest like offer urban adjust popular draft coral" diff --git a/integration-tests/tracetracking/.gitignore b/integration-tests/tracetracking/.gitignore deleted file mode 100644 index 4c49bd78f..000000000 --- a/integration-tests/tracetracking/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env diff --git a/integration-tests/tracetracking/integration_test.go b/integration-tests/tracetracking/integration_test.go index 6fdcd5529..e84e1be25 100644 --- a/integration-tests/tracetracking/integration_test.go +++ b/integration-tests/tracetracking/integration_test.go @@ -2,11 +2,17 @@ package tracetracking import ( "context" - "fmt" "math/big" "math/rand/v2" "testing" + chainsel "github.com/smartcontractkit/chain-selectors" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/xssnick/tonutils-go/address" + "github.com/xssnick/tonutils-go/tlb" + "integration-tests/tracetracking/async/wrappers/requestreply" "integration-tests/tracetracking/async/wrappers/requestreplywithtwodependencies" "integration-tests/tracetracking/async/wrappers/twomsgchain" @@ -14,14 +20,7 @@ import ( counter "integration-tests/tracetracking/counter/wrappers" "integration-tests/tracetracking/testutils" - chainsel "github.com/smartcontractkit/chain-selectors" - "github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/xssnick/tonutils-go/address" - "github.com/xssnick/tonutils-go/tlb" ) func TestIntegration(t *testing.T) { @@ -32,16 +31,16 @@ func TestIntegration(t *testing.T) { bob := accs[1] var transferAmount = big.NewInt(100) - fmt.Printf("\n\n\n\n\n\nTestStarted\n==========================\n") + t.Logf("\n\n\n\n\n\nTestStarted\n==========================\n") transfer, err := alice.Wallet.BuildTransfer(bob.Wallet.WalletAddress(), tlb.FromNanoTON(transferAmount), false, "deposit") require.NoError(t, err, "failed to build transfer: %w", err) externalMessageReceived, _, err := alice.SendWaitTransaction(context.TODO(), *bob.Wallet.WalletAddress(), transfer) require.NoError(t, err, "failed to send transaction: %w", err) - fmt.Printf("\n==========================\nreceivedMessage: %+v\n==========================\n", externalMessageReceived) + t.Logf("\n==========================\nreceivedMessage: %+v\n==========================\n", externalMessageReceived) rerr := externalMessageReceived.WaitForTrace(&bob) require.NoError(t, rerr, "failed to wait for trace: %w", rerr) - fmt.Printf("Transaction finalized\n") - fmt.Printf("\n==========================\nFinalized msg: %+v\n==========================\n", externalMessageReceived) + t.Logf("Transaction finalized\n") + t.Logf("\n==========================\nFinalized msg: %+v\n==========================\n", externalMessageReceived) aliceBalance := testutils.MustGetBalance(t, alice) testutils.VerifyTransaction(t, externalMessageReceived, initialAmount, big.NewInt(0).Neg(transferAmount), aliceBalance) @@ -53,26 +52,25 @@ func TestIntegration(t *testing.T) { }) t.Run("TestCounter", func(t *testing.T) { - t.Skip("mylocalton doesn't work with tolk 1.0 yet") alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") - fmt.Printf("Deploying Counter contract\n") + t.Logf("Deploying Counter contract\n") counter, err := counter.NewCounterProvider(alice).Deploy(counter.CounterInitData{ID: (rand.Uint32()), Value: 100}) require.NoError(t, err, "failed to deploy Counter contract: %w", err) - fmt.Printf("Counter contract deployed at %s\n", counter.Contract.Address.String()) + t.Logf("Counter contract deployed at %s\n", counter.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") - fmt.Printf("Checking initial value\n") + t.Logf("Checking initial value\n") result, err := counter.GetValue() require.NoError(t, err, "failed to get initial value: %w", err) expectedValue := uint32(100) require.Equal(t, expectedValue, result, "Expected initial value %d, got %d", expectedValue, result) - fmt.Printf("Initial value: %d\n", result) + t.Logf("Initial value: %d\n", result) - fmt.Printf("Sending SetCount request\n") + t.Logf("Sending SetCount request\n") msgReceived, err := counter.SendSetCount(1) require.NoError(t, err, "failed to send SetCount request: %w", err) require.Equal(t, tvm.ExitCodeSuccess, msgReceived.ExitCode, "Expected exit code 0, got %d", msgReceived.ExitCode) @@ -80,23 +78,23 @@ func TestIntegration(t *testing.T) { require.Equal(t, 1, outgoingCount, "Expected 1 outgoing internal received message, got %d", outgoingCount) internalExitCode := msgReceived.OutgoingInternalReceivedMessages[0].ExitCode require.Equal(t, tvm.ExitCodeSuccess, internalExitCode, "Expected exit code 0, got %d", internalExitCode) - fmt.Printf("msgReceived: %+v\n", msgReceived) - fmt.Printf("SetCount request sent\n") + t.Logf("msgReceived: %+v\n", msgReceived) + t.Logf("SetCount request sent\n") - fmt.Printf("Checking result\n") + t.Logf("Checking result\n") result, err = counter.GetValue() require.NoError(t, err, "failed to get value: %w", err) expectedValue = uint32(1) require.Equal(t, expectedValue, result, "Expected value %d, got %d", expectedValue, result) - fmt.Printf("Result: %d\n", result) + t.Logf("Result: %d\n", result) - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) t.Run("TestRequestReply", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") priceIndex := []string{ "apple", @@ -108,49 +106,49 @@ func TestIntegration(t *testing.T) { } itemAddresses := make([]*address.Address, len(priceIndex)) - fmt.Printf("Deploying ItemPrice contracts\n") + t.Logf("Deploying ItemPrice contracts\n") for index, name := range priceIndex { - fmt.Printf("Deploying ItemPrice %s", name) + t.Logf("Deploying ItemPrice %s", name) itemPrice, err := requestreply.NewItemPriceProvider(alice).Deploy(requestreply.ItemPriceInitData{ID: (rand.Uint32()), Price: prices[name]}) require.NoError(t, err, "failed to deploy ItemPrice contract: %w", err) - fmt.Printf("ItemPrice contract deployed at %s\n", itemPrice.Contract.Address.String()) + t.Logf("ItemPrice contract deployed at %s\n", itemPrice.Contract.Address.String()) itemAddresses[index] = itemPrice.Contract.Address } - fmt.Printf("Deploying PriceRegistry contract with addresses %+v: \n", itemAddresses) + t.Logf("Deploying PriceRegistry contract with addresses %+v: \n", itemAddresses) priceRegistry, err := requestreply.NewPriceRegistryProvider(alice).Deploy(requestreply.PriceRegistryInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy PriceRegistry contract: %w", err) - fmt.Printf("PriceRegistry contract deployed at %s\n", priceRegistry.Contract.Address.String()) + t.Logf("PriceRegistry contract deployed at %s\n", priceRegistry.Contract.Address.String()) for index, name := range priceIndex { - fmt.Printf("Sending AddPriceItem request for %s, key: %d, addr: %s\n", name, index, itemAddresses[index].String()) + t.Logf("Sending AddPriceItem request for %s, key: %d, addr: %s\n", name, index, itemAddresses[index].String()) _, serr := priceRegistry.SendAddPriceItem(uint8(index), itemAddresses[index]) //nolint:gosec // testing purpose require.NoError(t, serr, "failed to send AddPriceItem request: %w", serr) - fmt.Printf("AddPriceItem request sent\n") + t.Logf("AddPriceItem request sent\n") } - fmt.Printf("Deploying Storage contract\n") + t.Logf("Deploying Storage contract\n") storage, err := requestreply.NewStorageProvider(alice).Deploy(requestreply.StorageInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy Storage contract: %w", err) - fmt.Printf("Storage contract deployed at %s\n", storage.Contract.Address.String()) + t.Logf("Storage contract deployed at %s\n", storage.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") for index, name := range priceIndex { - fmt.Printf("Sending GetPrice request for %s\n", name) + t.Logf("Sending GetPrice request for %s\n", name) _, err = storage.SendGetPriceFrom(priceRegistry.Contract.Address, uint8(index)) //nolint:gosec // testing purpose require.NoError(t, err, "failed to send GetPriceFrom request: %w", err) - fmt.Printf("GetPriceFrom request sent\n") + t.Logf("GetPriceFrom request sent\n") - fmt.Printf("Checking result\n") + t.Logf("Checking result\n") result, err := storage.GetValue() require.NoError(t, err, "failed to get value: %w", err) expectedPrice := prices[name] assert.Equal(t, expectedPrice, result, "Expected price %d, got %d", expectedPrice, result) - fmt.Printf("Result: %d\n", result) + t.Logf("Result: %d\n", result) } - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) type Item struct { @@ -161,7 +159,7 @@ func TestIntegration(t *testing.T) { t.Run("TestRequestReplyWithTwoDependencies", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") priceIndex := []string{ "apple", @@ -177,76 +175,76 @@ func TestIntegration(t *testing.T) { } itemAddresses := make([]Item, len(priceIndex)) - fmt.Printf("Deploying ItemPrice and ItemCount contracts\n") + t.Logf("Deploying ItemPrice and ItemCount contracts\n") for index, name := range priceIndex { - fmt.Printf("Deploying ItemPrice %s", name) + t.Logf("Deploying ItemPrice %s", name) itemPrice, err := requestreplywithtwodependencies.NewItemPriceProvider(alice).Deploy(requestreplywithtwodependencies.ItemPriceInitData{ID: (rand.Uint32()), Price: prices[name]}) require.NoError(t, err, "failed to deploy ItemPrice contract: %w", err) - fmt.Printf("ItemPrice contract deployed at %s\n", itemPrice.Contract.Address.String()) + t.Logf("ItemPrice contract deployed at %s\n", itemPrice.Contract.Address.String()) - fmt.Printf("Deploying ItemCount %s", name) + t.Logf("Deploying ItemCount %s", name) itemCount, err := requestreplywithtwodependencies.NewItemCountProvider(alice).Deploy(requestreplywithtwodependencies.ItemCountInitData{ID: (rand.Uint32()), Count: quantity[name]}) require.NoError(t, err, "failed to deploy ItemCount contract: %w", err) - fmt.Printf("ItemCount contract deployed at %s\n", itemCount.Contract.Address.String()) + t.Logf("ItemCount contract deployed at %s\n", itemCount.Contract.Address.String()) itemAddresses[index] = Item{itemPrice.Contract.Address, itemCount.Contract.Address} } - fmt.Printf("Deploying Inventory contract with addresses %+v: \n", itemAddresses) + t.Logf("Deploying Inventory contract with addresses %+v: \n", itemAddresses) inventory, err := requestreplywithtwodependencies.NewInventoryProvider(alice).Deploy(requestreplywithtwodependencies.InventoryInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy Inventory contract: %w", err) - fmt.Printf("Inventory contract deployed at %s\n", inventory.Contract.Address.String()) + t.Logf("Inventory contract deployed at %s\n", inventory.Contract.Address.String()) for index, name := range priceIndex { - fmt.Printf("Sending AddItem request for %s, key: %d, priceAddr: %s, countAddr: %s\n", name, index, itemAddresses[index].PriceAddr.String(), itemAddresses[index].CountAddr.String()) + t.Logf("Sending AddItem request for %s, key: %d, priceAddr: %s, countAddr: %s\n", name, index, itemAddresses[index].PriceAddr.String(), itemAddresses[index].CountAddr.String()) _, serr := inventory.SendAddItem(uint8(index), itemAddresses[index].PriceAddr, itemAddresses[index].CountAddr) //nolint:gosec // testing purpose require.NoError(t, serr, "failed to send AddItem request: %w", serr) - fmt.Printf("AddItem request sent\n") + t.Logf("AddItem request sent\n") } - fmt.Printf("Deploying Storage contract\n") + t.Logf("Deploying Storage contract\n") storage, err := requestreplywithtwodependencies.NewStorageProvider(alice).Deploy(requestreplywithtwodependencies.StorageInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy Storage contract: %w", err) - fmt.Printf("Storage contract deployed at %s\n", storage.Contract.Address.String()) + t.Logf("Storage contract deployed at %s\n", storage.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") for index, name := range priceIndex { - fmt.Printf("Sending GetCapitalFrom request for %s\n", name) + t.Logf("Sending GetCapitalFrom request for %s\n", name) _, err = storage.SendGetCapitalFrom(inventory.Contract.Address, uint8(index)) //nolint:gosec // testing purpose require.NoError(t, err, "failed to send GetCapitalFrom request: %w", err) - fmt.Printf("GetCapitalFrom request sent\n") + t.Logf("GetCapitalFrom request sent\n") - fmt.Printf("Checking result\n") + t.Logf("Checking result\n") result, err := storage.GetValue() require.NoError(t, err, "failed to get value: %w", err) expectedCapital := prices[name] * quantity[name] assert.Equal(t, expectedCapital, result, "Expected capital %d, got %d", expectedCapital, result) - fmt.Printf("Result: %d\n", result) + t.Logf("Result: %d\n", result) } - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) t.Run("TestMemoryContract", func(t *testing.T) { alice := accs[0] const initValue = uint32(0) - fmt.Printf("\n\n\n\n\n\nTestStarted\n==========================\n") - fmt.Printf("Deploying memory contract with initial value %d\n", initValue) + t.Logf("\n\n\n\n\n\nTestStarted\n==========================\n") + t.Logf("Deploying memory contract with initial value %d\n", initValue) memoryContract, err := twomsgchain.NewMemoryProvider(alice).Deploy(twomsgchain.MemoryInitData{ID: rand.Uint32()}) require.NoError(t, err, "failed to deploy memory contract: %w", err) - fmt.Printf("Memory contract deployed at %s\n", memoryContract.Contract.Address.String()) - fmt.Printf("Checking if memory contract is deployed\n") + t.Logf("Memory contract deployed at %s\n", memoryContract.Contract.Address.String()) + t.Logf("Checking if memory contract is deployed\n") initValueReturned, err := memoryContract.GetValue() require.NoError(t, err, "failed to get value: %w", err) - fmt.Printf("Initial value in memory contract is %d\n", initValueReturned) + t.Logf("Initial value in memory contract is %d\n", initValueReturned) assert.Equal(t, initValue, initValueReturned, "Initial value should be %d", initValue) - fmt.Printf("Storing value %d in memory contract\n", initValue) + t.Logf("Storing value %d in memory contract\n", initValue) const valueToStore = uint32(2) msgRec, err := memoryContract.SendSetValue(valueToStore) require.NoError(t, err, "failed to store value: %w", err) _ = msgRec - fmt.Printf("Checking if value is stored in memory contract\n") + t.Logf("Checking if value is stored in memory contract\n") recordedValue, err := memoryContract.GetValue() require.NoError(t, err, "failed to get value: %w", err) assert.Equal(t, valueToStore, recordedValue, "Stored value should be %d", valueToStore) @@ -254,31 +252,31 @@ func TestIntegration(t *testing.T) { t.Run("TestTwoMsgChain", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTestStarted\n==========================\n") + t.Logf("\n\n\n\n\n\nTestStarted\n==========================\n") const initValue = uint32(0) - fmt.Printf("Deploying memory contract with initial value %d\n", initValue) + t.Logf("Deploying memory contract with initial value %d\n", initValue) memoryContract, err := twomsgchain.NewMemoryProvider(alice).Deploy(twomsgchain.MemoryInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy memory contract: %w", err) - fmt.Printf("Memory contract deployed at %s\n", memoryContract.Contract.Address.String()) + t.Logf("Memory contract deployed at %s\n", memoryContract.Contract.Address.String()) - fmt.Printf("Deploying storage contract with memory address %s\n", memoryContract.Contract.Address.String()) + t.Logf("Deploying storage contract with memory address %s\n", memoryContract.Contract.Address.String()) storageContract, err := twomsgchain.NewStorageProvider(alice).Deploy(twomsgchain.StorageInitData{ID: (rand.Uint32()), MemoryAddress: memoryContract.Contract.Address}) require.NoError(t, err, "failed to deploy storage contract: %w", err) - fmt.Printf("Storage contract deployed at %s\n", storageContract.Contract.Address.String()) + t.Logf("Storage contract deployed at %s\n", storageContract.Contract.Address.String()) - fmt.Printf("Checking if memory contract is deployed\n") + t.Logf("Checking if memory contract is deployed\n") initValueReturned, err := memoryContract.GetValue() require.NoError(t, err, "failed to get value: %w", err) - fmt.Printf("Initial value in memory contract is %d\n", initValueReturned) + t.Logf("Initial value in memory contract is %d\n", initValueReturned) assert.Equal(t, initValue, initValueReturned, "Initial value should be %d", initValue) const valueToStore = uint32(2) - fmt.Printf("Storing value %d in storage contract\n", valueToStore) + t.Logf("Storing value %d in storage contract\n", valueToStore) msgRec, err := storageContract.SendStore(valueToStore) require.NoError(t, err, "failed to store value: %w", err) _ = msgRec - fmt.Printf("Checking if value is stored in memory contract\n") + t.Logf("Checking if value is stored in memory contract\n") recordedValue, err := memoryContract.GetValue() require.NoError(t, err, "failed to get value: %w", err) assert.Equal(t, valueToStore, recordedValue, "Stored value should be %d", valueToStore) @@ -287,48 +285,48 @@ func TestIntegration(t *testing.T) { t.Run("AutoAck", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") const initValue = uint32(0) counterProvider := twophasecommit.NewCounterProvider(alice) - fmt.Printf("Deploying counter A with initial value %d\n", initValue) + t.Logf("Deploying counter A with initial value %d\n", initValue) counterA, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: true}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter A deployed at %s\n", counterA.Contract.Address.String()) + t.Logf("Counter A deployed at %s\n", counterA.Contract.Address.String()) - fmt.Printf("Deploying counter B with initial value %d\n", initValue) + t.Logf("Deploying counter B with initial value %d\n", initValue) counterB, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: true}) require.NoError(t, err, "failed to deploy counter B contract: %w", err) - fmt.Printf("Counter B deployed at %s\n", counterB.Contract.Address.String()) + t.Logf("Counter B deployed at %s\n", counterB.Contract.Address.String()) - fmt.Printf("Deploying DB contract\n") + t.Logf("Deploying DB contract\n") dbContract, err := twophasecommit.NewDBProvider(alice).Deploy(twophasecommit.DBInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy DB contract: %w", err) - fmt.Printf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) + t.Logf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") const valueForCounterA = uint32(1) const valueForCounterB = uint32(2) - fmt.Printf("Beginning transaction\n") + t.Logf("Beginning transaction\n") txID := rand.Uint64() _, err = dbContract.SendBeginTransaction(txID) require.NoError(t, err, "failed to begin transaction: %w", err) - fmt.Printf("Transaction started with ID %d\n", txID) + t.Logf("Transaction started with ID %d\n", txID) - fmt.Printf("Setting value in counter A to %d\n", valueForCounterA) + t.Logf("Setting value in counter A to %d\n", valueForCounterA) _, err = dbContract.SendSetValue(counterA.Contract.Address, valueForCounterA) require.NoError(t, err, "failed to set value in counter A: %w", err) - fmt.Printf("Setting value in counter B to %d\n", valueForCounterB) + t.Logf("Setting value in counter B to %d\n", valueForCounterB) _, err = dbContract.SendSetValue(counterB.Contract.Address, valueForCounterB) require.NoError(t, err, "failed to set value in counter B: %w", err) - fmt.Printf("Committing transaction\n") + t.Logf("Committing transaction\n") _, err = dbContract.SendCommit() require.NoError(t, err, "failed to commit transaction: %w", err) - fmt.Printf("Transaction committed\n") + t.Logf("Transaction committed\n") - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err := counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, valueForCounterA, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -336,57 +334,57 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, valueForCounterB, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) t.Run("AcksBeforeCommit", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") const initValue = uint32(0) counterProvider := twophasecommit.NewCounterProvider(alice) - fmt.Printf("Deploying counter A with initial value %d\n", initValue) + t.Logf("Deploying counter A with initial value %d\n", initValue) counterA, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter A deployed at %s\n", counterA.Contract.Address.String()) + t.Logf("Counter A deployed at %s\n", counterA.Contract.Address.String()) - fmt.Printf("Deploying counter B with initial value %d\n", initValue) + t.Logf("Deploying counter B with initial value %d\n", initValue) counterB, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter B deployed at %s\n", counterB.Contract.Address.String()) + t.Logf("Counter B deployed at %s\n", counterB.Contract.Address.String()) - fmt.Printf("Deploying DB contract\n") + t.Logf("Deploying DB contract\n") dbContract, err := twophasecommit.NewDBProvider(alice).Deploy(twophasecommit.DBInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy DB contract: %w", err) - fmt.Printf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) + t.Logf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") const valueForCounterA = uint32(1) const valueForCounterB = uint32(2) - fmt.Printf("Beginning transaction\n") + t.Logf("Beginning transaction\n") txID := rand.Uint64() _, err = dbContract.SendBeginTransaction(txID) require.NoError(t, err, "failed to begin transaction: %w", err) - fmt.Printf("Transaction started with ID %d\n", txID) + t.Logf("Transaction started with ID %d\n", txID) - fmt.Printf("Setting value in counter A to %d\n", valueForCounterA) + t.Logf("Setting value in counter A to %d\n", valueForCounterA) _, err = dbContract.SendSetValue(counterA.Contract.Address, valueForCounterA) require.NoError(t, err, "failed to set value in counter A: %w", err) - fmt.Printf("Sending ack to counter A\n") + t.Logf("Sending ack to counter A\n") _, err = counterA.SendAck() require.NoError(t, err, "failed to send ack to counter A: %w", err) - fmt.Printf("Setting value in counter B to %d\n", valueForCounterB) + t.Logf("Setting value in counter B to %d\n", valueForCounterB) _, err = dbContract.SendSetValue(counterB.Contract.Address, valueForCounterB) require.NoError(t, err, "failed to set value in counter B: %w", err) - fmt.Printf("Sending ack to counter B\n") + t.Logf("Sending ack to counter B\n") _, err = counterB.SendAck() require.NoError(t, err, "failed to send ack to counter B: %w", err) - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err := counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, initValue, valueA, "Counter A value mismatch: expected %d, got %d", initValue, valueA) @@ -394,12 +392,12 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, initValue, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Committing transaction\n") + t.Logf("Committing transaction\n") _, err = dbContract.SendCommit() require.NoError(t, err, "failed to commit transaction: %w", err) - fmt.Printf("Transaction committed\n") + t.Logf("Transaction committed\n") - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err = counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, valueForCounterA, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -407,58 +405,58 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, valueForCounterB, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) t.Run("AcksAfterCommit", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") const initValue = uint32(0) counterProvider := twophasecommit.NewCounterProvider(alice) - fmt.Printf("Deploying counter A with initial value %d\n", initValue) + t.Logf("Deploying counter A with initial value %d\n", initValue) counterA, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter A deployed at %s\n", counterA.Contract.Address.String()) + t.Logf("Counter A deployed at %s\n", counterA.Contract.Address.String()) - fmt.Printf("Deploying counter B with initial value %d\n", initValue) + t.Logf("Deploying counter B with initial value %d\n", initValue) counterB, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter B deployed at %s\n", counterB.Contract.Address.String()) + t.Logf("Counter B deployed at %s\n", counterB.Contract.Address.String()) - fmt.Printf("Deploying DB contract\n") + t.Logf("Deploying DB contract\n") dbContract, err := twophasecommit.NewDBProvider(alice).Deploy(twophasecommit.DBInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy DB contract: %w", err) - fmt.Printf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) + t.Logf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") const valueForCounterA = uint32(1) const valueForCounterB = uint32(2) - fmt.Printf("Beginning transaction\n") + t.Logf("Beginning transaction\n") txID := rand.Uint64() _, err = dbContract.SendBeginTransaction(txID) require.NoError(t, err, "failed to begin transaction: %w", err) - fmt.Printf("Transaction started with ID %d\n", txID) + t.Logf("Transaction started with ID %d\n", txID) - fmt.Printf("Setting value in counter A to %d\n", valueForCounterA) + t.Logf("Setting value in counter A to %d\n", valueForCounterA) _, err = dbContract.SendSetValue(counterA.Contract.Address, valueForCounterA) require.NoError(t, err, "failed to set value in counter A: %w", err) - fmt.Printf("Setting value in counter B to %d\n", valueForCounterB) + t.Logf("Setting value in counter B to %d\n", valueForCounterB) _, err = dbContract.SendSetValue(counterB.Contract.Address, valueForCounterB) require.NoError(t, err, "failed to set value in counter B: %w", err) - fmt.Printf("Committing transaction\n") + t.Logf("Committing transaction\n") _, err = dbContract.SendCommit() require.NoError(t, err, "failed to commit transaction: %w", err) - fmt.Printf("Transaction committed\n") + t.Logf("Transaction committed\n") - fmt.Printf("Sending ack to counter A\n") + t.Logf("Sending ack to counter A\n") _, err = counterA.SendAck() require.NoError(t, err, "failed to send ack to counter A: %w", err) - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err := counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, initValue, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -466,11 +464,11 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, initValue, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Sending ack to counter B\n") + t.Logf("Sending ack to counter B\n") _, err = counterB.SendAck() require.NoError(t, err, "failed to send ack to counter B: %w", err) - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err = counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, valueForCounterA, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -478,58 +476,58 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, valueForCounterB, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) t.Run("OneAckAfterCommit", func(t *testing.T) { alice := accs[0] - fmt.Printf("\n\n\n\n\n\nTest Setup\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Setup\n==========================\n") const initValue = uint32(0) counterProvider := twophasecommit.NewCounterProvider(alice) - fmt.Printf("Deploying counter A with initial value %d\n", initValue) + t.Logf("Deploying counter A with initial value %d\n", initValue) counterA, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter A deployed at %s\n", counterA.Contract.Address.String()) + t.Logf("Counter A deployed at %s\n", counterA.Contract.Address.String()) - fmt.Printf("Deploying counter B with initial value %d\n", initValue) + t.Logf("Deploying counter B with initial value %d\n", initValue) counterB, err := counterProvider.Deploy(twophasecommit.CounterInitData{ID: (rand.Uint32()), Value: initValue, AutoAck: false}) require.NoError(t, err, "failed to deploy counter A contract: %w", err) - fmt.Printf("Counter B deployed at %s\n", counterB.Contract.Address.String()) + t.Logf("Counter B deployed at %s\n", counterB.Contract.Address.String()) - fmt.Printf("Deploying DB contract\n") + t.Logf("Deploying DB contract\n") dbContract, err := twophasecommit.NewDBProvider(alice).Deploy(twophasecommit.DBInitData{ID: (rand.Uint32())}) require.NoError(t, err, "failed to deploy DB contract: %w", err) - fmt.Printf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) + t.Logf("DB contract deployed at %s\n", dbContract.Contract.Address.String()) - fmt.Printf("\n\n\n\n\n\nTest Started\n==========================\n") + t.Logf("\n\n\n\n\n\nTest Started\n==========================\n") const valueForCounterA = uint32(1) const valueForCounterB = uint32(2) - fmt.Printf("Beginning transaction\n") + t.Logf("Beginning transaction\n") txID := rand.Uint64() _, err = dbContract.SendBeginTransaction(txID) require.NoError(t, err, "failed to begin transaction: %w", err) - fmt.Printf("Transaction started with ID %d\n", txID) + t.Logf("Transaction started with ID %d\n", txID) - fmt.Printf("Setting value in counter A to %d\n", valueForCounterA) + t.Logf("Setting value in counter A to %d\n", valueForCounterA) _, err = dbContract.SendSetValue(counterA.Contract.Address, valueForCounterA) require.NoError(t, err, "failed to set value in counter A: %w", err) - fmt.Printf("Setting value in counter B to %d\n", valueForCounterB) + t.Logf("Setting value in counter B to %d\n", valueForCounterB) _, err = dbContract.SendSetValue(counterB.Contract.Address, valueForCounterB) require.NoError(t, err, "failed to set value in counter B: %w", err) - fmt.Printf("Sending ack to counter A\n") + t.Logf("Sending ack to counter A\n") _, err = counterA.SendAck() require.NoError(t, err, "failed to send ack to counter A: %w", err) - fmt.Printf("Committing transaction\n") + t.Logf("Committing transaction\n") _, err = dbContract.SendCommit() require.NoError(t, err, "failed to commit transaction: %w", err) - fmt.Printf("Transaction committed\n") + t.Logf("Transaction committed\n") - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err := counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, initValue, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -537,11 +535,11 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, initValue, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Sending ack to counter B\n") + t.Logf("Sending ack to counter B\n") _, err = counterB.SendAck() require.NoError(t, err, "failed to send ack to counter B: %w", err) - fmt.Printf("Checking value in counters\n") + t.Logf("Checking value in counters\n") valueA, err = counterA.GetValue() require.NoError(t, err, "failed to get value from counter A: %w", err) assert.Equal(t, valueForCounterA, valueA, "Counter A value mismatch: expected %d, got %d", valueForCounterA, valueA) @@ -549,6 +547,6 @@ func TestIntegration(t *testing.T) { require.NoError(t, err, "failed to get value from counter B: %w", err) assert.Equal(t, valueForCounterB, valueB, "Counter B value mismatch: expected %d, got %d", valueForCounterB, valueB) - fmt.Printf("Test completed successfully\n") + t.Logf("Test completed successfully\n") }) } diff --git a/integration-tests/tracetracking/testutils/test_utils.go b/integration-tests/tracetracking/testutils/test_utils.go index c5877faf2..3317b2f12 100644 --- a/integration-tests/tracetracking/testutils/test_utils.go +++ b/integration-tests/tracetracking/testutils/test_utils.go @@ -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" @@ -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 } @@ -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")) } @@ -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()) @@ -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: diff --git a/integration-tests/txm/txm_test.go b/integration-tests/txm/txm_test.go index b450ccc36..94af9e540 100644 --- a/integration-tests/txm/txm_test.go +++ b/integration-tests/txm/txm_test.go @@ -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") diff --git a/integration-tests/utils/chain.go b/integration-tests/utils/chain.go index 02e56d9dc..3c5ffc6c4 100644 --- a/integration-tests/utils/chain.go +++ b/integration-tests/utils/chain.go @@ -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) @@ -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}) })