Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Improve TestStellarToEthereumWithdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Jan 22, 2023
1 parent 30f036d commit 985d6ca
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions integration/ethereum_stellar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"

"github.com/stellar/go/amount"
"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/txnbuild"
"github.com/stellar/go/xdr"
)

Expand Down Expand Up @@ -136,6 +138,17 @@ func TestStellarToEthereumWithdrawal(t *testing.T) {
WithdrawalWindow: time.Hour,
})

acct, err := itest.horizonClient.AccountDetail(horizonclient.AccountRequest{AccountID: itest.clientKey.Address()})
require.NoError(t, err)
var before xdr.Int64
for _, balance := range acct.Balances {
if balance.Asset.Type == "native" {
before = amount.MustParse(balance.Balance)
break
}
}
require.Greater(t, before, xdr.Int64(0))

tx, err := itest.bridgeClient.SubmitStellarDeposit(xdr.MustNewNativeAsset(), "3", ethereumSenderAddress(t))
require.NoError(t, err)

Expand All @@ -156,6 +169,30 @@ func TestStellarToEthereumWithdrawal(t *testing.T) {
gasPrice,
)
require.Error(t, err)

receipt, err := itest.bridgeClient.SubmitEthereumDeposit(
context.Background(),
common.HexToAddress(EthereumXLMTokenAddress),
itest.clientKey.Address(),
new(big.Int).Mul(big.NewInt(3), big.NewInt(1e7)),
gasPrice,
)
require.NoError(t, err)

_, err = itest.bridgeClient.SubmitStellarWithdrawal(receipt.TxHash.String(), receipt.Logs[0].Index)
require.NoError(t, err)

acct, err = itest.horizonClient.AccountDetail(horizonclient.AccountRequest{AccountID: itest.clientKey.Address()})
require.NoError(t, err)
var after xdr.Int64
for _, balance := range acct.Balances {
if balance.Asset.Type == "native" {
after = amount.MustParse(balance.Balance)
break
}
}
require.Greater(t, before, xdr.Int64(0))
require.Equal(t, before, after+txnbuild.MinBaseFee*2)
}

func TestStellarRefund(t *testing.T) {
Expand Down

0 comments on commit 985d6ca

Please sign in to comment.