From bb6c397bc9ab9dec2c8fbff22f98f99919826b3d Mon Sep 17 00:00:00 2001 From: Pravin Goomannee Date: Thu, 11 Mar 2021 12:54:48 +0000 Subject: [PATCH] refactor: create step to deposit into account --- integration/execution_layer_test.go | 10 ---------- integration/main_test.go | 4 +++- integration/steps/deposit_Into_account.go | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 integration/steps/deposit_Into_account.go diff --git a/integration/execution_layer_test.go b/integration/execution_layer_test.go index 7efb7aeaf0..af8635bb64 100644 --- a/integration/execution_layer_test.go +++ b/integration/execution_layer_test.go @@ -35,16 +35,6 @@ func theInsurancePoolInitialBalanceForTheMarketsIs(amountstr string) error { return nil } -func theMakesADepositOfIntoTheAccount(trader, amountstr, asset string) error { - amount, _ := strconv.ParseUint(amountstr, 10, 0) - // row.0 = traderID, row.1 = amount to topup - - _, err := execsetup.collateral.Deposit( - context.Background(), trader, asset, amount, - ) - return err -} - func generalAccountForAssetBalanceIs(trader, asset, balancestr string) error { balance, _ := strconv.ParseUint(balancestr, 10, 0) acc, err := execsetup.broker.GetTraderGeneralAccount(trader, asset) diff --git a/integration/main_test.go b/integration/main_test.go index e108309519..ae9270d83e 100644 --- a/integration/main_test.go +++ b/integration/main_test.go @@ -62,7 +62,9 @@ func FeatureContext(s *godog.Suite) { s.Step(`^The "([^"]*)" withdraw "([^"]*)" from the "([^"]*)" account$`, func(owner, amountStr, asset string) error { return steps.WithdrawFromAccount(execsetup.collateral, owner, amountStr, asset) }) - s.Step(`^The "([^"]*)" makes a deposit of "([^"]*)" into the "([^"]*)" account$`, theMakesADepositOfIntoTheAccount) + s.Step(`^The "([^"]*)" makes a deposit of "([^"]*)" into the "([^"]*)" account$`, func(owner, amountstr, asset string) error { + return steps.DepositIntoAccount(execsetup.collateral, owner, amountstr, asset) + }) s.Step(`^"([^"]*)" general account for asset "([^"]*)" balance is "([^"]*)"$`, generalAccountForAssetBalanceIs) s.Step(`^"([^"]*)" have only one account per asset$`, func(owner string) error { return steps.HaveOnlyOneAccountPerAsset(execsetup.broker, owner) diff --git a/integration/steps/deposit_Into_account.go b/integration/steps/deposit_Into_account.go new file mode 100644 index 0000000000..0bb301a2b0 --- /dev/null +++ b/integration/steps/deposit_Into_account.go @@ -0,0 +1,16 @@ +package steps + +import ( + "context" + "strconv" + + "code.vegaprotocol.io/vega/collateral" +) + +func DepositIntoAccount(collateral *collateral.Engine, owner, amountstr, asset string) error { + amount, _ := strconv.ParseUint(amountstr, 10, 0) + _, err := collateral.Deposit( + context.Background(), owner, asset, amount, + ) + return err +}