How to use paused method in wpt

Best JavaScript code snippet using wpt

testGovernanceForController.js

Source:testGovernanceForController.js Github

copy

Full Screen

1const { expect, util } = require("chai");2const { ethers } = require("hardhat");3const { utils, Contract } = require("ethers");4const {5 loadFixture,6 increaseBlock,7 fixtureDefault,8 deployRewardDistributor,9 deployMSDController,10 deployOracle,11 deployiToken,12} = require("../helpers/fixtures.js");13const { parseTokenAmount, setOraclePrices } = require("../helpers/utils.js");14const zeroAddress = ethers.constants.AddressZero;15const MAX = ethers.constants.MaxUint256;16const BASE = utils.parseEther("1");17const ZERO = ethers.BigNumber.from("0");18const blocksPerYear = ethers.BigNumber.from("2102400");19const abiCoder = new ethers.utils.AbiCoder();20let iUSDx, iUSDT, iWBTC, iETH, controller, interestRateModel;21let USDx, USDT, WBTC;22let users, user1, user2, user3, owner;23let lendingData;24let oracle;25let iTokenDecimals, iToken1Decimals;26let actualiTokenMintAmount, actualiToken1MintAmount;27let beforeController, mockController;28let beforeInterestRateModel, mockInterestRateModel;29let delta;30let xUSD, iMUSX, xUSDS, xEUR, iMEUX, xEURS;31let msdController;32let fixedInterestRateModel;33let timelock;34let newiToken;35describe("Governance Examination for Controller", function () {36 const rawMintAmount = ethers.BigNumber.from("500");37 async function init() {38 ({39 controller: controller,40 owner: owner,41 iToken0: iUSDx,42 underlying0: USDx,43 iToken1: iUSDT,44 underlying1: USDT,45 iToken2: iWBTC,46 underlying2: WBTC,47 iETH: iETH,48 interestRateModel: interestRateModel,49 accounts: users,50 flashloanExecutor: flashloanExecutor,51 flashloanExecutorFailure: flashloanExecutorFailure,52 priceOracle: oracle,53 lendingData: lendingData,54 fixedInterestRateModel: fixedInterestRateModel,55 xUSD: xUSD,56 iMUSX: iMUSX,57 xUSDS: xUSDS,58 xEUR: xEUR,59 iMEUX: iMEUX,60 xEURS: xEURS,61 msdController: msdController,62 } = await loadFixture(fixtureDefault));63 // [user1, user2, user3] = users;64 // Deploy the governance contract65 const Timelock = await ethers.getContractFactory("Timelock");66 timelock = await Timelock.deploy();67 await timelock.deployed();68 // Deploy a new iToken.69 newiToken = (70 await deployiToken(71 USDx.address,72 "New Tokne",73 "NT",74 controller.address,75 interestRateModel.address76 )77 ).iToken;78 await setOraclePrices(oracle, [newiToken], [1]);79 }80 describe("Test controller contract", function () {81 before("Transfer controller owner to timelock contract", async function () {82 await init();83 // transfer ownership to governance contract84 await controller._setPendingOwner(timelock.address);85 await timelock.executeTransaction(86 controller.address,87 0,88 "_acceptOwner()",89 "0x"90 );91 let owner = await controller.owner();92 expect(owner).to.equal(timelock.address);93 });94 it("Add new iToken to market", async function () {95 let input = "500000000000000000";96 let beforeAllTokensLength = (await controller.getAlliTokens()).length;97 let data = abiCoder.encode(98 ["address", "uint256", "uint256", "uint256", "uint256", "uint256"],99 [newiToken.address, input, input, input, input, input]100 );101 await timelock.executeTransaction(102 controller.address,103 0,104 "_addMarket(address,uint256,uint256,uint256,uint256,uint256)",105 data106 );107 let afterAllTokensLength = (await controller.getAlliTokens()).length;108 expect(beforeAllTokensLength + 1).to.equal(afterAllTokensLength);109 });110 it("Set new close factor", async function () {111 let closeFactor = "300000000000000000";112 let data = abiCoder.encode(["uint256"], [closeFactor]);113 await timelock.executeTransaction(114 controller.address,115 0,116 "_setCloseFactor(uint256)",117 data118 );119 let newCloseFactor = await controller.closeFactorMantissa();120 expect(newCloseFactor).to.equal(closeFactor);121 });122 it("Set new liquidation incentive", async function () {123 let liquidationIncentive = "1400000000000000000";124 let data = abiCoder.encode(["uint256"], [liquidationIncentive]);125 await timelock.executeTransaction(126 controller.address,127 0,128 "_setLiquidationIncentive(uint256)",129 data130 );131 let newLiquidationIncentive = await controller.liquidationIncentiveMantissa();132 expect(newLiquidationIncentive).to.equal(liquidationIncentive);133 });134 it("Set new collateral factor", async function () {135 let collateralFactor = "300000000000000000";136 let data = abiCoder.encode(137 ["address", "uint256"],138 [newiToken.address, collateralFactor]139 );140 await timelock.executeTransaction(141 controller.address,142 0,143 "_setCollateralFactor(address,uint256)",144 data145 );146 let newCollateralFactor = (await controller.markets(newiToken.address))147 .collateralFactorMantissa;148 expect(newCollateralFactor).to.equal(collateralFactor);149 });150 it("Set new borrow factor", async function () {151 let borrowFactor = "300000000000000000";152 let data = abiCoder.encode(153 ["address", "uint256"],154 [newiToken.address, borrowFactor]155 );156 await timelock.executeTransaction(157 controller.address,158 0,159 "_setBorrowFactor(address,uint256)",160 data161 );162 let newBorrowFactor = (await controller.markets(newiToken.address))163 .borrowFactorMantissa;164 expect(newBorrowFactor).to.equal(borrowFactor);165 });166 it("Set new supply capacity", async function () {167 let supplyCapacity = await parseTokenAmount(newiToken, "8545");168 let data = abiCoder.encode(169 ["address", "uint256"],170 [newiToken.address, supplyCapacity]171 );172 await timelock.executeTransaction(173 controller.address,174 0,175 "_setSupplyCapacity(address,uint256)",176 data177 );178 let newSupplyCapacity = (await controller.markets(newiToken.address))179 .supplyCapacity;180 expect(newSupplyCapacity).to.equal(supplyCapacity);181 });182 it("Set new borrow capacity", async function () {183 let borrowCapacity = await parseTokenAmount(newiToken, "7545");184 // let oldBorrowCapacity = (await controller.markets(newiToken.address)).borrowCapacity;185 // console.log("oldBorrowCapacity", oldBorrowCapacity.toString());186 let data = abiCoder.encode(187 ["address", "uint256"],188 [newiToken.address, borrowCapacity]189 );190 await timelock.executeTransaction(191 controller.address,192 0,193 "_setBorrowCapacity(address,uint256)",194 data195 );196 let newBorrowCapacity = (await controller.markets(newiToken.address))197 .borrowCapacity;198 // console.log("newBorrowCapacity", newBorrowCapacity.toString());199 expect(newBorrowCapacity).to.equal(borrowCapacity);200 });201 it("Set new pause guardian", async function () {202 let pauseGuardian = users[16];203 let data = abiCoder.encode(["address"], [pauseGuardian.address]);204 await timelock.executeTransaction(205 controller.address,206 0,207 "_setPauseGuardian(address)",208 data209 );210 let newPauseGuardian = await controller.pauseGuardian();211 expect(newPauseGuardian).to.equal(pauseGuardian.address);212 });213 it("Set iToken mint paused", async function () {214 let mintPaused = true;215 // let oldiTokenMintPaused = (await controller.markets(newiToken.address)).mintPaused;216 // console.log("oldiTokenMintPaused", oldiTokenMintPaused);217 let data = abiCoder.encode(218 ["address", "bool"],219 [newiToken.address, mintPaused]220 );221 await timelock.executeTransaction(222 controller.address,223 0,224 "_setMintPaused(address,bool)",225 data226 );227 let iTokenMintPaused = (await controller.markets(newiToken.address))228 .mintPaused;229 // console.log("iTokenMintPaused", iTokenMintPaused);230 expect(iTokenMintPaused).to.equal(mintPaused);231 });232 it("Set all iTokens mint paused", async function () {233 let mintPaused = true;234 // let oldiUSDTMintPaused = (await controller.markets(iUSDT.address)).mintPaused;235 // console.log("oldiUSDTMintPaused", oldiUSDTMintPaused);236 // let oldiUSDxMintPaused = (await controller.markets(iUSDx.address)).mintPaused;237 // console.log("oldiUSDxMintPaused", oldiUSDxMintPaused);238 let data = abiCoder.encode(["bool"], [mintPaused]);239 await timelock.executeTransaction(240 controller.address,241 0,242 "_setAllMintPaused(bool)",243 data244 );245 let newiUSDTMintPaused = (await controller.markets(iUSDT.address))246 .mintPaused;247 // console.log("newiUSDTMintPaused", newiUSDTMintPaused);248 let newiUSDxMintPaused = (await controller.markets(iUSDx.address))249 .mintPaused;250 // console.log("newiUSDxMintPaused", newiUSDxMintPaused);251 expect(newiUSDTMintPaused).to.equal(mintPaused);252 expect(newiUSDxMintPaused).to.equal(mintPaused);253 });254 it("Set iToken redeem paused", async function () {255 let redeemPaused = true;256 // let oldiTokenRedeemPaused = (await controller.markets(newiToken.address)).redeemPaused;257 // console.log("oldiTokenRedeemPaused", oldiTokenRedeemPaused);258 let data = abiCoder.encode(259 ["address", "bool"],260 [newiToken.address, redeemPaused]261 );262 await timelock.executeTransaction(263 controller.address,264 0,265 "_setRedeemPaused(address,bool)",266 data267 );268 let iTokenRedeemPaused = (await controller.markets(newiToken.address))269 .redeemPaused;270 // console.log("iTokenRedeemPaused", iTokenRedeemPaused);271 expect(iTokenRedeemPaused).to.equal(redeemPaused);272 });273 it("Set all iTokens redeem paused", async function () {274 let redeemPaused = true;275 // let oldiUSDTRedeemPaused = (await controller.markets(iUSDT.address)).redeemPaused;276 // console.log("oldiUSDTRedeemPaused", oldiUSDTRedeemPaused);277 // let oldiUSDxRedeemPaused = (await controller.markets(iUSDx.address)).redeemPaused;278 // console.log("oldiUSDxRedeemPaused", oldiUSDxRedeemPaused);279 let data = abiCoder.encode(["bool"], [redeemPaused]);280 await timelock.executeTransaction(281 controller.address,282 0,283 "_setAllRedeemPaused(bool)",284 data285 );286 let newiUSDTRedeemPaused = (await controller.markets(iUSDT.address))287 .redeemPaused;288 // console.log("newiUSDTRedeemPaused", newiUSDTRedeemPaused);289 let newiUSDxRedeemPaused = (await controller.markets(iUSDx.address))290 .redeemPaused;291 // console.log("newiUSDxRedeemPaused", newiUSDxRedeemPaused);292 expect(newiUSDTRedeemPaused).to.equal(redeemPaused);293 expect(newiUSDxRedeemPaused).to.equal(redeemPaused);294 });295 it("Set iToken borrow paused", async function () {296 let borrowPaused = true;297 // let oldiTokenBorrowPaused = (await controller.markets(newiToken.address)).borrowPaused;298 // console.log("oldiTokenBorrowPaused", oldiTokenBorrowPaused);299 let data = abiCoder.encode(300 ["address", "bool"],301 [newiToken.address, borrowPaused]302 );303 await timelock.executeTransaction(304 controller.address,305 0,306 "_setBorrowPaused(address,bool)",307 data308 );309 let iTokenBorrowPaused = (await controller.markets(newiToken.address))310 .borrowPaused;311 // console.log("iTokenBorrowPaused", iTokenBorrowPaused);312 expect(iTokenBorrowPaused).to.equal(borrowPaused);313 });314 it("Set all iTokens borrow paused", async function () {315 let borrowPaused = true;316 // let oldiUSDTBorrowPaused = (await controller.markets(iUSDT.address)).borrowPaused;317 // console.log("oldiUSDTBorrowPaused", oldiUSDTBorrowPaused);318 // let oldiUSDxBorrowPaused = (await controller.markets(iUSDx.address)).borrowPaused;319 // console.log("oldiUSDxBorrowPaused", oldiUSDxBorrowPaused);320 let data = abiCoder.encode(["bool"], [borrowPaused]);321 await timelock.executeTransaction(322 controller.address,323 0,324 "_setAllBorrowPaused(bool)",325 data326 );327 let newiUSDTBorrowPaused = (await controller.markets(iUSDT.address))328 .borrowPaused;329 // console.log("newiUSDTBorrowPaused", newiUSDTBorrowPaused);330 let newiUSDxBorrowPaused = (await controller.markets(iUSDx.address))331 .borrowPaused;332 // console.log("newiUSDxBorrowPaused", newiUSDxBorrowPaused);333 expect(newiUSDTBorrowPaused).to.equal(borrowPaused);334 expect(newiUSDxBorrowPaused).to.equal(borrowPaused);335 });336 it("Set iToken transfer paused", async function () {337 let transferPaused = true;338 // let oldiTokenTransferPaused = await controller.transferPaused();339 // console.log("oldiTokenTransferPaused", oldiTokenTransferPaused);340 let data = abiCoder.encode(["bool"], [transferPaused]);341 await timelock.executeTransaction(342 controller.address,343 0,344 "_setTransferPaused(bool)",345 data346 );347 let iTokenTransferPaused = await controller.transferPaused();348 // console.log("iTokenTransferPaused", iTokenTransferPaused);349 expect(iTokenTransferPaused).to.equal(transferPaused);350 });351 it("Set iToken seize paused", async function () {352 let seizePaused = true;353 // let oldiTokenSeizePaused = await controller.seizePaused();354 // console.log("oldiTokenSeizePaused", oldiTokenSeizePaused);355 let data = abiCoder.encode(["bool"], [seizePaused]);356 await timelock.executeTransaction(357 controller.address,358 0,359 "_setSeizePaused(bool)",360 data361 );362 let iTokenSeizePaused = await controller.seizePaused();363 // console.log("iTokenSeizePaused", iTokenSeizePaused);364 expect(iTokenSeizePaused).to.equal(seizePaused);365 });366 it("Set iToken paused to false", async function () {367 let paused = false;368 // let oldiTokenMintPaused = (await controller.markets(newiToken.address)).mintPaused;369 // console.log("oldiTokenMintPaused", oldiTokenMintPaused);370 // let oldiTokenBorrowPaused = (await controller.markets(newiToken.address)).borrowPaused;371 // console.log("oldiTokenBorrowPaused", oldiTokenBorrowPaused);372 // let oldiTokenRedeemPaused = (await controller.markets(newiToken.address)).redeemPaused;373 // console.log("oldiTokenRedeemPaused", oldiTokenRedeemPaused);374 let data = abiCoder.encode(375 ["address", "bool"],376 [newiToken.address, paused]377 );378 await timelock.executeTransaction(379 controller.address,380 0,381 "_setiTokenPaused(address,bool)",382 data383 );384 let newiTokenMintPaused = (await controller.markets(newiToken.address))385 .mintPaused;386 // console.log("newiTokenMintPaused", newiTokenMintPaused);387 let newiTokenBorrowPaused = (await controller.markets(newiToken.address))388 .borrowPaused;389 // console.log("newiTokenBorrowPaused", newiTokenBorrowPaused);390 let newiTokenRedeemPaused = (await controller.markets(newiToken.address))391 .redeemPaused;392 // console.log("newiTokenRedeemPaused", newiTokenRedeemPaused);393 expect(newiTokenMintPaused).to.equal(paused);394 expect(newiTokenBorrowPaused).to.equal(paused);395 expect(newiTokenRedeemPaused).to.equal(paused);396 });397 it("Set protocol paused to false", async function () {398 let paused = false;399 // let oldiUSDTMintPaused = (await controller.markets(iUSDT.address)).mintPaused;400 // console.log("oldiUSDTMintPaused", oldiUSDTMintPaused);401 // let oldiUSDxBorrowPaused = (await controller.markets(iUSDx.address)).borrowPaused;402 // console.log("oldiUSDxBorrowPaused", oldiUSDxBorrowPaused);403 // let oldiUSDTRedeemPaused = (await controller.markets(iUSDT.address)).redeemPaused;404 // console.log("oldiUSDTRedeemPaused", oldiUSDTRedeemPaused);405 // let oldiUSDxTransferPaused = await controller.transferPaused();406 // console.log("oldiUSDxTransferPaused", oldiUSDxTransferPaused);407 // let oldiUSDTSeizePaused = await controller.seizePaused();408 // console.log("oldiUSDTSeizePaused", oldiUSDTSeizePaused);409 let data = abiCoder.encode(["bool"], [paused]);410 await timelock.executeTransaction(411 controller.address,412 0,413 "_setProtocolPaused(bool)",414 data415 );416 let newiUSDTMintPaused = (await controller.markets(iUSDT.address))417 .mintPaused;418 // console.log("newiUSDTMintPaused", newiUSDTMintPaused);419 let newiUSDxBorrowPaused = (await controller.markets(iUSDx.address))420 .borrowPaused;421 // console.log("newiUSDxBorrowPaused", newiUSDxBorrowPaused);422 let newiUSDTRedeemPaused = (await controller.markets(iUSDT.address))423 .redeemPaused;424 // console.log("newiUSDTRedeemPaused", newiUSDTRedeemPaused);425 let newiUSDxTransferPaused = await controller.transferPaused();426 // console.log("newiUSDxTransferPaused", newiUSDxTransferPaused);427 let newiUSDTSeizePaused = await controller.seizePaused();428 // console.log("newiUSDTSeizePaused", newiUSDTSeizePaused);429 expect(newiUSDTMintPaused).to.equal(paused);430 expect(newiUSDxBorrowPaused).to.equal(paused);431 expect(newiUSDTRedeemPaused).to.equal(paused);432 expect(newiUSDxTransferPaused).to.equal(paused);433 expect(newiUSDTSeizePaused).to.equal(paused);434 });435 it("Set a new price oracle", async function () {436 const [owner, ...accounts] = await ethers.getSigners();437 // let oldPriceOracle = await controller.priceOracle();438 // console.log("oldPriceOracle", oldPriceOracle);439 // Deploy a new oracle.440 const priceOracle = await deployOracle(owner.getAddress(), "0.01");441 let data = abiCoder.encode(["address"], [priceOracle.address]);442 await timelock.executeTransaction(443 controller.address,444 0,445 "_setPriceOracle(address)",446 data447 );448 let newPriceOracle = await controller.priceOracle();449 // console.log("newPriceOracle", newPriceOracle);450 expect(priceOracle.address).to.equal(newPriceOracle);451 });452 it("Set a new reward distributor", async function () {453 const [owner, ...accounts] = await ethers.getSigners();454 // let oldRewardDistributor = await controller.rewardDistributor();455 // console.log("oldRewardDistributor", oldRewardDistributor);456 const mockRewardDistributor = newiToken.address;457 let data = abiCoder.encode(["address"], [mockRewardDistributor]);458 await timelock.executeTransaction(459 controller.address,460 0,461 "_setRewardDistributor(address)",462 data463 );464 let newRewardDistributor = await controller.rewardDistributor();465 // console.log("newRewardDistributor", newRewardDistributor);466 expect(mockRewardDistributor).to.equal(newRewardDistributor);467 });468 it("Set supply capacity and borrow capacity at the same time", async function () {469 // let oldSupplyCapacity = (await controller.markets(newiToken.address)).supplyCapacity;470 // console.log("oldSupplyCapacity", oldSupplyCapacity.toString());471 // let oldBorrowCapacity = (await controller.markets(newiToken.address)).borrowCapacity;472 // console.log("oldBorrowCapacity", oldBorrowCapacity.toString());473 let supplyCapacity = await parseTokenAmount(newiToken, "99999");474 let supplyCapacityData = abiCoder.encode(475 ["address", "uint256"],476 [newiToken.address, supplyCapacity]477 );478 let borrowCapacity = await parseTokenAmount(newiToken, "99999");479 let borrowCapacityData = abiCoder.encode(480 ["address", "uint256"],481 [newiToken.address, borrowCapacity]482 );483 let targetsAddr = [controller.address, controller.address];484 let values = [0, 0];485 let signatures = [486 "_setSupplyCapacity(address,uint256)",487 "_setBorrowCapacity(address,uint256)",488 ];489 let datas = [supplyCapacityData, borrowCapacityData];490 await timelock.executeTransactions(491 targetsAddr,492 values,493 signatures,494 datas495 );496 let newSupplyCapacity = (await controller.markets(newiToken.address))497 .supplyCapacity;498 // console.log("newSupplyCapacity", newSupplyCapacity.toString());499 let newBorrowCapacity = (await controller.markets(newiToken.address))500 .borrowCapacity;501 // console.log("newBorrowCapacity", newBorrowCapacity.toString());502 expect(newSupplyCapacity).to.equal(supplyCapacity);503 expect(newBorrowCapacity).to.equal(borrowCapacity);504 });505 });...

Full Screen

Full Screen

stepping-with-natives-and-frameworks.js

Source:stepping-with-natives-and-frameworks.js Github

copy

Full Screen

1// Copyright 2017 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4let {session, contextGroup, Protocol} = InspectorTest.start('Stepping with natives and frameworks.');5contextGroup.addScript(`6function callAll() {7 for (var f of arguments)8 f();9}10//# sourceURL=framework.js`);11session.setupScriptMap();12InspectorTest.logProtocolCommandCalls('Debugger.pause');13InspectorTest.logProtocolCommandCalls('Debugger.stepInto');14InspectorTest.logProtocolCommandCalls('Debugger.stepOver');15InspectorTest.logProtocolCommandCalls('Debugger.stepOut');16InspectorTest.logProtocolCommandCalls('Debugger.resume');17Protocol.Debugger.enable();18Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});19InspectorTest.runAsyncTestSuite([20 async function testNativeCodeStepOut() {21 Protocol.Debugger.pause();22 Protocol.Runtime.evaluate({expression: '[1,2].map(v => v);'});23 await logPauseLocation(await Protocol.Debugger.oncePaused());24 Protocol.Debugger.stepInto();25 await logPauseLocation(await Protocol.Debugger.oncePaused());26 Protocol.Debugger.stepOut();27 await logPauseLocation(await Protocol.Debugger.oncePaused());28 await Protocol.Debugger.resume();29 },30 async function testNativeCodeStepOver() {31 Protocol.Debugger.pause();32 Protocol.Runtime.evaluate({expression: '[1,2].map(v => v);'});33 await logPauseLocation(await Protocol.Debugger.oncePaused());34 Protocol.Debugger.stepInto();35 await logPauseLocation(await Protocol.Debugger.oncePaused());36 Protocol.Debugger.stepOver();37 await logPauseLocation(await Protocol.Debugger.oncePaused());38 Protocol.Debugger.stepOver();39 await logPauseLocation(await Protocol.Debugger.oncePaused());40 Protocol.Debugger.stepOver();41 await logPauseLocation(await Protocol.Debugger.oncePaused());42 Protocol.Debugger.stepOver();43 await logPauseLocation(await Protocol.Debugger.oncePaused());44 await Protocol.Debugger.resume();45 },46 async function testNativeCodeStepInto() {47 Protocol.Debugger.pause();48 Protocol.Runtime.evaluate({expression: '[1,2].map(v => v);'});49 await logPauseLocation(await Protocol.Debugger.oncePaused());50 Protocol.Debugger.stepInto();51 await logPauseLocation(await Protocol.Debugger.oncePaused());52 Protocol.Debugger.stepInto();53 await logPauseLocation(await Protocol.Debugger.oncePaused());54 Protocol.Debugger.stepInto();55 await logPauseLocation(await Protocol.Debugger.oncePaused());56 Protocol.Debugger.stepInto();57 await logPauseLocation(await Protocol.Debugger.oncePaused());58 Protocol.Debugger.stepInto();59 await logPauseLocation(await Protocol.Debugger.oncePaused());60 await Protocol.Debugger.resume();61 },62 async function testFrameworkCodeStepInto() {63 Protocol.Debugger.pause();64 Protocol.Runtime.evaluate({expression: 'callAll(() => 1, () => 2);'});65 await logPauseLocation(await Protocol.Debugger.oncePaused());66 Protocol.Debugger.stepInto();67 await logPauseLocation(await Protocol.Debugger.oncePaused());68 Protocol.Debugger.stepInto();69 await logPauseLocation(await Protocol.Debugger.oncePaused());70 Protocol.Debugger.stepInto();71 await logPauseLocation(await Protocol.Debugger.oncePaused());72 Protocol.Debugger.stepInto();73 await logPauseLocation(await Protocol.Debugger.oncePaused());74 Protocol.Debugger.stepInto();75 await logPauseLocation(await Protocol.Debugger.oncePaused());76 await Protocol.Debugger.resume();77 },78 async function testFrameworkCodeStepOver() {79 Protocol.Debugger.pause();80 Protocol.Runtime.evaluate({expression: 'callAll(() => 1, () => 2);'});81 await logPauseLocation(await Protocol.Debugger.oncePaused());82 Protocol.Debugger.stepInto();83 await logPauseLocation(await Protocol.Debugger.oncePaused());84 Protocol.Debugger.stepOver();85 await logPauseLocation(await Protocol.Debugger.oncePaused());86 Protocol.Debugger.stepOver();87 await logPauseLocation(await Protocol.Debugger.oncePaused());88 Protocol.Debugger.stepOver();89 await logPauseLocation(await Protocol.Debugger.oncePaused());90 Protocol.Debugger.stepOver();91 await logPauseLocation(await Protocol.Debugger.oncePaused());92 await Protocol.Debugger.resume();93 },94 async function testFrameworkCodeStepOut() {95 Protocol.Debugger.pause();96 Protocol.Runtime.evaluate({expression: 'callAll(() => 1, () => 2);'});97 await logPauseLocation(await Protocol.Debugger.oncePaused());98 Protocol.Debugger.stepInto();99 await logPauseLocation(await Protocol.Debugger.oncePaused());100 Protocol.Debugger.stepOut();101 await logPauseLocation(await Protocol.Debugger.oncePaused());102 Protocol.Debugger.stepOut();103 await logPauseLocation(await Protocol.Debugger.oncePaused());104 await Protocol.Debugger.resume();105 },106 async function testFrameworkNextCallDeeperStepOut() {107 Protocol.Debugger.pause();108 Protocol.Runtime.evaluate({109 expression: 'callAll(() => 1, callAll.bind(null, () => 2));'});110 await logPauseLocation(await Protocol.Debugger.oncePaused());111 Protocol.Debugger.stepInto();112 await logPauseLocation(await Protocol.Debugger.oncePaused());113 Protocol.Debugger.stepOut();114 await logPauseLocation(await Protocol.Debugger.oncePaused());115 Protocol.Debugger.stepOut();116 await logPauseLocation(await Protocol.Debugger.oncePaused());117 await Protocol.Debugger.resume();118 },119 async function testFrameworkNextCallDeeperStepOutSameFunction() {120 await Protocol.Runtime.evaluate({expression: 'foo = () => 1'});121 Protocol.Debugger.pause();122 Protocol.Runtime.evaluate({123 expression: 'callAll(foo, callAll.bind(null, foo));'});124 await logPauseLocation(await Protocol.Debugger.oncePaused());125 Protocol.Debugger.stepInto();126 await logPauseLocation(await Protocol.Debugger.oncePaused());127 Protocol.Debugger.stepOut();128 await logPauseLocation(await Protocol.Debugger.oncePaused());129 await Protocol.Debugger.resume();130 },131 async function testFrameworkNextCallDeeperStepInto() {132 Protocol.Debugger.pause();133 Protocol.Runtime.evaluate({134 expression: 'callAll(() => 1, callAll.bind(null, () => 2));'});135 await logPauseLocation(await Protocol.Debugger.oncePaused());136 Protocol.Debugger.stepInto();137 await logPauseLocation(await Protocol.Debugger.oncePaused());138 Protocol.Debugger.stepOver();139 await logPauseLocation(await Protocol.Debugger.oncePaused());140 Protocol.Debugger.stepOver();141 await logPauseLocation(await Protocol.Debugger.oncePaused());142 Protocol.Debugger.stepOver();143 await logPauseLocation(await Protocol.Debugger.oncePaused());144 Protocol.Debugger.stepOver();145 await logPauseLocation(await Protocol.Debugger.oncePaused());146 await Protocol.Debugger.resume();147 },148 async function testFrameworkNextCallDeeperStepOver() {149 Protocol.Debugger.pause();150 Protocol.Runtime.evaluate({151 expression: 'callAll(() => 1, callAll.bind(null, () => 2));'});152 await logPauseLocation(await Protocol.Debugger.oncePaused());153 Protocol.Debugger.stepInto();154 await logPauseLocation(await Protocol.Debugger.oncePaused());155 Protocol.Debugger.stepOver();156 await logPauseLocation(await Protocol.Debugger.oncePaused());157 Protocol.Debugger.stepOver();158 await logPauseLocation(await Protocol.Debugger.oncePaused());159 Protocol.Debugger.stepOver();160 await logPauseLocation(await Protocol.Debugger.oncePaused());161 Protocol.Debugger.stepOver();162 await logPauseLocation(await Protocol.Debugger.oncePaused());163 await Protocol.Debugger.resume();164 },165 async function testFrameworkCurrentCallDeeperStepOut() {166 Protocol.Debugger.pause();167 Protocol.Runtime.evaluate({168 expression: 'callAll(callAll.bind(null, () => 1), () => 2);'});169 await logPauseLocation(await Protocol.Debugger.oncePaused());170 Protocol.Debugger.stepInto();171 await logPauseLocation(await Protocol.Debugger.oncePaused());172 Protocol.Debugger.stepOut();173 await logPauseLocation(await Protocol.Debugger.oncePaused());174 Protocol.Debugger.stepOut();175 await logPauseLocation(await Protocol.Debugger.oncePaused());176 await Protocol.Debugger.resume();177 },178 async function testFrameworkCurrentCallDeeperStepOutSameFunction() {179 await Protocol.Runtime.evaluate({expression: 'foo = () => 1'});180 Protocol.Debugger.pause();181 Protocol.Runtime.evaluate({182 expression: 'callAll(callAll.bind(null, foo), foo);'});183 await logPauseLocation(await Protocol.Debugger.oncePaused());184 Protocol.Debugger.stepInto();185 await logPauseLocation(await Protocol.Debugger.oncePaused());186 Protocol.Debugger.stepOut();187 await logPauseLocation(await Protocol.Debugger.oncePaused());188 await Protocol.Debugger.resume();189 },190 async function testFrameworkCurrentCallDeeperStepOver() {191 Protocol.Debugger.pause();192 Protocol.Runtime.evaluate({193 expression: 'callAll(callAll.bind(null, () => 1), () => 2);'});194 await logPauseLocation(await Protocol.Debugger.oncePaused());195 Protocol.Debugger.stepInto();196 await logPauseLocation(await Protocol.Debugger.oncePaused());197 Protocol.Debugger.stepOver();198 await logPauseLocation(await Protocol.Debugger.oncePaused());199 Protocol.Debugger.stepOver();200 await logPauseLocation(await Protocol.Debugger.oncePaused());201 Protocol.Debugger.stepOver();202 await logPauseLocation(await Protocol.Debugger.oncePaused());203 Protocol.Debugger.stepOver();204 await logPauseLocation(await Protocol.Debugger.oncePaused());205 await Protocol.Debugger.resume();206 },207 async function testFrameworkCurrentCallDeeperStepInto() {208 Protocol.Debugger.pause();209 Protocol.Runtime.evaluate({210 expression: 'callAll(callAll.bind(null, () => 1), () => 2);'});211 await logPauseLocation(await Protocol.Debugger.oncePaused());212 Protocol.Debugger.stepInto();213 await logPauseLocation(await Protocol.Debugger.oncePaused());214 Protocol.Debugger.stepInto();215 await logPauseLocation(await Protocol.Debugger.oncePaused());216 Protocol.Debugger.stepInto();217 await logPauseLocation(await Protocol.Debugger.oncePaused());218 Protocol.Debugger.stepInto();219 await logPauseLocation(await Protocol.Debugger.oncePaused());220 Protocol.Debugger.stepInto();221 await logPauseLocation(await Protocol.Debugger.oncePaused());222 await Protocol.Debugger.resume();223 },224 async function testFrameworkStepOverMixed() {225 await Protocol.Runtime.evaluate({expression: 'foo = () => 1'});226 Protocol.Debugger.pause();227 Protocol.Runtime.evaluate({228 expression: 'callAll(foo, foo, () => 2);'});229 await logPauseLocation(await Protocol.Debugger.oncePaused());230 Protocol.Debugger.stepInto();231 await logPauseLocation(await Protocol.Debugger.oncePaused());232 Protocol.Debugger.stepOver();233 await logPauseLocation(await Protocol.Debugger.oncePaused());234 Protocol.Debugger.stepOver();235 await logPauseLocation(await Protocol.Debugger.oncePaused());236 Protocol.Debugger.stepOver();237 await logPauseLocation(await Protocol.Debugger.oncePaused());238 Protocol.Debugger.stepOver();239 await logPauseLocation(await Protocol.Debugger.oncePaused());240 Protocol.Debugger.stepOver();241 await logPauseLocation(await Protocol.Debugger.oncePaused());242 Protocol.Debugger.stepOver();243 await logPauseLocation(await Protocol.Debugger.oncePaused());244 await Protocol.Debugger.resume();245 },246 async function testFrameworkStepOutMixed() {247 await Protocol.Runtime.evaluate({expression: 'foo = () => 1'});248 Protocol.Debugger.pause();249 Protocol.Runtime.evaluate({250 expression: 'callAll(foo, foo, () => 2);'});251 await logPauseLocation(await Protocol.Debugger.oncePaused());252 Protocol.Debugger.stepInto();253 await logPauseLocation(await Protocol.Debugger.oncePaused());254 Protocol.Debugger.stepOut();255 await logPauseLocation(await Protocol.Debugger.oncePaused());256 Protocol.Debugger.stepOut();257 await logPauseLocation(await Protocol.Debugger.oncePaused());258 await Protocol.Debugger.resume();259 },260 async function testStepOutFrameworkSameFunctionAtReturn() {261 await Protocol.Runtime.evaluate({expression: 'foo = () => 1'});262 Protocol.Debugger.pause();263 Protocol.Runtime.evaluate({264 expression: 'callAll(foo, foo, () => 2);'});265 await logPauseLocation(await Protocol.Debugger.oncePaused());266 Protocol.Debugger.stepInto();267 await logPauseLocation(await Protocol.Debugger.oncePaused());268 Protocol.Debugger.stepOver();269 await logPauseLocation(await Protocol.Debugger.oncePaused());270 Protocol.Debugger.stepOut();271 await logPauseLocation(await Protocol.Debugger.oncePaused());272 Protocol.Debugger.stepOut();273 await logPauseLocation(await Protocol.Debugger.oncePaused());274 await Protocol.Debugger.resume();275 }276]);277function logPauseLocation(message) {278 return session.logSourceLocation(message.params.callFrames[0].location);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) {19 console.log(err);20 } else {21 console.log(data);22 wpt.getTestResults(data.data.testId, function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28 });29 }30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33 if (err) {34 console.log(err);35 } else {36 console.log(data);37 wpt.getTestResults(data.data.testId, function(err, data) {38 if (err) {39 console.log(err);40 } else {41 console.log(data);42 }43 });44 }45});46var wpt = require('webpagetest');47var wpt = new WebPageTest('www.webpagetest.org');48 if (err) {49 console.log(err);50 } else {51 console.log(data);52 wpt.getTestResults(data.data.testId, function(err, data) {53 if (err) {54 console.log(err);55 } else {56 console.log(data);57 }58 });59 }60});61var wpt = require('webpagetest');62var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3api.runTest('www.google.com', {4}, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 api.getTestResults(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14 });15 }16});17var wpt = require('webpagetest');18var api = new wpt('www.webpagetest.org');19api.runTest('www.google.com', {20}, function(err, data) {21 if (err) {22 console.log(err);23 } else {24 api.getTestResults(data.data.testId, function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30 });31 }32});33var wpt = require('webpagetest');34var api = new wpt('www.webpagetest.org');35api.runTest('www.google.com', {36}, function(err, data) {37 if (err) {38 console.log(err);39 } else {40 api.getTestResults(data.data.testId, function(err, data) {41 if (err) {42 console.log(err);43 } else {44 console.log(data);45 }46 });47 }48});49var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');3 if (err) {4 console.log('Error: ', err);5 } else {6 console.log('Test Submitted');7 api.getTestStatus(data.data.testId, function(err, data) {8 if (err) {9 console.log('Error: ', err);10 } else {11 console.log('Test Status: ', data);12 }13 });14 }15});16var wpt = require('webpagetest');17var api = wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');18 if (err) {19 console.log('Error: ', err);20 } else {21 console.log('Test Submitted');22 api.testStatus(data.data.testId, function(err, data) {23 if (err) {24 console.log('Error: ', err);25 } else {26 console.log('Test Status: ', data);27 }28 });29 }30});31var wpt = require('webpagetest');32var api = wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');33 if (err) {34 console.log('Error: ', err);35 } else {36 console.log('Test Submitted');37 api.testStatus(data.data.testId, function(err, data) {38 if (err) {39 console.log('Error: ', err);40 } else {41 console.log('Test Status: ', data);42 }43 });44 }45});46var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3client.runTest(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 client.getTestResults(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});16{ [Error: Error: 400 Bad Request17 at IncomingMessage.res.on (/home/abhishek/node_modules/webpagetest/lib/webpagetest.js:75:20)18 at IncomingMessage.EventEmitter.emit (events.js:98:17)19 at process._tickCallback (node.js:415:13)]20 message: 'Error: 400 Bad Request' }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('API_KEY');3var options = { location: 'ec2-us-west-2:Chrome', timeout: 60, runs: 1, firstViewOnly: true, pollResults: 5 };4var testId;5api.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 testId = data.data.testId;8 console.log('Test ID: ' + testId);9 api.testStatus(testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test Status: ' + data.data.statusText);12 api.getTestResults(testId, function(err, data) {13 if (err) return console.error(err);14 console.log('Test Results: ' + JSON.stringify(data.data));15 });16 });17});18var wpt = require('webpagetest');19var api = new wpt('API_KEY');20var options = { location: 'ec2-us-west-2:Chrome', timeout: 60, runs: 1, firstViewOnly: true, pollResults: 5 };21var testId;22api.runTest(url, options, function(err, data) {23 if (err) return console.error(err);24 testId = data.data.testId;25 console.log('Test ID: ' + testId);26 api.testStatus(testId, function(err, data) {27 if (err) return console.error(err);28 console.log('Test Status: ' + data.data.statusText);29 api.getTestResults(testId, function(err, data) {30 if (err) return console.error(err);31 console.log('Test Results: ' + JSON.stringify(data.data));32 });33 });34});35var wpt = require('webpagetest');36var api = new wpt('API_KEY');37var options = { location: 'ec2-us-west-2:Chrome', timeout: 60, runs: 1, firstViewOnly: true, pollResults: 5 };38var testId;39api.runTest(url, options, function(err, data) {40 if (

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var testId = null;4var testResult = null;5var testStatus = null;6function getTestResults() {7 if (testStatus.statusCode == 200) {8 if (testResult.statusCode == 200) {9 console.log(testResult.data);10 } else {11 console.log('Test Results: ' + testResult.statusCode);12 }13 } else {14 console.log('Test Status: ' + testStatus.statusCode);15 }16}17function getTestStatus() {18 wpt.getTestStatus(testId, function (err, data) {19 testStatus = data;20 getTestResults();21 });22}23function startTest() {24 wpt.runTest(testURL, {25 }, function (err, data) {26 testId = data.data.testId;27 getTestStatus();28 });29}30function pauseTest() {31 wpt.pauseTest(testId, function (err, data) {32 console.log(data);33 startTest();34 });35}36function stopTest() {37 wpt.stopTest(testId, function (err, data) {38 console.log(data);39 });40}41function getTestResults() {42 if (testStatus.statusCode == 200) {43 if (testResult.statusCode == 200) {44 console.log(testResult.data);45 } else {46 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.8b0a9b4a4e0e4c8d0c2a2b4c4b4a4b4a');3wpt.runTest(url, { location: 'Dulles:Chrome', runs: 1, firstViewOnly: true }, function(err, data) {4 if (err) return console.error(err);5 console.log('Test started: ' + data.data.testId);6 wpt.getTestStatus(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test status: ' + data.data.statusText);9 if (data.data.statusText === 'Test Complete') {10 console.log('Test completed');11 } else {12 console.log('Test not completed');13 }14 });15});16var WebPageTest = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org', 'A.8b0a9b4a4e0e4c8d0c2a2b4c4b4a4b4a');18wpt.runTest(url, { location: 'Dulles:Chrome', runs: 1, firstViewOnly: true }, function(err, data) {19 if (err) return console.error(err);20 console.log('Test started: ' + data.data.testId);21 wpt.getTestStatus(data.data.testId, function(err, data) {22 if (err) return console.error(err);23 console.log('Test status: ' + data.data.statusText);24 if (data.data.statusText === 'Test Complete') {25 console.log('Test completed');26 } else {27 console.log('Test not completed');28 }29 });30});31var WebPageTest = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org', 'A.8b0a9b4a4e0e4c8d0c2a2b4c4b4

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful