-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,41 @@ | ||
package e2etests | ||
|
||
// DepositBTCRefund ... | ||
// TODO: define e2e test | ||
// https://github.com/zeta-chain/node-private/issues/79 | ||
//func DepositBTCRefund(r *runner.E2ERunner) { | ||
// r.Logger.InfoLoud("Deposit BTC with invalid memo; should be refunded") | ||
// btc := r.BtcRPCClient | ||
// utxos, err := r.BtcRPCClient.ListUnspent() | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// spendableAmount := 0.0 | ||
// spendableUTXOs := 0 | ||
// for _, utxo := range utxos { | ||
// if utxo.Spendable { | ||
// spendableAmount += utxo.Amount | ||
// spendableUTXOs++ | ||
// } | ||
// } | ||
// r.Logger.Info("ListUnspent:") | ||
// r.Logger.Info(" spendableAmount: %f", spendableAmount) | ||
// r.Logger.Info(" spendableUTXOs: %d", spendableUTXOs) | ||
// r.Logger.Info("Now sending two txs to TSS address...") | ||
// _, err = r.SendToTSSFromDeployerToDeposit(r.BTCTSSAddress, 1.1, utxos[:2], btc, r.BTCDeployerAddress) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// _, err = r.SendToTSSFromDeployerToDeposit(r.BTCTSSAddress, 0.05, utxos[2:4], btc, r.BTCDeployerAddress) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// | ||
// r.Logger.Info("testing if the deposit into BTC ZRC20 is successful...") | ||
// | ||
// // check if the deposit is successful | ||
// initialBalance, err := r.BTCZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// for { | ||
// time.Sleep(3 * time.Second) | ||
// balance, err := r.BTCZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// diff := big.NewInt(0) | ||
// diff.Sub(balance, initialBalance) | ||
// if diff.Cmp(big.NewInt(1.15*btcutil.SatoshiPerBitcoin)) != 0 { | ||
// r.Logger.Info("waiting for BTC balance to show up in ZRC contract... current bal %d", balance) | ||
// } else { | ||
// r.Logger.Info("BTC balance is in ZRC contract! Success") | ||
// break | ||
// } | ||
// } | ||
//} | ||
import ( | ||
"strconv" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/zeta-chain/zetacore/e2e/runner" | ||
"github.com/zeta-chain/zetacore/e2e/utils" | ||
) | ||
|
||
func TestDepositBTCRefund(r *runner.E2ERunner, args []string) { | ||
// ARRANGE | ||
// Given amount to send | ||
require.Len(r, args, 1) | ||
amount := parseFloat(r, args[0]) | ||
|
||
// Given BTC address | ||
r.SetBtcAddress(r.Name, false) | ||
|
||
// Given a list of UTXOs | ||
utxos, err := r.BtcRPCClient.ListUnspent() | ||
require.NoError(r, err) | ||
require.NotEmpty(r, utxos) | ||
|
||
// ACT | ||
// Send a single UTXO to TSS address | ||
txHash, err := r.SendToTSSFromDeployerWithMemo(amount, utxos, []byte("gibberish-memo")) | ||
require.NotEmpty(r, err) | ||
|
||
// Wait for processing in zetaclient | ||
utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) | ||
|
||
// ASSERT | ||
// todo... | ||
} | ||
|
||
func parseFloat(t require.TestingT, s string) float64 { | ||
f, err := strconv.ParseFloat(s, 64) | ||
require.NoError(t, err, "unable to parse float %q", s) | ||
return f | ||
} |