From b5c7e6e7e77640de5c7662bd890ce8387e05c475 Mon Sep 17 00:00:00 2001 From: asolovov Date: Wed, 29 Nov 2023 16:58:29 +0400 Subject: [PATCH] fix: utils --- .../perps-test/perps-market.go | 20 +++++++++---------- .../perps-test/settle_order.go | 17 ++++++++-------- .../testing-contracts/perps-test/src/main.go | 8 ++++---- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/utils/testing-contracts/perps-test/perps-market.go b/utils/testing-contracts/perps-test/perps-market.go index cdc9e4a..6dac0fc 100644 --- a/utils/testing-contracts/perps-test/perps-market.go +++ b/utils/testing-contracts/perps-test/perps-market.go @@ -150,16 +150,16 @@ func (m *TestPerpsMarket) GetCollateralAmount(marketIDS string) { logger.Log().WithField("layer", "TestPerpsMarket-GetCollateralAmount").Infof("collateral amount: %v", amount.String()) } -func (m *TestPerpsMarket) GetMaxCollateralAmount(marketIDS string) { - marketID := m.getBig(marketIDS) - - amount, err := m.perpsMarket.GetMaxCollateralAmount(nil, marketID) - if err != nil { - logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Fatalf("get max collateral amount err: %v", err.Error()) - } - - logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Infof("max collateral amount: %v", amount.String()) -} +//func (m *TestPerpsMarket) GetMaxCollateralAmount(marketIDS string) { +// marketID := m.getBig(marketIDS) +// +// amount, err := m.perpsMarket.GetMaxCollateralAmount(nil, marketID) +// if err != nil { +// logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Fatalf("get max collateral amount err: %v", err.Error()) +// } +// +// logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Infof("max collateral amount: %v", amount.String()) +//} func (m *TestPerpsMarket) ModifyCollateral(marketIDS string, amountS string) { aut := m.getAut("ModifyCollateral") diff --git a/utils/testing-contracts/perps-test/settle_order.go b/utils/testing-contracts/perps-test/settle_order.go index 2a2e99d..2cdef66 100644 --- a/utils/testing-contracts/perps-test/settle_order.go +++ b/utils/testing-contracts/perps-test/settle_order.go @@ -10,7 +10,6 @@ import ( "log" "math/big" "net/http" - "strings" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -38,7 +37,7 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int, logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("GetOrder err: %v", err) } - settlementTime := time.Unix(ordData.SettlementTime.Int64(), 2) + settlementTime := time.Unix(ordData.CommitmentTime.Int64(), 2) if time.Now().Before(settlementTime) { duration := time.Until(settlementTime) logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Infof("Waiting %v until order can be settled??? Not in this attempt!", duration) @@ -50,7 +49,7 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int, settlementStrategy := GetSettlementStrategy(int(ordData.Request.MarketId.Int64()), 2) settlementTimeBytes := make([]byte, 8) - binary.BigEndian.PutUint64(settlementTimeBytes, ordData.SettlementTime.Uint64()) + binary.BigEndian.PutUint64(settlementTimeBytes, ordData.CommitmentTime.Uint64()) settlementTimeHex := hex.EncodeToString(settlementTimeBytes) dataParam := fmt.Sprintf("0x%s%s", hex.EncodeToString(settlementStrategy.FeedID), settlementTimeHex) @@ -97,13 +96,13 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int, log.Printf("extra_data to string: %s", hex.EncodeToString(extraData)) - data, err := hex.DecodeString(strings.TrimPrefix(priceUpdateData.Data, "0x")) - if err != nil { - logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("Failed to decode hex string priceUpdateData.Data: %v", err) - } - aut := m.getAut("SettlePythOrder") + //data, err := hex.DecodeString(strings.TrimPrefix(priceUpdateData.Data, "0x")) + //if err != nil { + // logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("Failed to decode hex string priceUpdateData.Data: %v", err) + //} + aut := m.getAut("SettleOrder") - tx, err := m.perpsMarket.SettlePythOrder(aut, data, extraData) + tx, err := m.perpsMarket.SettleOrder(aut, accountID) if err != nil { logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("SettlePythOrder: %+v", err) } diff --git a/utils/testing-contracts/perps-test/src/main.go b/utils/testing-contracts/perps-test/src/main.go index 9f5b97b..804fe00 100644 --- a/utils/testing-contracts/perps-test/src/main.go +++ b/utils/testing-contracts/perps-test/src/main.go @@ -37,10 +37,10 @@ func main() { // Market ID perps.GetCollateralAmount(args[2]) perps.Close() - case "GetMaxCollateralAmount": - // Market ID - perps.GetMaxCollateralAmount(args[2]) - perps.Close() + //case "GetMaxCollateralAmount": + // // Market ID + // perps.GetMaxCollateralAmount(args[2]) + // perps.Close() case "SetApproval": // Amount perps.SetApproval(args[2])