code.vegaprotocol.io/vega@v0.79.0/core/integration/steps/network_params.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package steps 17 18 import ( 19 "context" 20 "fmt" 21 22 "code.vegaprotocol.io/vega/core/netparams" 23 "code.vegaprotocol.io/vega/logging" 24 25 "github.com/cucumber/godog" 26 ) 27 28 var unwatched = map[string]struct{}{} 29 30 func DebugNetworkParameter(log *logging.Logger, netParams *netparams.Store, key string) error { 31 value, err := netParams.Get(key) 32 if err != nil { 33 return err 34 } 35 log.Info(fmt.Sprintf("\n\n%s: %s\n", key, value)) 36 return nil 37 } 38 39 func TheFollowingNetworkParametersAreSet(netParams *netparams.Store, table *godog.Table) error { 40 ctx := context.Background() 41 for _, row := range parseNetworkParametersTable(table) { 42 name := row.MustStr("name") 43 44 if _, ok := unwatched[name]; !ok && !netParams.AnyWatchers(name) { 45 return errNoWatchersSpecified(name) 46 } 47 48 switch name { 49 case netparams.MarketAuctionMinimumDuration: 50 d := row.MustDurationSec("value") 51 if err := netParams.Update(ctx, netparams.MarketAuctionMinimumDuration, d.String()); err != nil { 52 return err 53 } 54 case netparams.MarketAuctionMaximumDuration: 55 d := row.MustDurationStr("value") 56 if err := netParams.Update(ctx, netparams.MarketAuctionMaximumDuration, d.String()); err != nil { 57 return err 58 } 59 case netparams.MarkPriceUpdateMaximumFrequency: 60 f := row.MustDurationStr("value") 61 str := f.String() 62 if err := netParams.Update(ctx, netparams.MarkPriceUpdateMaximumFrequency, str); err != nil { 63 return err 64 } 65 case netparams.InternalCompositePriceUpdateFrequency: 66 f := row.MustDurationStr("value") 67 str := f.String() 68 if err := netParams.Update(ctx, netparams.InternalCompositePriceUpdateFrequency, str); err != nil { 69 return err 70 } 71 case netparams.MarketLiquidityEquityLikeShareFeeFraction: 72 dv := row.MustDecimal("value") 73 if err := netParams.Update(ctx, netparams.MarketLiquidityEquityLikeShareFeeFraction, dv.String()); err != nil { 74 return err 75 } 76 default: 77 value := row.MustStr("value") 78 if err := netParams.Update(ctx, name, value); err != nil { 79 return err 80 } 81 } 82 } 83 84 netParams.DispatchChanges(ctx) 85 86 return nil 87 } 88 89 func parseNetworkParametersTable(table *godog.Table) []RowWrapper { 90 return StrictParseTable(table, []string{ 91 "name", 92 "value", 93 }, []string{}) 94 }