code.vegaprotocol.io/vega@v0.79.0/core/integration/main_test.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 core_test 17 18 import ( 19 "context" 20 "flag" 21 "fmt" 22 "log" 23 "os" 24 "regexp" 25 "testing" 26 27 "code.vegaprotocol.io/vega/core/integration/helpers" 28 "code.vegaprotocol.io/vega/core/integration/steps" 29 "code.vegaprotocol.io/vega/core/netparams" 30 "code.vegaprotocol.io/vega/libs/num" 31 "code.vegaprotocol.io/vega/libs/ptr" 32 "code.vegaprotocol.io/vega/protos/vega" 33 34 "github.com/cucumber/godog" 35 "github.com/cucumber/godog/colors" 36 ) 37 38 var ( 39 gdOpts = godog.Options{ 40 Output: colors.Colored(os.Stdout), 41 Format: "progress", 42 } 43 44 perpsSwap bool 45 features string 46 47 expectingEventsOverStepText = `there were "([0-9]+)" events emitted over the last step` 48 ) 49 50 func init() { 51 godog.BindFlags("godog.", flag.CommandLine, &gdOpts) 52 flag.StringVar(&features, "features", "", "a coma separated list of paths to the feature files") 53 flag.BoolVar(&perpsSwap, "perps", false, "Runs all tests swapping out the default futures oracles for their corresponding perps oracle") 54 } 55 56 func TestMain(m *testing.M) { 57 flag.Parse() 58 gdOpts.Paths = flag.Args() 59 60 if testing.Short() { 61 log.Print("Skipping core integration tests, go test run with -short") 62 return 63 } 64 if perpsSwap { 65 marketConfig.OracleConfigs.SwapToPerps() 66 gdOpts.Tags += " ~NoPerp" 67 } 68 69 status := godog.TestSuite{ 70 Name: "godogs", 71 TestSuiteInitializer: InitializeTestSuite, 72 ScenarioInitializer: InitializeScenario, 73 Options: &gdOpts, 74 }.Run() 75 76 os.Exit(status) 77 } 78 79 func InitializeTestSuite(ctx *godog.TestSuiteContext) {} 80 81 func InitializeScenario(s *godog.ScenarioContext) { 82 s.BeforeScenario(func(*godog.Scenario) { 83 execsetup = newExecutionTestSetup() 84 }) 85 s.StepContext().Before(func(ctx context.Context, st *godog.Step) (context.Context, error) { 86 // record accounts before step 87 execsetup.accountsBefore = execsetup.broker.GetAccounts() 88 execsetup.ledgerMovementsBefore = len(execsetup.broker.GetTransfers(false)) 89 execsetup.insurancePoolDepositsOverStep = make(map[string]*num.Int) 90 // set default netparams 91 execsetup.netParams.Update(ctx, netparams.MarketSuccessorLaunchWindow, "1h") 92 93 // don't record events before step if it's the step that's meant to assess number of events over a regular step 94 if b, _ := regexp.MatchString(expectingEventsOverStepText, st.Text); !b { 95 execsetup.eventsBefore = len(execsetup.broker.GetAllEvents()) 96 } 97 98 return ctx, nil 99 }) 100 s.StepContext().After(func(ctx context.Context, st *godog.Step, status godog.StepResultStatus, err error) (context.Context, error) { 101 aerr := reconcileAccounts() 102 if aerr != nil { 103 aerr = fmt.Errorf("failed to reconcile account balance changes over the last step from emitted events: %v", aerr) 104 } 105 return ctx, aerr 106 }) 107 s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { 108 berr := steps.TheCumulatedBalanceForAllAccountsShouldBeWorth(execsetup.broker, execsetup.netDeposits.String()) 109 if berr != nil { 110 berr = fmt.Errorf("error at scenario end (testing net deposits/withdrawals against cumulated balance for all accounts): %v", berr) 111 } 112 return ctx, berr 113 }) 114 115 s.Step(`^the stop orders should have the following states$`, func(table *godog.Table) error { 116 return steps.TheStopOrdersShouldHaveTheFollowingStates(execsetup.broker, table) 117 }) 118 119 // delegation/validator steps 120 s.Step(`the validators:$`, func(table *godog.Table) error { 121 return steps.TheValidators(execsetup.topology, execsetup.stakingAccount, execsetup.delegationEngine, table) 122 }) 123 s.Step(`^the parties should have the following delegation balances for epoch (\d+):$`, func(epoch string, table *godog.Table) error { 124 return steps.PartiesShouldHaveTheFollowingDelegationBalances(execsetup.broker, table, epoch) 125 }) 126 127 s.Step(`^the validators should have the following val scores for epoch (\d+):$`, func(epoch string, table *godog.Table) error { 128 return steps.ValidatorsShouldHaveTheFollowingScores(execsetup.broker, table, epoch) 129 }) 130 s.Step(`^the parties receive the following reward for epoch (\d+):$`, func(epoch string, table *godog.Table) error { 131 return steps.PartiesShouldReceiveTheFollowingReward(execsetup.broker, table, epoch) 132 }) 133 s.Step(`^the current epoch is "([^"]+)"$`, func(epoch string) error { 134 return steps.TheCurrentEpochIs(execsetup.broker, epoch) 135 }) 136 137 // Market steps 138 s.Step(`the simple risk model named "([^"]*)":$`, func(name string, table *godog.Table) error { 139 return steps.TheSimpleRiskModel(marketConfig, name, table) 140 }) 141 s.Step(`the log normal risk model named "([^"]*)":$`, func(name string, table *godog.Table) error { 142 return steps.TheLogNormalRiskModel(marketConfig, name, table) 143 }) 144 s.Step(`the fees configuration named "([^"]*)":$`, func(name string, table *godog.Table) error { 145 return steps.TheFeesConfiguration(marketConfig, name, table) 146 }) 147 s.Step(`^the oracle spec for settlement data filtering data from "([^"]*)" named "([^"]*)":$`, func(signers string, name string, table *godog.Table) error { 148 return steps.TheOracleSpec(marketConfig, name, "settlement data", signers, table) 149 }) 150 s.Step(`^the oracle spec for trading termination filtering data from "([^"]*)" named "([^"]*)":$`, func(signers string, name string, table *godog.Table) error { 151 return steps.TheOracleSpec(marketConfig, name, "trading termination", signers, table) 152 }) 153 s.Step(`^the settlement data decimals for the oracle named "([^"]*)" is given in "([^"]*)" decimal places$`, func(name, decimals string) error { 154 return steps.OracleSpecSettlementDataDecimals(marketConfig, name, decimals) 155 }) 156 s.Step(`^the perpetual oracles from "([^"]+)":`, func(signers string, table *godog.Table) error { 157 return steps.ThePerpsOracleSpec(marketConfig, signers, table) 158 }) 159 s.Step(`^the composite price oracles from "([^"]+)":`, func(signers string, table *godog.Table) error { 160 return steps.TheCompositePriceOracleSpec(marketConfig, signers, table) 161 }) 162 s.Step(`^the time triggers oracle spec is:`, func(table *godog.Table) error { 163 return steps.TheTimeTriggerOracleSpec(marketConfig, execsetup.timeService.GetTimeNow(), table) 164 }) 165 s.Step(`the price monitoring named "([^"]*)":$`, func(name string, table *godog.Table) error { 166 return steps.ThePriceMonitoring(marketConfig, name, table) 167 }) 168 s.Step(`the liquidity sla params named "([^"]*)":$`, func(name string, table *godog.Table) error { 169 return steps.TheLiquiditySLAPArams(marketConfig, name, table) 170 }) 171 s.Step(`the liquidity monitoring parameters:$`, func(table *godog.Table) error { 172 return steps.TheLiquidityMonitoring(marketConfig, table) 173 }) 174 s.Step(`the margin calculator named "([^"]*)":$`, func(name string, table *godog.Table) error { 175 return steps.TheMarginCalculator(marketConfig, name, table) 176 }) 177 s.Step(`^the parties submit update margin mode:$`, func(table *godog.Table) error { 178 return steps.ThePartiesUpdateMarginMode(execsetup.executionEngine, table) 179 }) 180 181 s.Step(`^the markets:$`, func(table *godog.Table) error { 182 markets, err := steps.TheMarkets(marketConfig, execsetup.executionEngine, execsetup.collateralEngine, execsetup.netParams, execsetup.timeService.GetTimeNow(), table) 183 execsetup.markets = markets 184 return err 185 }) 186 s.Step(`^the spot markets:$`, func(table *godog.Table) error { 187 markets, err := steps.TheSpotMarkets(marketConfig, execsetup.executionEngine, execsetup.collateralEngine, execsetup.timeService.GetTimeNow(), table) 188 execsetup.markets = markets 189 return err 190 }) 191 s.Step(`^the markets are updated:$`, func(table *godog.Table) error { 192 markets, err := steps.TheMarketsUpdated(marketConfig, execsetup.executionEngine, execsetup.markets, execsetup.netParams, table) 193 if err != nil { 194 return err 195 } 196 execsetup.markets = markets 197 return nil 198 }) 199 200 s.Step(`^the spot markets are updated:$`, func(table *godog.Table) error { 201 markets, err := steps.TheSpotMarketsUpdated(marketConfig, execsetup.executionEngine, execsetup.markets, execsetup.netParams, table) 202 if err != nil { 203 return err 204 } 205 execsetup.markets = markets 206 return nil 207 }) 208 209 s.Step(`the successor market "([^"]+)" is enacted$`, func(successor string) error { 210 if err := steps.TheSuccesorMarketIsEnacted(successor, execsetup.markets, execsetup.executionEngine); err != nil { 211 return err 212 } 213 return nil 214 }) 215 216 // Other steps 217 s.Step(`^the initial insurance pool balance is "([^"]*)" for all the markets$`, func(amountstr string) error { 218 amount, _ := num.UintFromString(amountstr, 10) 219 for _, mkt := range execsetup.markets { 220 assets, _ := mkt.GetAssets() 221 marketInsuranceAccount, err := execsetup.collateralEngine.GetMarketInsurancePoolAccount(mkt.ID, assets[0]) 222 if err != nil { 223 return err 224 } 225 if err := execsetup.collateralEngine.IncrementBalance(context.Background(), marketInsuranceAccount.ID, amount); err != nil { 226 return err 227 } 228 execsetup.insurancePoolDepositsOverStep[marketInsuranceAccount.ID] = num.IntFromUint(amount, true) 229 // add to the net deposits 230 execsetup.netDeposits.Add(execsetup.netDeposits, amount) 231 } 232 return nil 233 }) 234 235 s.Step(`^the active pap id should be "([^"]+)" for the market "([^"]+)"$`, func(mpAlgo, marketID string) error { 236 return steps.TheActivePAPIDShouldBeForMarket(execsetup.executionEngine, marketID, mpAlgo) 237 }) 238 s.Step(`^the active pap order id should be "([^"]+)" for the market "([^"]+)"$`, func(mpAlgo, marketID string) error { 239 return steps.TheActivePAPOrderIDShouldBeForMarket(execsetup.executionEngine, marketID, mpAlgo) 240 }) 241 242 s.Step(`^the mark price algo should be "([^"]+)" for the market "([^"]+)"$`, func(mpAlgo, marketID string) error { 243 return steps.TheMarkPriceAlgoShouldBeForMarket(execsetup.broker, marketID, mpAlgo) 244 }) 245 246 s.Step(`^the last market state should be "([^"]+)" for the market "([^"]+)"$`, func(mState, marketID string) error { 247 return steps.TheLastStateUpdateShouldBeForMarket(execsetup.broker, marketID, mState) 248 }) 249 s.Step(`^the market state should be "([^"]*)" for the market "([^"]*)"$`, func(marketState, marketID string) error { 250 return steps.TheMarketStateShouldBeForMarket(execsetup.executionEngine, marketID, marketState) 251 }) 252 s.Step(`^the following network parameters are set:$`, func(table *godog.Table) error { 253 return steps.TheFollowingNetworkParametersAreSet(execsetup.netParams, table) 254 }) 255 s.Step(`^the market states are updated through governance:`, func(data *godog.Table) error { 256 return steps.TheMarketStateIsUpdatedTo(execsetup.executionEngine, data) 257 }) 258 s.Step(`^time is updated to "([^"]*)"$`, func(rawTime string) error { 259 steps.TimeIsUpdatedTo(execsetup.executionEngine, execsetup.timeService, rawTime) 260 return nil 261 }) 262 s.Step(`^the parties cancel the following orders:$`, func(table *godog.Table) error { 263 return steps.PartiesCancelTheFollowingOrders(execsetup.broker, execsetup.executionEngine, table) 264 }) 265 s.Step(`^the parties cancel the following stop orders:$`, func(table *godog.Table) error { 266 return steps.PartiesCancelTheFollowingStopOrders(execsetup.broker, execsetup.executionEngine, table) 267 }) 268 s.Step(`^the party "([^"]*)" cancels all their stop orders for the market "([^"]*)"$`, func(partyId, marketId string) error { 269 return steps.PartyCancelsAllTheirStopOrdersForTheMarket(execsetup.executionEngine, partyId, marketId) 270 }) 271 s.Step(`^the party "([^"]*)" cancels all their stop orders`, func(partyId string) error { 272 return steps.PartyCancelsAllTheirStopOrders(execsetup.executionEngine, partyId) 273 }) 274 s.Step(`^the parties cancel all their orders for the markets:$`, func(table *godog.Table) error { 275 return steps.PartiesCancelAllTheirOrdersForTheMarkets(execsetup.broker, execsetup.executionEngine, table) 276 }) 277 s.Step(`^the parties amend the following orders:$`, func(table *godog.Table) error { 278 return steps.PartiesAmendTheFollowingOrders(execsetup.broker, execsetup.executionEngine, table) 279 }) 280 s.Step(`^the parties place the following pegged orders:$`, func(table *godog.Table) error { 281 return steps.PartiesPlaceTheFollowingPeggedOrders(execsetup.executionEngine, table) 282 }) 283 s.Step(`^the parties deposit on asset's general account the following amount:$`, func(table *godog.Table) error { 284 return steps.PartiesDepositTheFollowingAssets(execsetup.collateralEngine, execsetup.broker, execsetup.netDeposits, table) 285 }) 286 s.Step(`^the parties deposit on staking account the following amount:$`, func(table *godog.Table) error { 287 return steps.PartiesTransferToStakingAccount(execsetup.stakingAccount, execsetup.broker, table, "") 288 }) 289 s.Step(`^the parties withdraw from staking account the following amount:$`, func(table *godog.Table) error { 290 return steps.PartiesWithdrawFromStakingAccount(execsetup.stakingAccount, execsetup.broker, table) 291 }) 292 293 s.Step(`^the parties withdraw the following assets:$`, func(table *godog.Table) error { 294 return steps.PartiesWithdrawTheFollowingAssets(execsetup.collateralEngine, execsetup.broker, execsetup.netDeposits, table) 295 }) 296 s.Step(`^the parties place the following orders:$`, func(table *godog.Table) error { 297 return steps.PartiesPlaceTheFollowingOrders(execsetup.executionEngine, execsetup.timeService, table) 298 }) 299 s.Step(`^the parties place the following hacked orders:$`, func(table *godog.Table) error { 300 return steps.PartiesPlaceTheFollowingHackedOrders(execsetup.executionEngine, execsetup.timeService, table) 301 }) 302 s.Step(`^the party "([^"]+)" adds the following orders to a batch:$`, func(party string, table *godog.Table) error { 303 return steps.PartyAddsTheFollowingOrdersToABatch(party, execsetup.executionEngine, execsetup.timeService, table) 304 }) 305 306 s.Step(`^the party "([^"]+)" adds the following cancels to a batch:$`, func(party string, table *godog.Table) error { 307 return steps.PartyAddsTheFollowingCancelsToABatch(party, execsetup.executionEngine, execsetup.timeService, table) 308 }) 309 310 s.Step(`^the party "([^"]+)" adds the following amends to a batch:$`, func(party string, table *godog.Table) error { 311 return steps.PartyAddsTheFollowingAmendsToABatch(party, execsetup.executionEngine, execsetup.timeService, table) 312 }) 313 314 s.Step(`^the party "([^"]+)" adds the following iceberg orders to a batch:$`, func(party string, table *godog.Table) error { 315 return steps.PartyAddsTheFollowingIcebergOrdersToABatch(party, execsetup.executionEngine, execsetup.timeService, table) 316 }) 317 318 s.Step(`^the party "([^"]+)" starts a batch instruction$`, func(party string) error { 319 return steps.PartyStartsABatchInstruction(party, execsetup.executionEngine) 320 }) 321 322 s.Step(`^the party "([^"]+)" submits their batch instruction$`, func(party string) error { 323 return steps.PartySubmitsTheirBatchInstruction(party, execsetup.executionEngine) 324 }) 325 s.Step(`^the party "([^"]+)" submits their batch instruction with error "([^"]+)"$`, func(party, err string) error { 326 return steps.PartySubmitsTheirBatchInstructionWithError(party, err, execsetup.executionEngine) 327 }) 328 329 s.Step(`^the parties place the following orders "([^"]+)" blocks apart:$`, func(blockCount string, table *godog.Table) error { 330 return steps.PartiesPlaceTheFollowingOrdersBlocksApart(execsetup.executionEngine, execsetup.timeService, execsetup.block, execsetup.epochEngine, table, blockCount) 331 }) 332 s.Step(`^the parties place the following orders with ticks:$`, func(table *godog.Table) error { 333 return steps.PartiesPlaceTheFollowingOrdersWithTicks(execsetup.executionEngine, execsetup.timeService, execsetup.epochEngine, table) 334 }) 335 336 s.Step(`^the parties submit the following liquidity provision:$`, func(table *godog.Table) error { 337 return steps.PartiesSubmitLiquidityProvision(execsetup.executionEngine, table) 338 }) 339 s.Step(`^party "([^"]+)" cancels their liquidity provision for market "([^"]+)"$`, func(party, marketID string) error { 340 return steps.PartyCancelsTheirLiquidityProvision(execsetup.executionEngine, marketID, party) 341 }) 342 s.Step(`^the parties submit the following one off transfers:$`, func(table *godog.Table) error { 343 return steps.PartiesSubmitTransfers(execsetup.banking, table) 344 }) 345 s.Step(`^the parties submit the following recurring transfers:$`, func(table *godog.Table) error { 346 return steps.PartiesSubmitRecurringTransfers(execsetup.banking, table) 347 }) 348 s.Step(`^the parties submit the following transfer cancellations:$`, func(table *godog.Table) error { 349 return steps.PartiesCancelTransfers(execsetup.banking, table) 350 }) 351 s.Step(`^the parties have the following transfer fee discounts`, func(table *godog.Table) error { 352 return steps.PartiesAvailableFeeDiscounts(execsetup.banking, table) 353 }) 354 s.Step(`^the parties submit the following delegations:$`, func(table *godog.Table) error { 355 return steps.PartiesDelegateTheFollowingStake(execsetup.delegationEngine, table) 356 }) 357 s.Step(`^the parties submit the following undelegations:$`, func(table *godog.Table) error { 358 return steps.PartiesUndelegateTheFollowingStake(execsetup.delegationEngine, table) 359 }) 360 s.Step(`the protocol automated purchase is defined as:$`, func(table *godog.Table) error { 361 return steps.TheAutomatedPurchasePrograms(marketConfig, execsetup.executionEngine, table) 362 }) 363 s.Step(`^the starting auction time for market "([^"]+)" is "([^"]+)"`, func(marketID, startTime string) error { 364 return steps.MarketAuctionStartTime(execsetup.executionEngine, marketID, startTime) 365 }) 366 s.Step(`^the ending auction time for market "([^"]+)" is "([^"]+)"`, func(marketID, endTime string) error { 367 return steps.MarketAuctionEndTime(execsetup.executionEngine, marketID, endTime) 368 }) 369 370 s.Step(`^the opening auction period ends for market "([^"]+)"$`, func(marketID string) error { 371 return steps.MarketOpeningAuctionPeriodEnds(execsetup.executionEngine, execsetup.timeService, execsetup.markets, marketID) 372 }) 373 s.Step(`^the oracles broadcast data signed with "([^"]*)":$`, func(pubKeys string, properties *godog.Table) error { 374 return steps.OraclesBroadcastDataSignedWithKeys(execsetup.oracleEngine, execsetup.timeService, pubKeys, properties) 375 }) 376 s.Step(`^the oracles broadcast data with block time signed with "([^"]*)":$`, func(pubKeys string, properties *godog.Table) error { 377 return steps.OraclesBroadcastDataWithBlockTimeSignedWithKeys(execsetup.oracleEngine, execsetup.timeService, pubKeys, properties) 378 }) 379 s.Step(`^the following LP events should be emitted:$`, func(table *godog.Table) error { 380 return steps.TheFollowingLPEventsShouldBeEmitted(execsetup.broker, table) 381 }) 382 383 s.Step(`the following orders are cancelled on market "([^"]+)":$`, func(market string, table *godog.Table) error { 384 return steps.TheCancelledOrdersEventContains(execsetup.broker, market, table) 385 }) 386 387 // block time stuff 388 s.Step(`^the average block duration is "([^"]+)" with variance "([^"]+)"$`, func(block, variance string) error { 389 return steps.TheAverageBlockDurationWithVariance(execsetup.block, block, variance) 390 }) 391 s.Step(`^the average block duration is "([^"]+)"$`, func(blockTime string) error { 392 return steps.TheAverageBlockDurationIs(execsetup.block, blockTime) 393 }) 394 395 s.Step(`^the parties place the following iceberg orders:$`, func(table *godog.Table) error { 396 return steps.PartiesPlaceTheFollowingIcebergOrders(execsetup.executionEngine, execsetup.timeService, table) 397 }) 398 399 s.Step(`^the parties place the following pegged iceberg orders:$`, func(table *godog.Table) error { 400 return steps.PartiesPlaceTheFollowingPeggedIcebergOrders(execsetup.executionEngine, execsetup.timeService, table) 401 }) 402 403 s.Step(`^the parties amend the following pegged iceberg orders:$`, func(table *godog.Table) error { 404 return steps.PartiesAmendTheFollowingPeggedIcebergOrders(execsetup.broker, execsetup.executionEngine, execsetup.timeService, table) 405 }) 406 407 s.Step(`^the iceberg orders should have the following states:$`, func(table *godog.Table) error { 408 return steps.TheIcebergOrdersShouldHaveTheFollowingStates(execsetup.broker, table) 409 }) 410 411 s.Step(`the network moves ahead "([^"]+)" blocks`, func(blocks string) error { 412 return steps.TheNetworkMovesAheadNBlocks(execsetup.executionEngine, execsetup.block, execsetup.timeService, blocks, execsetup.epochEngine) 413 }) 414 s.Step(`the network moves ahead "([^"]+)" with block duration of "([^"]+)"`, func(total, block string) error { 415 return steps.TheNetworkMovesAheadDurationWithBlocks(execsetup.executionEngine, execsetup.block, execsetup.timeService, total, block) 416 }) 417 s.Step(`^the network moves ahead "([^"]+)" epochs$`, func(epochs string) error { 418 return steps.TheNetworkMovesAheadNEpochs(execsetup.broker, execsetup.block, execsetup.executionEngine, execsetup.epochEngine, execsetup.timeService, epochs) 419 }) 420 421 s.Step(`^the automated purchase program for market "([^"]*)" should have a snapshot balance of "([^"]*)"$`, func(marketID, balance string) error { 422 return steps.PAPVolumeSnapshotShouldBe(execsetup.broker, marketID, balance) 423 }) 424 425 // Assertion steps 426 s.Step(`^the parties should have the following staking account balances:$`, func(table *godog.Table) error { 427 return steps.PartiesShouldHaveTheFollowingStakingAccountBalances(execsetup.stakingAccount, table) 428 }) 429 s.Step(`^the parties should have the following account balances:$`, func(table *godog.Table) error { 430 return steps.PartiesShouldHaveTheFollowingAccountBalances(execsetup.executionEngine, execsetup.broker, table) 431 }) 432 s.Step(`^the parties should have the following margin levels:$`, func(table *godog.Table) error { 433 return steps.ThePartiesShouldHaveTheFollowingMarginLevels(execsetup.broker, table) 434 }) 435 s.Step(`^the parties should have the following profit and loss:$`, func(table *godog.Table) error { 436 return steps.PartiesHaveTheFollowingProfitAndLoss(execsetup.executionEngine, execsetup.positionPlugin, table) 437 }) 438 s.Step(`^the order book should have the following volumes for market "([^"]*)":$`, func(marketID string, table *godog.Table) error { 439 return steps.TheOrderBookOfMarketShouldHaveTheFollowingVolumes(execsetup.broker, marketID, table) 440 }) 441 s.Step(`^the orders should have the following status:$`, func(table *godog.Table) error { 442 return steps.TheOrdersShouldHaveTheFollowingStatus(execsetup.broker, table) 443 }) 444 s.Step(`^the orders should have the following states:$`, func(table *godog.Table) error { 445 return steps.TheOrdersShouldHaveTheFollowingStates(execsetup.broker, table) 446 }) 447 s.Step(`^the pegged orders should have the following states:$`, func(table *godog.Table) error { 448 return steps.ThePeggedOrdersShouldHaveTheFollowingStates(execsetup.broker, table) 449 }) 450 s.Step(`^the following orders should be rejected:$`, func(table *godog.Table) error { 451 return steps.TheFollowingOrdersShouldBeRejected(execsetup.broker, table) 452 }) 453 s.Step(`^the following orders should be stopped:$`, func(table *godog.Table) error { 454 return steps.TheFollowingOrdersShouldBeStopped(execsetup.broker, table) 455 }) 456 s.Step(`^"([^"]*)" should have general account balance of "([^"]*)" for asset "([^"]*)"$`, func(party, balance, asset string) error { 457 return steps.PartyShouldHaveGeneralAccountBalanceForAsset(execsetup.broker, party, asset, balance) 458 }) 459 s.Step(`^"([^"]*)" should have vesting account balance of "([^"]*)" for asset "([^"]*)"$`, func(party, balance, asset string) error { 460 return steps.PartyShouldHaveVestingAccountBalanceForAsset(execsetup.broker, party, asset, balance) 461 }) 462 s.Step(`^parties should have the following vesting account balances:$`, func(table *godog.Table) error { 463 return steps.PartiesShouldHaveVestingAccountBalances(execsetup.broker, table) 464 }) 465 s.Step(`^parties should have the following vested account balances:$`, func(table *godog.Table) error { 466 return steps.PartiesShouldHaveVestedAccountBalances(execsetup.broker, table) 467 }) 468 s.Step(`^"([^"]*)" should have vested account balance of "([^"]*)" for asset "([^"]*)"$`, func(party, balance, asset string) error { 469 return steps.PartyShouldHaveVestedAccountBalanceForAsset(execsetup.broker, party, asset, balance) 470 }) 471 s.Step(`^"([^"]*)" should have holding account balance of "([^"]*)" for asset "([^"]*)"$`, func(party, balance, asset string) error { 472 return steps.PartyShouldHaveHoldingAccountBalanceForAsset(execsetup.broker, party, asset, balance) 473 }) 474 s.Step(`^the reward account of type "([^"]*)" should have balance of "([^"]*)" for asset "([^"]*)"$`, func(accountType, balance, asset string) error { 475 return steps.RewardAccountBalanceForAssetShouldMatch(execsetup.broker, accountType, asset, balance) 476 }) 477 s.Step(`^"([^"]*)" should have one account per asset$`, func(owner string) error { 478 return steps.PartyShouldHaveOneAccountPerAsset(execsetup.broker, owner) 479 }) 480 s.Step(`^"([^"]*)" should have only the following accounts:$`, func(owner string, table *godog.Table) error { 481 return steps.PartyShouldHaveOnlyTheFollowingAccounts(execsetup.broker, owner, table) 482 }) 483 s.Step(`^"([^"]*)" should have one margin account per market$`, func(owner string) error { 484 return steps.PartyShouldHaveOneMarginAccountPerMarket(execsetup.broker, owner) 485 }) 486 s.Step(`^the cumulated balance for all accounts should be worth "([^"]*)"$`, func(rawAmount string) error { 487 return steps.TheCumulatedBalanceForAllAccountsShouldBeWorth(execsetup.broker, rawAmount) 488 }) 489 s.Step(`^the settlement account should have a balance of "([^"]*)" for the market "([^"]*)"$`, func(rawAmount, marketID string) error { 490 return steps.TheSettlementAccountShouldHaveBalanceForMarket(execsetup.broker, rawAmount, marketID) 491 }) 492 s.Step(`^the following network trades should be executed:$`, func(table *godog.Table) error { 493 return steps.TheFollowingNetworkTradesShouldBeExecuted(execsetup.broker, table) 494 }) 495 s.Step(`^the following trades should be executed:$`, func(table *godog.Table) error { 496 return steps.TheFollowingTradesShouldBeExecuted(execsetup.executionEngine, execsetup.broker, table) 497 }) 498 s.Step(`^the trading mode should be "([^"]*)" for the market "([^"]*)"$`, func(tradingMode, marketID string) error { 499 return steps.TheTradingModeShouldBeForMarket(execsetup.executionEngine, marketID, tradingMode) 500 }) 501 s.Step(`^the insurance pool balance should be "([^"]*)" for the market "([^"]*)"$`, func(rawAmount, marketID string) error { 502 return steps.TheInsurancePoolBalanceShouldBeForTheMarket(execsetup.broker, rawAmount, marketID) 503 }) 504 s.Step(`^the network treasury balance should be "([^"]*)" for the asset "([^"]*)"$`, func(rawAmount, asset string) error { 505 return steps.TheNetworkTreasuryBalanceShouldBeForTheAsset(execsetup.broker, rawAmount, asset) 506 }) 507 s.Step(`^the buy back fees balance should be "([^"]*)" for the asset "([^"]*)"$`, func(rawAmount, asset string) error { 508 return steps.TheBuyBackFeesBalanceShouldBeForTheAsset(execsetup.broker, rawAmount, asset) 509 }) 510 s.Step(`^the global insurance pool balance should be "([^"]*)" for the asset "([^"]*)"$`, func(rawAmount, asset string) error { 511 return steps.TheGlobalInsuranceBalanceShouldBeForTheAsset(execsetup.broker, rawAmount, asset) 512 }) 513 s.Step(`^the party "([^"]*)" lp liquidity fee account balance should be "([^"]*)" for the market "([^"]*)"$`, func(party, rawAmount, market string) error { 514 return steps.TheLPLiquidityFeeBalanceShouldBeForTheMarket(execsetup.broker, party, rawAmount, market) 515 }) 516 s.Step(`^the party "([^"]*)" lp liquidity bond account balance should be "([^"]*)" for the market "([^"]*)"$`, func(party, rawAmount, market string) error { 517 return steps.TheLPLiquidityBondBalanceShouldBeForTheMarket(execsetup.broker, party, rawAmount, market) 518 }) 519 s.Step(`^the transfers of following types should NOT happen:$`, func(table *godog.Table) error { 520 return steps.TheTransfersOfFollowingTypesShouldNotHappen(execsetup.broker, table) 521 }) 522 s.Step(`^the transfers of following types should happen:$`, func(table *godog.Table) error { 523 return steps.TheTransfersOfFollowingTypesShouldHappen(execsetup.broker, table) 524 }) 525 s.Step(`^the following transfers should happen:$`, func(table *godog.Table) error { 526 return steps.TheFollowingTransfersShouldHappen(execsetup.broker, execsetup.executionEngine, table) 527 }) 528 s.Step(`^the mark price should be "([^"]*)" for the market "([^"]*)"$`, func(rawMarkPrice, marketID string) error { 529 return steps.TheMarkPriceForTheMarketIs(execsetup.executionEngine, marketID, rawMarkPrice) 530 }) 531 s.Step(`^the liquidity provisions should have the following states:$`, func(table *godog.Table) error { 532 return steps.TheLiquidityProvisionsShouldHaveTheFollowingStates(execsetup.broker, table) 533 }) 534 s.Step(`^the target stake should be "([^"]*)" for the market "([^"]*)"$`, func(stake, marketID string) error { 535 return steps.TheTargetStakeShouldBeForMarket(execsetup.executionEngine, marketID, stake) 536 }) 537 s.Step(`^the supplied stake should be "([^"]*)" for the market "([^"]*)"$`, func(stake, marketID string) error { 538 return steps.TheSuppliedStakeShouldBeForTheMarket(execsetup.executionEngine, marketID, stake) 539 }) 540 s.Step(`^the open interest should be "([^"]*)" for the market "([^"]*)"$`, func(stake, marketID string) error { 541 return steps.TheOpenInterestShouldBeForTheMarket(execsetup.executionEngine, marketID, stake) 542 }) 543 s.Step(`^the liquidity provider fee shares for the market "([^"]*)" should be:$`, func(marketID string, table *godog.Table) error { 544 return steps.TheLiquidityProviderFeeSharesForTheMarketShouldBe(execsetup.executionEngine, marketID, table) 545 }) 546 s.Step(`^the price monitoring bounds for the market "([^"]*)" should be:$`, func(marketID string, table *godog.Table) error { 547 return steps.ThePriceMonitoringBoundsForTheMarketShouldBe(execsetup.executionEngine, marketID, table) 548 }) 549 s.Step(`^the accumulated liquidity fees should be "([^"]*)" for the market "([^"]*)"$`, func(amount, marketID string) error { 550 return steps.TheAccumulatedLiquidityFeesShouldBeForTheMarket(execsetup.broker, amount, marketID) 551 }) 552 s.Step(`^the accumulated infrastructure fees should be "([^"]*)" for the asset "([^"]*)"$`, func(amount, asset string) error { 553 return steps.TheAccumulatedInfrastructureFeesShouldBeForTheMarket(execsetup.broker, amount, asset) 554 }) 555 s.Step(`^the liquidity fee factor should be "([^"]*)" for the market "([^"]*)"$`, func(fee, marketID string) error { 556 return steps.TheLiquidityFeeFactorShouldForTheMarket(execsetup.broker, fee, marketID) 557 }) 558 s.Step(`^the market data for the market "([^"]+)" should be:$`, func(marketID string, table *godog.Table) error { 559 return steps.TheMarketDataShouldBe(execsetup.executionEngine, marketID, table) 560 }) 561 s.Step(`^the product data for the market "([^"]+)" should be:$`, func(marketID string, table *godog.Table) error { 562 return steps.TheProductDataShouldBe(execsetup.executionEngine, marketID, table) 563 }) 564 s.Step(`the auction ends with a traded volume of "([^"]+)" at a price of "([^"]+)"`, func(vol, price string) error { 565 now := execsetup.timeService.GetTimeNow() 566 return steps.TheAuctionTradedVolumeAndPriceShouldBe(execsetup.broker, vol, price, now) 567 }) 568 s.Step(expectingEventsOverStepText, func(eventCounter int) error { 569 return steps.ExpectingEventsOverStep(execsetup.broker, execsetup.eventsBefore, eventCounter) 570 }) 571 s.Step(`there were "([0-9]+)" events emitted in this scenario so far`, func(eventCounter int) error { 572 return steps.ExpectingEventsInTheSecenarioSoFar(execsetup.broker, eventCounter) 573 }) 574 s.Step(`fail`, func() { 575 reporter.Fatalf("fail step invoked") 576 }) 577 s.Step(`system unix time is "([^"]+)"`, func(unixTime int) error { 578 now := execsetup.timeService.GetTimeNow() 579 return steps.VerifyTime(now, int64(unixTime)) 580 }) 581 582 // Referral program steps. 583 s.Step(`^the referral program:$`, func(table *godog.Table) error { 584 return steps.TheReferralProgram(referralProgramConfig, execsetup.referralProgram, table) 585 }) 586 s.Step(`^the referral benefit tiers "([^"]+)":$`, func(name string, table *godog.Table) error { 587 return steps.TheReferralBenefitTiersConfiguration(referralProgramConfig, name, table) 588 }) 589 s.Step(`^the referral staking tiers "([^"]+)":$`, func(name string, table *godog.Table) error { 590 return steps.TheReferralStakingTiersConfiguration(referralProgramConfig, name, table) 591 }) 592 s.Step(`^the parties create the following referral codes:$`, func(table *godog.Table) error { 593 return steps.PartiesCreateTheFollowingReferralCode(execsetup.referralProgram, execsetup.teamsEngine, table) 594 }) 595 s.Step(`^the parties apply the following referral codes:$`, func(table *godog.Table) error { 596 return steps.PartiesApplyTheFollowingReferralCode(execsetup.referralProgram, execsetup.teamsEngine, table) 597 }) 598 s.Step(`^the team "([^"]*)" has the following members:$`, func(team string, table *godog.Table) error { 599 return steps.TheTeamHasTheFollowingMembers(execsetup.teamsEngine, team, table) 600 }) 601 s.Step(`^the following teams with referees are created:$`, func(table *godog.Table) error { 602 return steps.TheFollowingTeamsWithRefereesAreCreated(execsetup.collateralEngine, execsetup.broker, execsetup.netDeposits, execsetup.referralProgram, execsetup.teamsEngine, table) 603 }) 604 605 s.Step(`the referral set stats for code "([^"]+)" at epoch "([^"]+)" should have a running volume of (\d+):`, func(code, epoch, volume string, table *godog.Table) error { 606 return steps.TheReferralSetStatsShouldBe(execsetup.broker, code, epoch, volume, table) 607 }) 608 s.Step(`the activity streaks at epoch "([^"]+)" should be:`, func(epoch string, table *godog.Table) error { 609 return steps.TheActivityStreaksShouldBe(execsetup.broker, epoch, table) 610 }) 611 s.Step(`the vesting stats at epoch "([^"]+)" should be:`, func(epoch string, table *godog.Table) error { 612 return steps.TheVestingStatsShouldBe(execsetup.broker, epoch, table) 613 }) 614 s.Step(`the volume discount stats at epoch "([^"]+)" should be:`, func(epoch string, table *godog.Table) error { 615 return steps.TheVolumeDiscountStatsShouldBe(execsetup.broker, epoch, table) 616 }) 617 s.Step(`the average fill price is:`, func(table *godog.Table) error { 618 return steps.TheAverageFillPriceIs(execsetup.executionEngine, table) 619 }) 620 // AMM steps 621 s.Step(`^the parties submit the following AMM:$`, func(table *godog.Table) error { 622 return steps.PartiesSubmitTheFollowingAMMs(execsetup.executionEngine, table) 623 }) 624 s.Step(`^the parties amend the following AMM:$`, func(table *godog.Table) error { 625 return steps.PartiesAmendTheFollowingAMMs(execsetup.executionEngine, table) 626 }) 627 s.Step(`^the parties cancel the following AMM:$`, func(table *godog.Table) error { 628 return steps.PartiesCancelTheFollowingAMMs(execsetup.executionEngine, table) 629 }) 630 s.Step(`^the AMM pool status should be:$`, func(table *godog.Table) error { 631 return steps.AMMPoolStatusShouldBe(execsetup.broker, table) 632 }) 633 s.Step(`^the following AMM pool events should be emitted:$`, func(table *godog.Table) error { 634 return steps.ExpectToSeeAMMEvents(execsetup.broker, table) 635 }) 636 s.Step(`^set the following AMM sub account aliases:$`, func(table *godog.Table) error { 637 return steps.SetAMMPartyAlias(execsetup.broker, execsetup.executionEngine, table) 638 }) 639 s.Step(`^parties have the following AMM account balances:$`, func(table *godog.Table) error { 640 return steps.PartiesHaveTheFollowingAMMBalances(execsetup.broker, execsetup.executionEngine, table) 641 }) 642 // AMM specific debugging 643 s.Step(`^debug all AMM pool events$`, func() error { 644 return steps.DebugAMMPoolEvents(execsetup.broker, execsetup.log) 645 }) 646 s.Step(`^debug AMM pool events for party "([^"]+)"$`, func(party string) error { 647 return steps.DebugAMMPoolEventsForPartyMarket(execsetup.broker, execsetup.log, ptr.From(party), nil) 648 }) 649 s.Step(`^debug all AMM pool events for market "([^"]+)"$`, func(market string) error { 650 return steps.DebugAMMPoolEventsForPartyMarket(execsetup.broker, execsetup.log, nil, ptr.From(market)) 651 }) 652 s.Step(`^debug all AMM pool events for market "([^"]+)" and party "([^"]+)"$`, func(market, party string) error { 653 return steps.DebugAMMPoolEventsForPartyMarket(execsetup.broker, execsetup.log, ptr.From(party), ptr.From(market)) 654 }) 655 656 // Debug steps 657 s.Step(`^debug accounts$`, func() error { 658 steps.DebugAccounts(execsetup.broker, execsetup.log) 659 return nil 660 }) 661 s.Step(`^debug transfers$`, func() error { 662 steps.DebugTransfers(execsetup.broker, execsetup.log) 663 return nil 664 }) 665 s.Step(`^debug trades$`, func() error { 666 steps.DebugTrades(execsetup.broker, execsetup.log) 667 return nil 668 }) 669 s.Step(`^debug orders$`, func() error { 670 steps.DebugOrders(execsetup.broker, execsetup.log) 671 return nil 672 }) 673 s.Step(`^debug market data for "([^"]*)"$`, func(mkt string) error { 674 return steps.DebugMarketData(execsetup.executionEngine, execsetup.log, mkt) 675 }) 676 s.Step(`^debug all events$`, func() error { 677 steps.DebugAllEvents(execsetup.broker, execsetup.log) 678 return nil 679 }) 680 s.Step(`^debug all events as JSON file "([^"]+)"$`, func(fname string) error { 681 return steps.DebugAllEventsJSONFile(execsetup.broker, execsetup.log, fname) 682 }) 683 s.Step(`^debug auction events$`, func() error { 684 steps.DebugAuctionEvents(execsetup.broker, execsetup.log) 685 return nil 686 }) 687 s.Step(`^debug transaction errors$`, func() error { 688 steps.DebugTxErrors(execsetup.broker, execsetup.log) 689 return nil 690 }) 691 s.Step(`^debug liquidity submission errors$`, func() error { 692 steps.DebugLPSTxErrors(execsetup.broker, execsetup.log) 693 return nil 694 }) 695 s.Step(`^debug liquidity provision events$`, func() error { 696 steps.DebugLPs(execsetup.broker, execsetup.log) 697 return nil 698 }) 699 s.Step(`^debug detailed liquidity provision events$`, func() error { 700 steps.DebugLPDetail(execsetup.log, execsetup.broker) 701 return nil 702 }) 703 s.Step(`^debug funding period events$`, func() error { 704 steps.DebugFundingPeriodEventss(execsetup.broker, execsetup.log) 705 return nil 706 }) 707 s.Step(`^debug orderbook volumes for market "([^"]*)"$`, func(mkt string) error { 708 return steps.DebugVolumesForMarket(execsetup.log, execsetup.broker, mkt) 709 }) 710 s.Step(`^debug detailed orderbook volumes for market "([^"]*)"$`, func(mkt string) error { 711 return steps.DebugVolumesForMarketDetail(execsetup.log, execsetup.broker, mkt) 712 }) 713 s.Step(`^debug last "([0-9]+)" events$`, func(eventCounter int) error { 714 steps.DebugLastNEvents(eventCounter, execsetup.broker, execsetup.log) 715 return nil 716 }) 717 s.Step(`^debug network parameter "([^"]*)"$`, func(name string) error { 718 return steps.DebugNetworkParameter(execsetup.log, execsetup.netParams, name) 719 }) 720 s.Step(`^debug funding payment events$`, func() error { 721 steps.DebugFundingPaymentsEvents(execsetup.broker, execsetup.log) 722 return nil 723 }) 724 725 // Event steps 726 s.Step(`^clear all events$`, func() error { 727 steps.ClearAllEvents(execsetup.broker) 728 return nil 729 }) 730 s.Step(`^clear transfer response events$`, func() error { 731 steps.ClearTransferResponseEvents(execsetup.broker) 732 return nil 733 }) 734 735 s.Step(`^the following funding period events should be emitted:$`, func(table *godog.Table) error { 736 return steps.TheFollowingFundingPeriodEventsShouldBeEmitted(execsetup.broker, table) 737 }) 738 s.Step(`^the following funding payment events should be emitted:$`, func(table *godog.Table) error { 739 return steps.TheFollowingFundingPaymentEventsShouldBeEmitted(execsetup.broker, table) 740 }) 741 s.Step(`^the following events should be emitted:$`, func(table *godog.Table) error { 742 return steps.TheFollowingEventsShouldBeEmitted(execsetup.broker, table) 743 }) 744 s.Step(`^the following events should NOT be emitted:$`, func(table *godog.Table) error { 745 return steps.TheFollowingEventsShouldNotBeEmitted(execsetup.broker, table) 746 }) 747 s.Step(`^a total of "([0-9]+)" events should be emitted$`, func(eventCounter int) error { 748 return steps.TotalOfEventsShouldBeEmitted(execsetup.broker, eventCounter) 749 }) 750 s.Step(`^the loss socialisation amounts are:$`, func(table *godog.Table) error { 751 return steps.TheLossSocialisationAmountsAre(execsetup.broker, table) 752 }) 753 s.Step(`^debug loss socialisation events$`, func() error { 754 return steps.DebugLossSocialisationEvents(execsetup.broker, execsetup.log) 755 }) 756 757 // Decimal places steps 758 s.Step(`^the following assets are registered:$`, func(table *godog.Table) error { 759 return steps.RegisterAsset(table, execsetup.assetsEngine, execsetup.collateralEngine) 760 }) 761 s.Step(`^the following assets are updated:$`, func(table *godog.Table) error { 762 return steps.UpdateAsset(table, execsetup.assetsEngine, execsetup.collateralEngine) 763 }) 764 s.Step(`^set assets to strict$`, func() error { 765 execsetup.assetsEngine.SetStrict() 766 return nil 767 }) 768 s.Step(`^set assets to permissive$`, func() error { 769 execsetup.assetsEngine.SetPermissive() 770 return nil 771 }) 772 773 s.Step(`^the parties should have the following position changes for market "([^)]+)":$`, func(mkt string, table *godog.Table) error { 774 return steps.PartiesShouldHaveTheFollowingPositionStatus(execsetup.broker, mkt, table) 775 }) 776 777 s.Step(`^the parties should have the following aggregated position changes for market "([^)]+)":$`, func(mkt string, table *godog.Table) error { 778 return steps.PartiesShouldHaveTheFollowingPositionStatusAgg(execsetup.broker, mkt, table) 779 }) 780 781 s.Step(`^the volume discount program tiers named "([^"]*)":$`, func(vdp string, table *godog.Table) error { 782 return steps.VolumeDiscountProgramTiers(volumeDiscountTiers, vdp, table) 783 }) 784 785 s.Step(`^the volume discount program:$`, func(table *godog.Table) error { 786 return steps.VolumeDiscountProgram(execsetup.volumeDiscountProgram, volumeDiscountTiers, table) 787 }) 788 789 s.Step(`^the party "([^"]*)" has the following discount infra factor "([^"]*)"$`, func(party, discountFactor string) error { 790 return steps.PartyHasTheFollowingDiscountInfraFactor(party, discountFactor, execsetup.volumeDiscountProgram) 791 }) 792 793 s.Step(`^the party "([^"]*)" has the following discount maker factor "([^"]*)"$`, func(party, discountFactor string) error { 794 return steps.PartyHasTheFollowingDiscountMakerFactor(party, discountFactor, execsetup.volumeDiscountProgram) 795 }) 796 797 s.Step(`^the party "([^"]*)" has the following discount liquidity factor "([^"]*)"$`, func(party, discountFactor string) error { 798 return steps.PartyHasTheFollowingDiscountLiquidityFactor(party, discountFactor, execsetup.volumeDiscountProgram) 799 }) 800 801 s.Step(`^the parties have the following discount factors:$`, func(table *godog.Table) error { 802 return steps.PartiesHaveTheFollowingDiscountFactors(execsetup.volumeDiscountProgram, table) 803 }) 804 805 s.Step(`^the AMM "([^"]*)" has the following discount infra factor "([^"]*)"$`, func(alias, discountFactor string) error { 806 return steps.AMMHasTheFollowingDiscountInfraFactor(execsetup.executionEngine, execsetup.volumeDiscountProgram, alias, discountFactor) 807 }) 808 809 s.Step(`^the AMM "([^"]*)" has the following discount maker factor "([^"]*)"$`, func(alias, discountFactor string) error { 810 return steps.AMMHasTheFollowingDiscountMakerFactor(execsetup.executionEngine, execsetup.volumeDiscountProgram, alias, discountFactor) 811 }) 812 813 s.Step(`^the AMM "([^"]*)" has the following discount liquidity factor "([^"]*)"$`, func(alias, discountFactor string) error { 814 return steps.AMMHasTheFollowingDiscountLiquidityFactor(execsetup.executionEngine, execsetup.volumeDiscountProgram, alias, discountFactor) 815 }) 816 s.Step(`^the party "([^"]*)" has the following taker notional "([^"]*)"$`, func(party, notional string) error { 817 return steps.PartyHasTheFollowingTakerNotional(party, notional, execsetup.volumeDiscountProgram) 818 }) 819 820 s.Step(`^the AMM "([^"]+)" has the following taker notional "([^"]+)"$`, func(alias, notional string) error { 821 return steps.AMMHasTheFollowingNotionalValue(execsetup.executionEngine, execsetup.volumeDiscountProgram, alias, notional) 822 }) 823 824 s.Step(`^create the network treasury account for asset "([^"]*)"$`, func(asset string) error { 825 return steps.CreateNetworkTreasuryAccount(execsetup.collateralEngine, asset) 826 }) 827 828 s.Step(`the liquidation strategies:$`, func(table *godog.Table) error { 829 return steps.TheLiquidationStrategies(marketConfig, table) 830 }) 831 832 s.Step(`^clear trade events$`, func() error { 833 return steps.ClearTradeEvents(execsetup.broker) 834 }) 835 836 s.Step(`^the volume rebate program tiers named "([^"]*)":$`, func(vrp string, table *godog.Table) error { 837 return steps.VolumeRebateProgramTiers(volumeRebateTiers, vrp, table) 838 }) 839 840 s.Step(`^the volume rebate program:$`, func(table *godog.Table) error { 841 return steps.VolumeRebateProgram(execsetup.volumeRebateProgram, volumeRebateTiers, execsetup.timeService, table) 842 }) 843 s.Step(`^the party "([^"]*)" has the following rebate factor "([^"]*)"$`, func(party, rebate string) error { 844 return steps.PartyHasTheFollowingRebate(party, rebate, execsetup.volumeRebateProgram) 845 }) 846 s.Step(`^the AMM "([^"]*)" has the following rebate factor "([^"]*)"$`, func(alias, rebate string) error { 847 return steps.AMMHasTheFollowingRebate(execsetup.executionEngine, execsetup.volumeRebateProgram, alias, rebate) 848 }) 849 850 s.Step(`^the party "([^"]*)" has the following maker volume fraction "([^"]*)"$`, func(party, fraction string) error { 851 return steps.PartyHasTheFollowingMakerVolumeFraction(party, fraction, execsetup.volumeRebateProgram) 852 }) 853 854 s.Step(`^the AMM "([^"]+)" has the following maker volume fraction "([^"]+)"$`, func(alias, fraction string) error { 855 return steps.AMMHasTheFollowingMakerVolumeFraction(execsetup.executionEngine, execsetup.volumeRebateProgram, alias, fraction) 856 }) 857 858 // Long block auction steps 859 s.Step(`^the long block duration table is:$`, func(table *godog.Table) error { 860 return steps.TheLongBlockDurationTableIsUploaded(context.Background(), execsetup.executionEngine, table) 861 }) 862 863 s.Step(`^the previous block duration was "([^"]+)"$`, func(duration string) error { 864 return steps.ThePreviousBlockDurationWas(context.Background(), execsetup.executionEngine, duration) 865 }) 866 } 867 868 func reconcileAccounts() error { 869 return helpers.ReconcileAccountChanges(execsetup.collateralEngine, execsetup.accountsBefore, execsetup.broker.GetAccounts(), execsetup.insurancePoolDepositsOverStep, extractLedgerEntriesOverStep()) 870 } 871 872 func extractLedgerEntriesOverStep() []*vega.LedgerEntry { 873 transfers := execsetup.broker.GetTransfers(false) 874 n := len(transfers) - execsetup.ledgerMovementsBefore 875 ret := make([]*vega.LedgerEntry, 0, n) 876 if n > 0 { 877 for i := execsetup.ledgerMovementsBefore; i < len(transfers); i++ { 878 ret = append(ret, transfers[i]) 879 } 880 } 881 return ret 882 }