From 18dc1a2f61608956301bce2d207d1e07921610e2 Mon Sep 17 00:00:00 2001 From: asolovov Date: Tue, 14 Nov 2023 19:18:46 +0400 Subject: [PATCH] update: add liquidate account method for test contract --- utils/testing-contracts/perps-test/perps-market.go | 13 +++++++++++++ utils/testing-contracts/perps-test/src/main.go | 3 +++ 2 files changed, 16 insertions(+) diff --git a/utils/testing-contracts/perps-test/perps-market.go b/utils/testing-contracts/perps-test/perps-market.go index a47fe2f..96a06c4 100644 --- a/utils/testing-contracts/perps-test/perps-market.go +++ b/utils/testing-contracts/perps-test/perps-market.go @@ -218,6 +218,19 @@ func (m *TestPerpsMarket) CommitOrder(marketIDS string, sizeS string) { logger.Log().WithField("layer", "TestPerpsMarket-CommitOrder").Infof("order commited, tx hash: %v", tx.Hash()) } +func (m *TestPerpsMarket) LiquidateAccount(accountIDs string) { + aut := m.getAut("Liquidate") + + accountID := m.getBig(accountIDs) + + tx, err := m.perpsMarket.Liquidate(aut, accountID) + if err != nil { + logger.Log().WithField("layer", "TestPerpsMarket-LiquidateAccount").Fatalf("liquidate account err: %v", err.Error()) + } + + logger.Log().WithField("layer", "TestPerpsMarket-LiquidateAccount").Infof("account liquidated, tx hash: %v", tx.Hash()) +} + func (m *TestPerpsMarket) Close() { m.rpcClient.Close() } diff --git a/utils/testing-contracts/perps-test/src/main.go b/utils/testing-contracts/perps-test/src/main.go index 65ab27a..9f5b97b 100644 --- a/utils/testing-contracts/perps-test/src/main.go +++ b/utils/testing-contracts/perps-test/src/main.go @@ -55,6 +55,9 @@ func main() { // Account ID, Permission and User perps.GrantPermission(args[2], args[3], args[4]) perps.Close() + case "LiquidateAccount": + perps.LiquidateAccount(args[2]) + perps.Close() default: perps.Close() logger.Log().WithField("layer", "TestPerpsMarket-Main").Fatalf("unknown command")