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

Commit 985d6ca

Browse files
committed
Improve TestStellarToEthereumWithdrawal
1 parent 30f036d commit 985d6ca

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

integration/ethereum_stellar_test.go

+37
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import (
1313
"github.com/ethereum/go-ethereum/rpc"
1414
"github.com/stretchr/testify/require"
1515

16+
"github.com/stellar/go/amount"
1617
"github.com/stellar/go/clients/horizonclient"
1718
"github.com/stellar/go/protocols/horizon"
19+
"github.com/stellar/go/txnbuild"
1820
"github.com/stellar/go/xdr"
1921
)
2022

@@ -136,6 +138,17 @@ func TestStellarToEthereumWithdrawal(t *testing.T) {
136138
WithdrawalWindow: time.Hour,
137139
})
138140

141+
acct, err := itest.horizonClient.AccountDetail(horizonclient.AccountRequest{AccountID: itest.clientKey.Address()})
142+
require.NoError(t, err)
143+
var before xdr.Int64
144+
for _, balance := range acct.Balances {
145+
if balance.Asset.Type == "native" {
146+
before = amount.MustParse(balance.Balance)
147+
break
148+
}
149+
}
150+
require.Greater(t, before, xdr.Int64(0))
151+
139152
tx, err := itest.bridgeClient.SubmitStellarDeposit(xdr.MustNewNativeAsset(), "3", ethereumSenderAddress(t))
140153
require.NoError(t, err)
141154

@@ -156,6 +169,30 @@ func TestStellarToEthereumWithdrawal(t *testing.T) {
156169
gasPrice,
157170
)
158171
require.Error(t, err)
172+
173+
receipt, err := itest.bridgeClient.SubmitEthereumDeposit(
174+
context.Background(),
175+
common.HexToAddress(EthereumXLMTokenAddress),
176+
itest.clientKey.Address(),
177+
new(big.Int).Mul(big.NewInt(3), big.NewInt(1e7)),
178+
gasPrice,
179+
)
180+
require.NoError(t, err)
181+
182+
_, err = itest.bridgeClient.SubmitStellarWithdrawal(receipt.TxHash.String(), receipt.Logs[0].Index)
183+
require.NoError(t, err)
184+
185+
acct, err = itest.horizonClient.AccountDetail(horizonclient.AccountRequest{AccountID: itest.clientKey.Address()})
186+
require.NoError(t, err)
187+
var after xdr.Int64
188+
for _, balance := range acct.Balances {
189+
if balance.Asset.Type == "native" {
190+
after = amount.MustParse(balance.Balance)
191+
break
192+
}
193+
}
194+
require.Greater(t, before, xdr.Int64(0))
195+
require.Equal(t, before, after+txnbuild.MinBaseFee*2)
159196
}
160197

161198
func TestStellarRefund(t *testing.T) {

0 commit comments

Comments
 (0)