Skip to content

Commit 4699290

Browse files
committed
fix: improve CI test stability with dynamic address discovery
- Replace hardcoded TestAddress with dynamic discovery via getTestAddress() - Add waitForValidators() and getValidatorsWithRetry() helpers for CI timing - Run integration tests sequentially (-p 1) to prevent sequence mismatches - Update 15 test files to use dynamic address resolution
1 parent 51c7bb4 commit 4699290

15 files changed

Lines changed: 260 additions & 89 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
run: ./sekai-cli scenario run examples/scenarios/ci-integration-test.yaml
129129

130130
- name: Run Go integration tests
131-
run: go test -v -timeout 30m ./test/integration/...
131+
run: go test -v -timeout 30m -p 1 ./test/integration/...
132132

133133
- name: Collect logs on failure
134134
if: failure()

test/integration/auth_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ import (
1111
// TestAuthAccount tests querying a single account by address.
1212
func TestAuthAccount(t *testing.T) {
1313
skipIfContainerNotRunning(t)
14+
testAddr := getTestAddress(t)
1415
client := getTestClient(t)
1516
defer client.Close()
1617

1718
ctx, cancel := getTestContext()
1819
defer cancel()
1920

2021
mod := auth.New(client)
21-
result, err := mod.Account(ctx, TestAddress)
22+
result, err := mod.Account(ctx, testAddr)
2223
requireNoError(t, err, "Failed to query account")
2324
requireNotNil(t, result, "Account is nil")
2425

2526
// Verify account has expected fields
26-
requireEqual(t, TestAddress, result.Address, "Address mismatch")
27+
requireEqual(t, testAddr, result.Address, "Address mismatch")
2728
requireTrue(t, result.AccountNumber != "", "Account number should not be empty")
2829

2930
t.Logf("Account: %s, Number: %s, Sequence: %s", result.Address, result.AccountNumber, result.Sequence)
@@ -32,6 +33,7 @@ func TestAuthAccount(t *testing.T) {
3233
// TestAuthAccounts tests querying all accounts.
3334
func TestAuthAccounts(t *testing.T) {
3435
skipIfContainerNotRunning(t)
36+
testAddr := getTestAddress(t)
3537
client := getTestClient(t)
3638
defer client.Close()
3739

@@ -51,7 +53,7 @@ func TestAuthAccounts(t *testing.T) {
5153
// Verify the test address is in the list
5254
found := false
5355
for _, acc := range result.Accounts {
54-
if acc.Address == TestAddress {
56+
if acc.Address == testAddr {
5557
found = true
5658
break
5759
}
@@ -62,6 +64,7 @@ func TestAuthAccounts(t *testing.T) {
6264
// TestAuthAddressByAccNum tests querying an address by account number.
6365
func TestAuthAddressByAccNum(t *testing.T) {
6466
skipIfContainerNotRunning(t)
67+
testAddr := getTestAddress(t)
6568
client := getTestClient(t)
6669
defer client.Close()
6770

@@ -71,7 +74,7 @@ func TestAuthAddressByAccNum(t *testing.T) {
7174
mod := auth.New(client)
7275

7376
// First get the account to know its account number
74-
acc, err := mod.Account(ctx, TestAddress)
77+
acc, err := mod.Account(ctx, testAddr)
7578
requireNoError(t, err, "Failed to query account")
7679
requireNotNil(t, acc, "Account is nil")
7780

@@ -80,7 +83,7 @@ func TestAuthAddressByAccNum(t *testing.T) {
8083
requireNoError(t, err, "Failed to query address by account number")
8184
requireNotNil(t, result, "Result is nil")
8285

83-
requireEqual(t, TestAddress, result.AccountAddress, "Address mismatch")
86+
requireEqual(t, testAddr, result.AccountAddress, "Address mismatch")
8487
t.Logf("Account number %s maps to address %s", acc.AccountNumber, result.AccountAddress)
8588
}
8689

test/integration/bank_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ import (
1313
// TestBankBalances tests querying all balances for an address.
1414
func TestBankBalances(t *testing.T) {
1515
skipIfContainerNotRunning(t)
16+
testAddr := getTestAddress(t)
1617
client := getTestClient(t)
1718
defer client.Close()
1819

1920
ctx, cancel := getTestContext()
2021
defer cancel()
2122

2223
mod := bank.New(client)
23-
result, err := mod.Balances(ctx, TestAddress)
24+
result, err := mod.Balances(ctx, testAddr)
2425
requireNoError(t, err, "Failed to query balances")
2526

26-
t.Logf("Address %s has %d token types", TestAddress, len(result))
27+
t.Logf("Address %s has %d token types", testAddr, len(result))
2728
for _, coin := range result {
2829
t.Logf(" %s: %s", coin.Denom, coin.Amount)
2930
}
@@ -32,35 +33,37 @@ func TestBankBalances(t *testing.T) {
3233
// TestBankBalance tests querying balance for a specific denom.
3334
func TestBankBalance(t *testing.T) {
3435
skipIfContainerNotRunning(t)
36+
testAddr := getTestAddress(t)
3537
client := getTestClient(t)
3638
defer client.Close()
3739

3840
ctx, cancel := getTestContext()
3941
defer cancel()
4042

4143
mod := bank.New(client)
42-
result, err := mod.Balance(ctx, TestAddress, "ukex")
44+
result, err := mod.Balance(ctx, testAddr, "ukex")
4345
requireNoError(t, err, "Failed to query balance")
4446
requireNotNil(t, result, "Balance is nil")
4547

4648
requireEqual(t, "ukex", result.Denom, "Denom mismatch")
47-
t.Logf("Address %s has %s ukex", TestAddress, result.Amount)
49+
t.Logf("Address %s has %s ukex", testAddr, result.Amount)
4850
}
4951

5052
// TestBankSpendableBalances tests querying spendable balances.
5153
func TestBankSpendableBalances(t *testing.T) {
5254
skipIfContainerNotRunning(t)
55+
testAddr := getTestAddress(t)
5356
client := getTestClient(t)
5457
defer client.Close()
5558

5659
ctx, cancel := getTestContext()
5760
defer cancel()
5861

5962
mod := bank.New(client)
60-
result, err := mod.SpendableBalances(ctx, TestAddress)
63+
result, err := mod.SpendableBalances(ctx, testAddr)
6164
requireNoError(t, err, "Failed to query spendable balances")
6265

63-
t.Logf("Address %s has %d spendable token types", TestAddress, len(result))
66+
t.Logf("Address %s has %d spendable token types", testAddr, len(result))
6467
for _, coin := range result {
6568
t.Logf(" %s: %s", coin.Denom, coin.Amount)
6669
}
@@ -154,7 +157,8 @@ func TestBankSend(t *testing.T) {
154157
t.Logf("Recipient address: %s", recipientAddr)
155158

156159
// Get initial balances
157-
senderBalanceBefore, err := bankMod.Balance(ctx, TestAddress, "ukex")
160+
testAddr := getTestAddress(t)
161+
senderBalanceBefore, err := bankMod.Balance(ctx, testAddr, "ukex")
158162
requireNoError(t, err, "Failed to query sender balance")
159163
t.Logf("Sender balance before: %s ukex", senderBalanceBefore.Amount)
160164

test/integration/basket_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ func TestBasketProposalWithdrawSurplus(t *testing.T) {
325325
Description: "Integration test - verify withdraw surplus proposal",
326326
}
327327

328-
resp, err := mod.ProposalWithdrawSurplus(ctx, TestKey, "1", TestAddress, propOpts, nil)
328+
testAddr := getTestAddress(t)
329+
resp, err := mod.ProposalWithdrawSurplus(ctx, TestKey, "1", testAddr, propOpts, nil)
329330
if err != nil {
330331
t.Logf("ProposalWithdrawSurplus may have failed (no basket): %v", err)
331332
return

test/integration/bridge_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import (
1010
// TestBridgeGetCosmosEthereum tests querying cosmos to ethereum changes.
1111
func TestBridgeGetCosmosEthereum(t *testing.T) {
1212
skipIfContainerNotRunning(t)
13+
testAddr := getTestAddress(t)
1314
client := getTestClient(t)
1415
defer client.Close()
1516

1617
ctx, cancel := getTestContext()
1718
defer cancel()
1819

1920
mod := bridge.New(client)
20-
result, err := mod.GetCosmosEthereum(ctx, TestAddress)
21+
result, err := mod.GetCosmosEthereum(ctx, testAddr)
2122
if err != nil {
2223
// This may fail if no bridge changes exist
2324
t.Logf("Cosmos to Ethereum query: %v (expected if no changes)", err)
@@ -30,14 +31,15 @@ func TestBridgeGetCosmosEthereum(t *testing.T) {
3031
// TestBridgeGetEthereumCosmos tests querying ethereum to cosmos changes.
3132
func TestBridgeGetEthereumCosmos(t *testing.T) {
3233
skipIfContainerNotRunning(t)
34+
testAddr := getTestAddress(t)
3335
client := getTestClient(t)
3436
defer client.Close()
3537

3638
ctx, cancel := getTestContext()
3739
defer cancel()
3840

3941
mod := bridge.New(client)
40-
result, err := mod.GetEthereumCosmos(ctx, TestAddress)
42+
result, err := mod.GetEthereumCosmos(ctx, testAddr)
4143
if err != nil {
4244
// This may fail if no bridge changes exist
4345
t.Logf("Ethereum to Cosmos query: %v (expected if no changes)", err)
@@ -59,7 +61,8 @@ func TestBridgeChangeCosmosEthereum(t *testing.T) {
5961
mod := bridge.New(client)
6062

6163
// Use test values
62-
cosmosAddress := TestAddress
64+
testAddr := getTestAddress(t)
65+
cosmosAddress := testAddr
6366
ethAddress := "0x1234567890123456789012345678901234567890"
6467
amount := "100ukex"
6568

@@ -88,7 +91,8 @@ func TestBridgeChangeEthereumCosmos(t *testing.T) {
8891
mod := bridge.New(client)
8992

9093
// Use test values
91-
cosmosAddress := TestAddress
94+
testAddr := getTestAddress(t)
95+
cosmosAddress := testAddr
9296
ethTxHash := "0x" + generateUniqueID("txhash")
9397
amount := "100ukex"
9498

test/integration/collectives_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ func TestCollectivesAll(t *testing.T) {
2626
// TestCollectivesByAccount tests querying collectives by account.
2727
func TestCollectivesByAccount(t *testing.T) {
2828
skipIfContainerNotRunning(t)
29+
testAddr := getTestAddress(t)
2930
client := getTestClient(t)
3031
defer client.Close()
3132

3233
ctx, cancel := getTestContext()
3334
defer cancel()
3435

3536
mod := collectives.New(client)
36-
result, err := mod.CollectivesByAccount(ctx, TestAddress)
37+
result, err := mod.CollectivesByAccount(ctx, testAddr)
3738
if err != nil {
3839
// This may fail if no collectives for this account
3940
t.Logf("Collectives by account query: %v (expected if no collectives)", err)
4041
return
4142
}
4243

43-
t.Logf("Collectives for %s: %s", TestAddress, string(result))
44+
t.Logf("Collectives for %s: %s", testAddr, string(result))
4445
}
4546

4647
// TestCollectivesProposals tests querying collectives proposals.
@@ -253,11 +254,12 @@ func TestCollectivesProposalSendDonation(t *testing.T) {
253254

254255
mod := collectives.New(client)
255256

257+
testAddr := getTestAddress(t)
256258
propOpts := &collectives.ProposalSendDonationOpts{
257259
Title: "Test send donation proposal",
258260
Description: "Integration test - verify send donation proposal submission",
259261
CollectiveName: "test-collective",
260-
Address: TestAddress,
262+
Address: testAddr,
261263
Amounts: "10ukex",
262264
}
263265

test/integration/custody_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,95 +10,100 @@ import (
1010
// TestCustodyGet tests querying custody for an address.
1111
func TestCustodyGet(t *testing.T) {
1212
skipIfContainerNotRunning(t)
13+
testAddr := getTestAddress(t)
1314
client := getTestClient(t)
1415
defer client.Close()
1516

1617
ctx, cancel := getTestContext()
1718
defer cancel()
1819

1920
mod := custody.New(client)
20-
result, err := mod.Get(ctx, TestAddress)
21+
result, err := mod.Get(ctx, testAddr)
2122
if err != nil {
2223
// This may fail if no custody is set
2324
t.Logf("Custody get query: %v (expected if no custody)", err)
2425
return
2526
}
2627

27-
t.Logf("Custody for %s: %s", TestAddress, string(result))
28+
t.Logf("Custody for %s: %s", testAddr, string(result))
2829
}
2930

3031
// TestCustodyCustodians tests querying custody custodians.
3132
func TestCustodyCustodians(t *testing.T) {
3233
skipIfContainerNotRunning(t)
34+
testAddr := getTestAddress(t)
3335
client := getTestClient(t)
3436
defer client.Close()
3537

3638
ctx, cancel := getTestContext()
3739
defer cancel()
3840

3941
mod := custody.New(client)
40-
result, err := mod.Custodians(ctx, TestAddress)
42+
result, err := mod.Custodians(ctx, testAddr)
4143
if err != nil {
4244
// This may fail if no custodians are set
4345
t.Logf("Custodians query: %v (expected if no custodians)", err)
4446
return
4547
}
4648

47-
t.Logf("Custodians for %s: %s", TestAddress, string(result))
49+
t.Logf("Custodians for %s: %s", testAddr, string(result))
4850
}
4951

5052
// TestCustodyWhitelist tests querying custody whitelist.
5153
func TestCustodyWhitelist(t *testing.T) {
5254
skipIfContainerNotRunning(t)
55+
testAddr := getTestAddress(t)
5356
client := getTestClient(t)
5457
defer client.Close()
5558

5659
ctx, cancel := getTestContext()
5760
defer cancel()
5861

5962
mod := custody.New(client)
60-
result, err := mod.Whitelist(ctx, TestAddress)
63+
result, err := mod.Whitelist(ctx, testAddr)
6164
if err != nil {
6265
// This may fail if no whitelist is set
6366
t.Logf("Whitelist query: %v (expected if no whitelist)", err)
6467
return
6568
}
6669

67-
t.Logf("Whitelist for %s: %s", TestAddress, string(result))
70+
t.Logf("Whitelist for %s: %s", testAddr, string(result))
6871
}
6972

7073
// TestCustodyLimits tests querying custody limits.
7174
func TestCustodyLimits(t *testing.T) {
7275
skipIfContainerNotRunning(t)
76+
testAddr := getTestAddress(t)
7377
client := getTestClient(t)
7478
defer client.Close()
7579

7680
ctx, cancel := getTestContext()
7781
defer cancel()
7882

7983
mod := custody.New(client)
80-
result, err := mod.Limits(ctx, TestAddress)
84+
result, err := mod.Limits(ctx, testAddr)
8185
if err != nil {
8286
// This may fail if no limits are set
8387
t.Logf("Limits query: %v (expected if no limits)", err)
8488
return
8589
}
8690

87-
t.Logf("Limits for %s: %s", TestAddress, string(result))
91+
t.Logf("Limits for %s: %s", testAddr, string(result))
8892
}
8993

9094
// TestCustodyCustodiansPool tests querying custody pool for an address.
9195
func TestCustodyCustodiansPool(t *testing.T) {
9296
skipIfContainerNotRunning(t)
97+
testAddr := getTestAddress(t)
9398
client := getTestClient(t)
9499
defer client.Close()
95100

96101
ctx, cancel := getTestContext()
97102
defer cancel()
98103

99104
mod := custody.New(client)
100-
result, err := mod.CustodiansPool(ctx, TestAddress)
105+
result, err := mod.CustodiansPool(ctx, testAddr)
101106
requireNoError(t, err, "Failed to query custody pool")
102107

103-
t.Logf("Custody pool for %s: %s", TestAddress, string(result))
108+
t.Logf("Custody pool for %s: %s", testAddr, string(result))
104109
}

0 commit comments

Comments
 (0)