Skip to content

Commit b30e7b6

Browse files
authored
Merge pull request #732 from iotaledger/fix/cluster-tests
Fix cluster tests
2 parents 6e25389 + 25469f7 commit b30e7b6

32 files changed

+769
-1571
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Cluster Tests Nightly
2+
3+
on:
4+
pull_request:
5+
branches: [ "develop" ]
6+
schedule:
7+
- cron: '0 2 * * *'
8+
workflow_dispatch:
9+
10+
jobs:
11+
cluster-tests:
12+
name: Run cluster tests
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 120
15+
steps:
16+
- name: Set up Go 1.x
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.24.0"
20+
21+
- name: Check out code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
fetch-tags: true
26+
27+
- name: Get dependencies
28+
run: |
29+
go get -v -t -d ./...
30+
31+
- name: Run cluster tests
32+
run: |
33+
make test-cluster
34+
35+

clients/iota-go/iotaclient/faucet.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ func RequestFundsFromFaucet(ctx context.Context, address *iotago.Address, faucet
3434
return err
3535
}
3636
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusCreated && res.StatusCode != http.StatusAccepted {
37-
return fmt.Errorf("post %v response code: %v", faucetUrl, res.Status)
37+
body, err := io.ReadAll(res.Body)
38+
if err != nil {
39+
fmt.Printf("post %v response code: %v, error reading body: %v", faucetUrl, res.Status, err)
40+
}
41+
return fmt.Errorf("post %v response code: %v, body: %s", faucetUrl, res.Status, string(body))
3842
}
3943
defer res.Body.Close()
4044

clients/iscmove/iscmoveclient/client_assets_bag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (c *Client) GetAssetsBagWithBalances(
4444
return nil, fmt.Errorf("failed to call GetObject for Balance: %w", err)
4545
}
4646

47-
if resGetObject.Data.Content == nil || resGetObject.Data.Content.Data.MoveObject == nil {
47+
if resGetObject.Data == nil || resGetObject.Data.Content == nil || resGetObject.Data.Content.Data.MoveObject == nil {
4848
return nil, fmt.Errorf("content data of AssetBag nil! (%s)", assetsBagID)
4949
}
5050
var coinBalance struct {

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"l1": {
2727
"httpURL": "https://api.iota-rebased-alphanet.iota.cafe",
2828
"websocketURL": "wss://api.iota-rebased-alphanet.iota.cafe",
29+
"packageID": "0xa25cb7d5b6462009a471be13a241a2b604e66294e79a3a54d162d19e784c03b4",
2930
"maxConnectionAttempts": 30,
3031
"targetNetworkName": "IOTA"
3132
},

packages/apilib/rundkg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
// RunDistributedKeyGeneration runs DKG procedure on specific Wasp hosts: generates new keys and puts corresponding committee records
2020
// into nodes. In case of success, generated address is returned
2121
func RunDistributedKeyGeneration(ctx context.Context, client *apiclient.APIClient, peerPubKeys []string, threshold uint16, timeout ...time.Duration) (*cryptolib.Address, error) {
22-
to := uint32(60 * 1000)
22+
to := uint32(120 * 1000)
2323
if len(timeout) > 0 {
2424
n := timeout[0].Milliseconds()
2525
if n < int64(math.MaxUint16) {

packages/evm/evmtest/Storage.abi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"inputs":[{"internalType":"uint32","name":"_n","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"n","type":"uint32"}],"name":"Stored","type":"event"},{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_n","type":"uint32"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"}]
1+
[{"inputs":[{"internalType":"uint32","name":"_n","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"n","type":"uint32"}],"name":"Stored","type":"event"},{"inputs":[],"name":"increment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_n","type":"uint32"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"}]

packages/evm/evmtest/Storage.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6080604052348015600e575f5ffd5b506040516102653803806102658339818101604052810190602e9190608a565b805f5f6101000a81548163ffffffff021916908363ffffffff1602179055505060b0565b5f5ffd5b5f63ffffffff82169050919050565b606c816056565b81146075575f5ffd5b50565b5f815190506084816065565b92915050565b5f60208284031215609c57609b6052565b5b5f60a7848285016078565b91505092915050565b6101a8806100bd5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c80632e64cec114610038578063b9e9538214610056575b5f5ffd5b610040610072565b60405161004d9190610100565b60405180910390f35b610070600480360381019061006b9190610147565b610089565b005b5f5f5f9054906101000a900463ffffffff16905090565b805f5f6101000a81548163ffffffff021916908363ffffffff1602179055507f1216415e6088a976b049b2d1fc9e52c96a2199b400aa37dc4aa9585710d03b87816040516100d79190610100565b60405180910390a150565b5f63ffffffff82169050919050565b6100fa816100e2565b82525050565b5f6020820190506101135f8301846100f1565b92915050565b5f5ffd5b610126816100e2565b8114610130575f5ffd5b50565b5f813590506101418161011d565b92915050565b5f6020828403121561015c5761015b610119565b5b5f61016984828501610133565b9150509291505056fea2646970667358221220511c1772ce98a11d06e833809d341bb69e31bab47b980d3e98730b60a578344664736f6c634300081d0033
1+
6080604052348015600e575f5ffd5b506040516103653803806103658339818101604052810190602e9190608a565b805f5f6101000a81548163ffffffff021916908363ffffffff1602179055505060b0565b5f5ffd5b5f63ffffffff82169050919050565b606c816056565b81146075575f5ffd5b50565b5f815190506084816065565b92915050565b5f60208284031215609c57609b6052565b5b5f60a7848285016078565b91505092915050565b6102a8806100bd5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80632e64cec114610043578063b9e9538214610061578063d09de08a1461007d575b5f5ffd5b61004b610087565b604051610058919061019c565b60405180910390f35b61007b600480360381019061007691906101e3565b61009e565b005b6100856100f7565b005b5f5f5f9054906101000a900463ffffffff16905090565b805f5f6101000a81548163ffffffff021916908363ffffffff1602179055507f1216415e6088a976b049b2d1fc9e52c96a2199b400aa37dc4aa9585710d03b87816040516100ec919061019c565b60405180910390a150565b60015f5f8282829054906101000a900463ffffffff16610117919061023b565b92506101000a81548163ffffffff021916908363ffffffff1602179055507f1216415e6088a976b049b2d1fc9e52c96a2199b400aa37dc4aa9585710d03b875f5f9054906101000a900463ffffffff16604051610174919061019c565b60405180910390a1565b5f63ffffffff82169050919050565b6101968161017e565b82525050565b5f6020820190506101af5f83018461018d565b92915050565b5f5ffd5b6101c28161017e565b81146101cc575f5ffd5b50565b5f813590506101dd816101b9565b92915050565b5f602082840312156101f8576101f76101b5565b5b5f610205848285016101cf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6102458261017e565b91506102508361017e565b9250828201905063ffffffff81111561026c5761026b61020e565b5b9291505056fea2646970667358221220c86c70ada69370c5a6eee58a9ab5bf0f78e0a46925993338d6bbf65a7f6a059664736f6c634300081e0033

packages/evm/evmtest/Storage.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ contract Storage {
1717
emit Stored(_n);
1818
}
1919

20+
function increment() public {
21+
n += 1;
22+
emit Stored(n);
23+
}
24+
2025
function retrieve() public view returns (uint32) {
2126
return n;
2227
}

packages/util/timer.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

tools/cluster/cluster.go

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"io"
12+
"math"
1213
"math/rand"
1314
"net/http"
1415
"os"
@@ -69,6 +70,19 @@ type waspCmd struct {
6970
logScanner sync.WaitGroup
7071
}
7172

73+
func Retry(fn func() error, retries int) error {
74+
var err error
75+
for i := 0; i < retries; i++ {
76+
err = fn()
77+
if err != nil {
78+
time.Sleep(time.Duration(math.Pow(2, float64(i))) * 500 * time.Millisecond) // Exponential backoff
79+
continue
80+
}
81+
break
82+
}
83+
return err
84+
}
85+
7286
func New(name string, config *ClusterConfig, dataPath string, t *testing.T, log log.Logger, l1PacakgeID *iotago.PackageID) *Cluster {
7387
if log == nil {
7488
if t == nil {
@@ -209,37 +223,48 @@ func (clu *Cluster) InitDistributedKeyGeneration(committeeNodeCount int) ([]int,
209223
}
210224

211225
func (clu *Cluster) RunDistributedKeyGeneration(committeeNodes []int, threshold uint16, timeout ...time.Duration) (*cryptolib.Address, error) {
212-
if threshold == 0 {
213-
threshold = (uint16(len(committeeNodes))*2)/3 + 1
214-
}
215-
apiHosts := clu.Config.APIHosts(committeeNodes)
226+
var addr *cryptolib.Address
227+
var err error
228+
err = Retry(func() error {
229+
if threshold == 0 {
230+
threshold = (uint16(len(committeeNodes))*2)/3 + 1
231+
}
232+
apiHosts := clu.Config.APIHosts(committeeNodes)
216233

217-
peerPubKeys := make([]string, 0)
218-
for _, i := range committeeNodes {
219-
//nolint:bodyclose // false positive
220-
peeringNodeInfo, _, err := clu.WaspClient(i).NodeAPI.GetPeeringIdentity(context.Background()).Execute()
221-
if err != nil {
222-
return nil, err
234+
peerPubKeys := make([]string, 0)
235+
for _, i := range committeeNodes {
236+
//nolint:bodyclose // false positive
237+
peeringNodeInfo, _, err := clu.WaspClient(i).NodeAPI.GetPeeringIdentity(context.Background()).Execute()
238+
if err != nil {
239+
return err
240+
}
241+
242+
peerPubKeys = append(peerPubKeys, peeringNodeInfo.PublicKey)
223243
}
224244

225-
peerPubKeys = append(peerPubKeys, peeringNodeInfo.PublicKey)
226-
}
245+
distKeyGenInitiatorIndex := rand.Intn(len(apiHosts))
246+
client := clu.WaspClientFromHostName(apiHosts[distKeyGenInitiatorIndex])
227247

228-
distKeyGenInitiatorIndex := rand.Intn(len(apiHosts))
229-
client := clu.WaspClientFromHostName(apiHosts[distKeyGenInitiatorIndex])
248+
addr, err = apilib.RunDistributedKeyGeneration(context.Background(), client, peerPubKeys, threshold, timeout...)
249+
return err
250+
}, 5)
251+
252+
if err != nil {
253+
return nil, err
254+
}
230255

231-
return apilib.RunDistributedKeyGeneration(context.Background(), client, peerPubKeys, threshold, timeout...)
256+
return addr, nil
232257
}
233258

234259
func (clu *Cluster) DeployChainWithDistKeyGen(allPeers, committeeNodes []int, quorum uint16, blockKeepAmount ...int32) (*Chain, error) {
235260
stateAddr, err := clu.RunDistributedKeyGeneration(committeeNodes, quorum)
236261
if err != nil {
237262
return nil, err
238263
}
239-
return clu.DeployChain(allPeers, committeeNodes, quorum, stateAddr, blockKeepAmount...)
264+
return clu.DeployChain(allPeers, committeeNodes, quorum, stateAddr, false, blockKeepAmount...)
240265
}
241266

242-
func (clu *Cluster) DeployChain(allPeers, committeeNodes []int, quorum uint16, stateAddr *cryptolib.Address, blockKeepAmount ...int32) (*Chain, error) {
267+
func (clu *Cluster) DeployChain(allPeers, committeeNodes []int, quorum uint16, stateAddr *cryptolib.Address, deployTestContracts bool, blockKeepAmount ...int32) (*Chain, error) {
243268
if len(allPeers) == 0 {
244269
allPeers = clu.Config.AllNodes()
245270
}
@@ -279,7 +304,7 @@ func (clu *Cluster) DeployChain(allPeers, committeeNodes []int, quorum uint16, s
279304
isc.NewAddressAgentID(chain.OriginatorAddress()),
280305
1074,
281306
blockKeepAmountVal,
282-
false,
307+
deployTestContracts,
283308
).Encode()
284309

285310
getCoinsRes, err := l1Client.GetCoins(

0 commit comments

Comments
 (0)