2023-11-03 14:25:27 +00:00
|
|
|
//go:build integration
|
|
|
|
|
2024-01-10 19:04:27 +00:00
|
|
|
package tests
|
2023-11-03 14:25:27 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-11-11 12:04:18 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2024-01-09 20:02:14 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2023-11-03 14:25:27 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/accounts"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/admin"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/contracts/steps"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/requests"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/services"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/transactions"
|
|
|
|
)
|
|
|
|
|
|
|
|
func testDynamicTx(t *testing.T, ctx context.Context) {
|
|
|
|
t.Run("InitSubscriptions", func(t *testing.T) {
|
|
|
|
services.InitSubscriptions(ctx, []requests.SubMethod{requests.Methods.ETHNewHeads})
|
|
|
|
})
|
|
|
|
t.Run("PingErigonRpc", func(t *testing.T) {
|
|
|
|
require.Nil(t, admin.PingErigonRpc(ctx))
|
|
|
|
})
|
|
|
|
t.Run("CheckTxPoolContent", func(t *testing.T) {
|
|
|
|
transactions.CheckTxPoolContent(ctx, 0, 0, 0)
|
|
|
|
})
|
|
|
|
t.Run("SendTxWithDynamicFee", func(t *testing.T) {
|
|
|
|
const recipientAddress = "0x71562b71999873DB5b286dF957af199Ec94617F7"
|
|
|
|
const sendValue uint64 = 10000
|
|
|
|
_, err := transactions.SendTxWithDynamicFee(ctx, recipientAddress, accounts.DevAddress, sendValue)
|
|
|
|
require.Nil(t, err)
|
|
|
|
})
|
|
|
|
t.Run("AwaitBlocks", func(t *testing.T) {
|
|
|
|
require.Nil(t, transactions.AwaitBlocks(ctx, 2*time.Second))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDynamicTxNode0(t *testing.T) {
|
2024-01-10 19:04:27 +00:00
|
|
|
runCtx, err := ContextStart(t, "")
|
2023-11-03 14:25:27 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
testDynamicTx(t, runCtx.WithCurrentNetwork(0).WithCurrentNode(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDynamicTxAnyNode(t *testing.T) {
|
2024-01-10 19:04:27 +00:00
|
|
|
runCtx, err := ContextStart(t, "")
|
2023-11-03 14:25:27 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
testDynamicTx(t, runCtx.WithCurrentNetwork(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCallContract(t *testing.T) {
|
2024-01-10 19:04:27 +00:00
|
|
|
runCtx, err := ContextStart(t, "")
|
2023-11-03 14:25:27 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
ctx := runCtx.WithCurrentNetwork(0)
|
|
|
|
|
|
|
|
t.Run("InitSubscriptions", func(t *testing.T) {
|
|
|
|
services.InitSubscriptions(ctx, []requests.SubMethod{requests.Methods.ETHNewHeads})
|
|
|
|
})
|
|
|
|
t.Run("DeployAndCallLogSubscriber", func(t *testing.T) {
|
|
|
|
_, err := contracts_steps.DeployAndCallLogSubscriber(ctx, accounts.DevAddress)
|
|
|
|
require.Nil(t, err)
|
|
|
|
})
|
|
|
|
}
|