Skip to content

Commit 5b5bd5b

Browse files
committed
fix: Fix wasp-cli tests
1 parent ded4aa9 commit 5b5bd5b

File tree

11 files changed

+293
-224
lines changed

11 files changed

+293
-224
lines changed

clients/iota-go/iotajsonrpc/utils_pick_coins.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,42 @@ func PickupCoins(
9898
}, nil
9999
}
100100

101+
func PickupCoinsWithCointype(
102+
inputCoins *CoinPage,
103+
targetAmount *big.Int,
104+
cointype CoinType,
105+
) (*PickedCoins, error) {
106+
coins := inputCoins.Data
107+
inputCount := len(coins)
108+
if inputCount <= 0 {
109+
return nil, ErrNoCoinsFound
110+
}
111+
112+
total := big.NewInt(0)
113+
pickedCoins := []*Coin{}
114+
for _, coin := range coins {
115+
if coin.CoinType != cointype {
116+
continue
117+
}
118+
total = total.Add(total, new(big.Int).SetUint64(coin.Balance.Uint64()))
119+
pickedCoins = append(pickedCoins, coin)
120+
121+
if total.Cmp(targetAmount) >= 0 {
122+
break
123+
}
124+
}
125+
if total.Cmp(targetAmount) < 0 {
126+
if inputCoins.HasNextPage {
127+
return nil, ErrNeedMergeCoin
128+
}
129+
}
130+
return &PickedCoins{
131+
Coins: pickedCoins,
132+
TargetAmount: targetAmount,
133+
TotalAmount: total,
134+
}, nil
135+
}
136+
101137
func PickupCoinsSimple(coins Coins, targetAmount uint64) (Coins, error) {
102138
return PickupCoinsWithFilter(coins, targetAmount, nil)
103139
}

tools/cluster/tests/wasp-cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (w *WaspCLITest) runCmd(args []string, f func(*exec.Cmd)) ([]string, error)
7272
w.T.Helper()
7373
// -w: wait for requests
7474
// -d: debug output
75-
cmd := exec.Command("wasp-cli", append([]string{"-c", w.dir + "/wasp-cli.json", "-w", "-d"}, args...)...) //nolint:gosec
75+
cmd := exec.Command("wasp-cli", append([]string{"-c", w.dir + "/wasp-cli.json", "-w=2m", "-d"}, args...)...) //nolint:gosec
7676
cmd.Dir = w.dir
7777

7878
stdout := new(bytes.Buffer)

0 commit comments

Comments
 (0)