Skip to content

Commit

Permalink
refactor utxos list
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jun 5, 2024
1 parent dc93dc6 commit 47c08b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash)

r.Logger.Info("******* Second test: BTC -> ERC20ZRC20")
// list deployer utxos that have at least 1 BTC
utxos, err := r.ListDeployerUTXOs(1.0)
// list deployer utxos
utxos, err := r.ListDeployerUTXOs()
if err != nil {
panic(err)
}
Expand Down
22 changes: 7 additions & 15 deletions e2e/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

var blockHeaderBTCTimeout = 5 * time.Minute

// ListDeployerUTXOs list the deployer's UTXOs that have at least `minAmount`
func (runner *E2ERunner) ListDeployerUTXOs(_ float64) ([]btcjson.ListUnspentResult, error) {
// ListDeployerUTXOs list the deployer's UTXOs
func (runner *E2ERunner) ListDeployerUTXOs() ([]btcjson.ListUnspentResult, error) {
// query UTXOs from node
utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses(
1,
Expand All @@ -40,23 +40,15 @@ func (runner *E2ERunner) ListDeployerUTXOs(_ float64) ([]btcjson.ListUnspentResu
return nil, err
}

// filter UTXOs by `minAmount`
filtered := []btcjson.ListUnspentResult{}
for _, utxo := range utxos {
//if utxo.Amount >= minAmount {
filtered = append(filtered, utxo)
//}
}

return filtered, nil
return utxos, nil
}

// DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount
func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) {
runner.Logger.Print("⏳ depositing BTC into ZEVM")

// list deployer utxos that have at least 1 BTC
utxos, err := runner.ListDeployerUTXOs(1.0)
// list deployer utxos
utxos, err := runner.ListDeployerUTXOs()
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -101,8 +93,8 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) {
runner.Logger.Print("✅ BTC deposited in %s", time.Since(startTime))
}()

// list deployer utxos that have at least 1 BTC
utxos, err := runner.ListDeployerUTXOs(1.0)
// list deployer utxos
utxos, err := runner.ListDeployerUTXOs()
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 47c08b6

Please sign in to comment.