Skip to content

Commit ea5219b

Browse files
committed
feat: add liveness check for nodes in e2e tests and update node startup parameters
1 parent 015cb76 commit ea5219b

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

test/e2e/base_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,22 @@ func TestBasic(t *testing.T) {
6565
require.NoError(t, err, "failed to init aggregator", output)
6666

6767
// start aggregator
68+
node1P2P := "/ip4/0.0.0.0/tcp/26656"
6869
sut.ExecCmd(binaryPath,
6970
"start",
7071
"--home="+node1Home,
7172
"--evnode.node.aggregator",
7273
"--evnode.signer.passphrase_file="+passphraseFile,
7374
"--evnode.node.block_time=5ms",
7475
"--evnode.da.block_time=15ms",
76+
"--evnode.p2p.listen_address="+node1P2P,
7577
"--kv-endpoint=127.0.0.1:9090",
7678
)
7779

7880
sut.AwaitNodeUp(t, "http://127.0.0.1:7331", 2*time.Second)
7981

8082
// Give aggregator more time before starting the next node
81-
time.Sleep(1 * time.Second) // Increased wait time
83+
time.Sleep(2 * time.Second)
8284

8385
// Init the second node (full node)
8486
output, err = sut.RunCmd(binaryPath,
@@ -91,7 +93,7 @@ func TestBasic(t *testing.T) {
9193
// Copy genesis file from aggregator to full node
9294
MustCopyFile(t, filepath.Join(node1Home, "config", "genesis.json"), filepath.Join(node2Home, "config", "genesis.json"))
9395

94-
// Start the full node
96+
// Start the full node - will discover aggregator via DHT
9597
node2RPC := "127.0.0.1:7332"
9698
node2P2P := "/ip4/0.0.0.0/tcp/7676"
9799
sut.ExecCmd(
@@ -100,11 +102,13 @@ func TestBasic(t *testing.T) {
100102
"--home="+node2Home,
101103
"--evnode.log.level=debug",
102104
"--evnode.p2p.listen_address="+node2P2P,
105+
"--evnode.node.readiness_max_blocks_behind=100", // Allow more blocks behind during bootstrap
103106
fmt.Sprintf("--evnode.rpc.address=%s", node2RPC),
104107
)
105108

106-
sut.AwaitNodeUp(t, "http://"+node2RPC, 2*time.Second)
107-
t.Logf("Full node (node 2) is up.")
109+
// For local e2e tests, only check liveness (not full readiness with peers)
110+
sut.AwaitNodeLive(t, "http://"+node2RPC, 10*time.Second)
111+
t.Logf("Full node (node 2) is live.")
108112

109113
// when a client TX for state update is executed
110114
const myKey = "foo"

test/e2e/sut_helper.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ func (s *SystemUnderTest) AwaitNodeUp(t *testing.T, rpcAddr string, timeout time
115115
}, timeout, min(timeout/10, 200*time.Millisecond), "node is not up")
116116
}
117117

118+
// AwaitNodeLive waits until a node is alive (liveness check only).
119+
// This only verifies the process is alive and responsive, not that it's ready to serve traffic.
120+
// Use this for local tests where nodes may not have peers configured.
121+
func (s *SystemUnderTest) AwaitNodeLive(t *testing.T, rpcAddr string, timeout time.Duration) {
122+
t.Helper()
123+
t.Logf("Await node is live: %s", rpcAddr)
124+
ctx, done := context.WithTimeout(context.Background(), timeout)
125+
defer done()
126+
require.EventuallyWithT(t, func(t *assert.CollectT) {
127+
c := client.NewClient(rpcAddr)
128+
require.NotNil(t, c)
129+
130+
// Check liveness only: is the process alive?
131+
_, err := c.GetHealth(ctx)
132+
require.NoError(t, err, "liveness check failed")
133+
}, timeout, min(timeout/10, 200*time.Millisecond), "node is not live")
134+
}
135+
118136
// AwaitNBlocks waits until the node has produced at least `n` blocks.
119137
func (s *SystemUnderTest) AwaitNBlocks(t *testing.T, n uint64, rpcAddr string, timeout time.Duration) {
120138
t.Helper()

0 commit comments

Comments
 (0)