How to use reason1 method in wpt

Best JavaScript code snippet using wpt

18_TokenController.test.js

Source:18_TokenController.test.js Github

copy

Full Screen

1const Master = artifacts.require("Master");2const TokenController = artifacts.require("MockTokenController");3const PlotusToken = artifacts.require("MockPLOT.sol");4const OwnedUpgradeabilityProxy = artifacts.require('OwnedUpgradeabilityProxy');5// const BLOT = artifacts.require("bLOTToken");6const Web3 = require("web3");7const { assertRevert } = require("./utils/assertRevert.js");8const { expectRevert, time } = require("@openzeppelin/test-helpers");9const { assert } = require("chai");10contract("TokenController", ([owner, account2, account3]) => {11 let plotusToken, tokenController;12 const lockReason1 = web3.utils.fromAscii("DR");13 const lockReason2 = web3.utils.fromAscii("SM");14 const lockedAmount = 200;15 const lockPeriod = 1000;16 const thirtyDayPeriod = 30 * 24 * 60 * 60;17 const ALREADY_LOCKED = "Tokens already locked";18 const NOT_LOCKED = "No tokens locked";19 const AMOUNT_ZERO = "Amount can not be 0";20 const nullAddress = "0x0000000000000000000000000000000000000000";21 before(async () => {22 // masterInstance = await Master.deployed();23 masterInstance = await OwnedUpgradeabilityProxy.deployed();24 masterInstance = await Master.at(masterInstance.address);25 const tc = await masterInstance.getLatestAddress("0x5443");26 tokenController = await TokenController.at(tc);27 plotusToken = await tokenController.token();28 plotusToken = await PlotusToken.at(plotusToken);29 await tokenController.changeOperator(owner);30 assert.equal(await plotusToken.operator(), owner);31 await plotusToken.approve(tokenController.address, "1000000000000000000000000");32 });33 describe("1. Check Initialization Data", () => {34 it("1.1 Check for token creation", () => {35 assert.ok(tokenController);36 });37 it("1.2 Should have correct initialization data", async () => {38 const tokenInstance = await tokenController.token();39 assert.equal(tokenInstance, plotusToken.address);40 });41 it("1.3 Should not allow to call unauthorized functions", async() => {42 await assertRevert(tokenController.swapBLOT(owner, owner, 100));43 await assertRevert(tokenController.setMasterAddress());44 })45 });46 // describe("Swap BLOT functionality", () => {47 // it("Should be able to swap BLOT");48 // });49 // describe("Uint Parameter functionality", () => {50 // // let uintParameters = await tokenController.getUintParameters(web3.utils.fromAscii("SMLP"));51 // // assert.equal(web3.utils.toAscii(uintParameters.codeVal).replace(/\0/g, ""), "SMLP");52 // // assert.equal(uintParameters.val.toNumber(), 30);53 // it("Should be able to get unit parameters", async () => {54 // const undefinedCode1 = web3.utils.toHex("TRY");55 // const codeSMPL = web3.utils.toHex("SMPL");56 // const codeBRLIM = web3.utils.toHex("BRLIM");57 // const uintParameters1 = await tokenController.getUintParameters(undefinedCode1);58 // const uintParameters2 = await tokenController.getUintParameters(codeSMPL);59 // const uintParameters3 = await tokenController.getUintParameters(codeBRLIM);60 // // assert.equal(web3.utils.toAscii(uintParameters1.codeVal).replace(/\0/g, ""), "TRY");61 // assert.equal(uintParameters1.val.toNumber(), 0);62 // // assert.equal(web3.utils.toAscii(uintParameters2.codeVal).replace(/\0/g, ""), "SMPL");63 // assert.equal(uintParameters2.val.toNumber(), 30);64 // // assert.equal(web3.utils.toAscii(uintParameters3.codeVal).replace(/\0/g, ""), "BRLIM");65 // assert.equal(uintParameters3.val.toNumber(), 20000000);66 // });67 // it("Should be able to update unit parameters");68 // });69 describe("Lock Functionality", () => {70 before(async () => {71 await plotusToken.burn( await plotusToken.balanceOf(owner), { from: owner });72 await plotusToken.mint(owner, 2000, { from: owner });73 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), 2000);74 assert.equal(parseInt(web3.utils.fromWei(await tokenController.totalSupply())), parseInt(web3.utils.fromWei(await plotusToken.totalSupply())));75 await assertRevert(plotusToken.changeOperator(nullAddress));76 await plotusToken.changeOperator(tokenController.address);77 assert.equal(await plotusToken.operator(), tokenController.address);78 });79 it("Should revert lock token with amount zero", async () => {80 await assertRevert(tokenController.lock(lockReason1, 0, lockPeriod));81 });82 it("Should revert locking tokens with unspecified reason or time", async () => {83 await assertRevert(tokenController.lock(lockReason2, lockedAmount, lockPeriod));84 const unspecifiedReason = web3.utils.fromAscii("TRY");85 await assertRevert(tokenController.lock(unspecifiedReason, lockedAmount, lockPeriod));86 });87 it("Should revert if try to lock amount > than balance", async () => {88 await assertRevert(89 tokenController.lock(lockReason1, (await plotusToken.balanceOf(owner)).toNumber() + 1, lockPeriod)90 );91 });92 it("Should be able to lock", async () => {93 const origBalance = await plotusToken.balanceOf(owner);94 // await plotusToken.transfer(account2, value);95 // await plotusToken.operatorTransfer(account2,)96 let receipt = await tokenController.lock.call(lockReason1, lockedAmount, lockPeriod, { from: owner });97 assert.equal(receipt, true);98 let newLockTimestamp = await time.latest();99 receipt = await tokenController.lock(lockReason1, lockedAmount, lockPeriod);100 const lockReason = await tokenController.lockReason(owner, 0);101 const tokensUnlockable = await tokenController.tokensUnlockable(owner, lockReason1);102 const getUnlockableTokens = await tokenController.getUnlockableTokens(owner);103 const tokensLocked = await tokenController.tokensLocked(owner, lockReason1);104 const tokensLockedStruct = await tokenController.locked(owner, lockReason1);105 assert.equal(web3.utils.toAscii(lockReason).replace(/\0/g, ""), web3.utils.toAscii(lockReason1));106 assert.equal(tokensUnlockable.toNumber(), 0);107 assert.equal(getUnlockableTokens.toNumber(), 0);108 assert.equal(tokensLocked.toNumber(), lockedAmount);109 assert.equal(tokensLockedStruct.amount.toNumber(), lockedAmount);110 assert(tokensLockedStruct.validity.toNumber() >= lockPeriod + newLockTimestamp.toNumber());111 assert.equal(tokensLockedStruct.claimed, false);112 let tokenLockedAtTime = await tokenController.tokensLockedAtTime(owner, lockReason1, newLockTimestamp);113 assert.equal(tokenLockedAtTime.toNumber(), lockedAmount);114 tokenLockedAtTime = await tokenController.tokensLockedAtTime(115 owner,116 lockReason1,117 newLockTimestamp + lockPeriod + 1118 );119 assert.equal(tokenLockedAtTime.toNumber(), 0);120 const balance = await plotusToken.balanceOf(owner);121 const totalBalance = await tokenController.totalBalanceOf(owner);122 assert.equal(balance.toNumber(), origBalance.toNumber() - lockedAmount);123 assert.equal(totalBalance.toNumber(), origBalance.toNumber());124 // assert.equal(receipt.logs.length, 2);125 // assert.equal(receipt.logs[0].event, "Transfer");126 // assert.equal(receipt.logs[0].args.from, owner);127 // assert.equal(receipt.logs[0].args.to, tokenController.address);128 // assert.equal(receipt.logs[0].args.value.toNumber(), lockedAmount);129 assert.equal(receipt.logs[0].event, "Locked");130 assert.equal(receipt.logs[0].args._of, owner);131 assert.equal(132 web3.utils.toAscii(receipt.logs[0].args._reason).replace(/\0/g, ""),133 web3.utils.toAscii(lockReason1)134 );135 assert.equal(receipt.logs[0].args._amount.toNumber(), lockedAmount);136 assert(receipt.logs[0].args._validity.toNumber() >= lockPeriod + newLockTimestamp.toNumber());137 });138 it("Should be able to transfer the remaining tokens after lock", async () => {139 await plotusToken.transfer(account2, 300, { from: owner });140 const newSenderBalance = await plotusToken.balanceOf(owner);141 const newReceiverBalance = await plotusToken.balanceOf(account2);142 assert.equal(newSenderBalance.toNumber(), 1500);143 assert.equal(newReceiverBalance.toNumber(), 300);144 });145 it("Should NOT be able to transfer more than the remaining tokens after lock", async () => {146 const transferAmount = await tokenController.totalBalanceOf(owner);147 const oldReceiverBalance = await plotusToken.balanceOf(account2);148 await assertRevert(plotusToken.transfer(account2, transferAmount, { from: owner }));149 const newSenderBalance = await plotusToken.balanceOf(owner);150 const newReceiverBalance = await plotusToken.balanceOf(account2);151 assert.equal(newSenderBalance.toNumber(), 1500);152 assert.equal(newReceiverBalance.toNumber(), oldReceiverBalance.toNumber());153 });154 it("Should revert lock for if already locked for same account and reason", async () => {155 const balance = await plotusToken.balanceOf(owner);156 await assertRevert(tokenController.lock(lockReason1, balance, lockPeriod));157 });158 it("Should allow to lock token again", async () => {159 const lockStruct = await tokenController.locked(owner, lockReason1);160 await time.increaseTo(lockStruct.validity.toNumber() + 1);161 await tokenController.unlock(owner);162 await tokenController.lock(lockReason1, 1, 0);163 await tokenController.unlock(owner);164 await tokenController.lock(lockReason1, lockedAmount, lockPeriod);165 });166 });167 describe("Unlock Functionality", () => {168 it("Should not unlock before lock time has completed", async () => {169 const balance = await plotusToken.balanceOf(owner);170 const tokensLocked = await tokenController.tokensLocked(owner, lockReason1);171 const receipt = await tokenController.unlock.call(owner);172 assert.equal(receipt.toNumber(), 0);173 await tokenController.unlock(owner);174 const newBalance = await plotusToken.balanceOf(owner);175 const newTokensLocked = await tokenController.tokensLocked(owner, lockReason1);176 assert.equal(balance.toNumber(), newBalance.toNumber());177 assert.equal(tokensLocked.toNumber(), newTokensLocked.toNumber());178 });179 it("Should be able to unlock after lock time has passed", async () => {180 const lockStruct = await tokenController.locked(owner, lockReason1);181 const totalBalance = await tokenController.totalBalanceOf(owner);182 let tokensLocked = await tokenController.tokensLocked(owner, lockReason1);183 await time.increaseTo(lockStruct.validity.toNumber() + 1);184 let unlockableToken = await tokenController.getUnlockableTokens(owner);185 assert.equal(tokensLocked.toNumber(), unlockableToken.toNumber());186 let receipt = await tokenController.unlock.call(owner);187 assert.equal(receipt.toNumber(), lockedAmount);188 receipt = await tokenController.unlock(owner);189 tokensLocked = await tokenController.tokensLocked(owner, lockReason1);190 unlockableToken = await tokenController.getUnlockableTokens(owner);191 const newBalance = await plotusToken.balanceOf(owner);192 assert.equal(tokensLocked.toNumber(), 0);193 assert.equal(unlockableToken.toNumber(), 0);194 assert.equal(newBalance.toNumber(), totalBalance.toNumber());195 // assert.equal(receipt.logs.length, 2);196 assert.equal(receipt.logs[0].event, "Unlocked");197 assert.equal(receipt.logs[0].args._of, owner);198 assert.equal(199 web3.utils.toAscii(receipt.logs[0].args._reason).replace(/\0/g, ""),200 web3.utils.toAscii(lockReason1)201 );202 assert.equal(receipt.logs[0].args._amount.toNumber(), lockedAmount);203 // assert.equal(receipt.logs[1].event, "Transfer");204 // assert.equal(receipt.logs[1].args.from, tokenController.address);205 // assert.equal(receipt.logs[1].args.to, owner);206 // assert.equal(receipt.logs[1].args.value.toNumber(), lockedAmount);207 await tokenController.unlock(owner);208 const newNewBalance = await plotusToken.balanceOf(owner);209 assert.equal(newBalance.toNumber(), newNewBalance.toNumber());210 });211 // it("Should revert unlock if governance participation is there", async () => {212 // await tokenController.lock(lockReason3, 1, 0);213 // await tokenController.lockForGovernanceVote(owner, 5);214 // await assertRevert(tokenController.unlock(owner));215 // });216 });217 describe("Try lock/unlock for all three reasons", () => {218 let totalBalance;219 before(async () => {220 totalBalance = (await plotusToken.balanceOf(owner)).toNumber();221 assert.equal(totalBalance, (await tokenController.totalBalanceOf(owner)).toNumber());222 });223 // it("Should be able to lock for reason 1", async () => {224 // await tokenController.lock(lockReason2, lockedAmount, lockPeriod);225 // assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount);226 // assert.equal((await tokenController.tokensLocked(owner, lockReason2)).toNumber(), lockedAmount);227 // });228 it("Should be able to lock for reason 2", async () => {229 await tokenController.lock(lockReason1, lockedAmount, lockPeriod);230 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount);231 assert.equal((await tokenController.tokensLocked(owner, lockReason1)).toNumber(), lockedAmount);232 });233 it("Should be able to lock for reason 3", async () => {234 await assertRevert(tokenController.lock(lockReason2, lockedAmount, lockPeriod));235 await tokenController.lock(lockReason2, lockedAmount, thirtyDayPeriod);236 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount * 2);237 assert.equal((await tokenController.tokensLocked(owner, lockReason2)).toNumber(), lockedAmount);238 });239 it("Should show correct result for all lock related functions", async () => {240 assert.equal((await tokenController.getUnlockableTokens(owner)).toNumber(), 0);241 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), 0);242 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), 0);243 assert.equal((await tokenController.tokensUnlockable(owner, lockReason2)).toNumber(), 0);244 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount * 2);245 assert.equal((await tokenController.totalBalanceOf(owner)).toNumber(), totalBalance);246 await tokenController.unlock(owner);247 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount * 2);248 });249 it("Increasing time by loadPeriod should unlock Unlockable tokens", async () => {250 await time.increase(lockPeriod);251 assert.equal((await tokenController.getUnlockableTokens(owner)).toNumber(), lockedAmount * 1);252 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), lockedAmount);253 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), lockedAmount);254 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount * 2);255 await tokenController.unlock(owner);256 assert.equal((await tokenController.getUnlockableTokens(owner)).toNumber(), 0);257 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), 0);258 assert.equal((await tokenController.tokensUnlockable(owner, lockReason1)).toNumber(), 0);259 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount);260 });261 it("Increasing time by 30 days should unlock the lock with reason 3", async () => {262 await time.increase(thirtyDayPeriod);263 assert.equal((await tokenController.getUnlockableTokens(owner)).toNumber(), lockedAmount);264 assert.equal((await tokenController.tokensUnlockable(owner, lockReason2)).toNumber(), lockedAmount);265 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance - lockedAmount);266 await tokenController.unlock(owner);267 assert.equal((await tokenController.getUnlockableTokens(owner)).toNumber(), 0);268 assert.equal((await tokenController.tokensUnlockable(owner, lockReason2)).toNumber(), 0);269 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), totalBalance);270 });271 });272 describe("Extend Lock functionality", () => {273 before(async () => {274 await tokenController.lock(lockReason1, lockedAmount, lockPeriod);275 });276 it("Should be able to extend lock period for an existing lock", async () => {277 const lockValidityOrig = await tokenController.locked(owner, lockReason1);278 let receipt = await tokenController.extendLock.call(lockReason1, lockPeriod);279 assert.equal(receipt, true);280 receipt = await tokenController.extendLock(lockReason1, lockPeriod);281 const lockValidityExtended = await tokenController.locked(owner, lockReason1);282 assert.equal(receipt.logs.length, 1);283 assert.equal(receipt.logs[0].event, "Locked");284 assert.equal(receipt.logs[0].args._of, owner);285 assert.equal(286 web3.utils.toAscii(receipt.logs[0].args._reason).replace(/\0/g, ""),287 web3.utils.toAscii(lockReason1)288 );289 assert.equal(receipt.logs[0].args._amount.toNumber(), lockedAmount);290 assert(receipt.logs[0].args._validity.toNumber() >= lockValidityOrig[1].toNumber() + lockPeriod);291 assert.equal(lockValidityExtended[1].toNumber(), lockValidityOrig[1].toNumber() + lockPeriod);292 });293 it("Should NOT be able to extend lock for lockReason3 by any period other than 30 days", async () => {294 await tokenController.lock(lockReason2, lockedAmount, thirtyDayPeriod);295 await assertRevert(tokenController.extendLock(lockReason2, lockPeriod));296 await tokenController.extendLock(lockReason2, thirtyDayPeriod);297 await time.increase(thirtyDayPeriod * 2 + 1);298 await tokenController.unlock(owner)299 });300 it("Should NOT be able to extend lock if NOT locked for the reason", async () => {301 await expectRevert(tokenController.extendLock(lockReason1, lockPeriod), NOT_LOCKED);302 });303 it("Should revert when try to extend lock with unspecified reason", async () => {304 const unspecifiedReason = web3.utils.fromAscii("TRY");305 await assertRevert(tokenController.extendLock(unspecifiedReason, 1000));306 });307 it("Should revert when try to extend lock by 0 time", async () => {308 await assertRevert(tokenController.extendLock(lockReason1, 0));309 });310 });311 describe("Increase locked amount functionality", () => {312 before(async () => {313 await tokenController.lock(lockReason1, lockedAmount, lockPeriod);314 });315 it("Should be able to increase the number of tokens locked", async () => {316 const lockValidityOrig = await tokenController.locked(owner, lockReason1);317 const actualLockedAmount = await tokenController.tokensLocked(owner, lockReason1);318 let receipt = await tokenController.increaseLockAmount.call(lockReason1, lockedAmount);319 assert.equal(receipt, true);320 receipt = await tokenController.increaseLockAmount(lockReason1, lockedAmount);321 const increasedLockAmount = await tokenController.tokensLocked(owner, lockReason1);322 assert.equal(increasedLockAmount.toNumber(), actualLockedAmount.toNumber() + lockedAmount);323 assert.equal(receipt.logs.length, 1);324 // assert.equal(receipt.logs[0].event, "Transfer");325 // assert.equal(receipt.logs[0].args.from, owner);326 // assert.equal(receipt.logs[0].args.to, tokenController.address);327 // assert.equal(receipt.logs[0].args.value.toNumber(), lockedAmount);328 assert.equal(receipt.logs[0].event, "Locked");329 assert.equal(receipt.logs[0].args._of, owner);330 assert.equal(web3.utils.toAscii(receipt.logs[0].args._reason).replace(/\0/g, ""), web3.utils.toAscii(lockReason1));331 assert.equal(receipt.logs[0].args._amount.toNumber(), 2 * lockedAmount);332 assert(receipt.logs[0].args._validity.toNumber() === lockValidityOrig.validity.toNumber());333 });334 it("Should revert if NO tokens locked for the reason", async () => {335 await expectRevert(tokenController.increaseLockAmount(lockReason2, thirtyDayPeriod), NOT_LOCKED);336 });337 it("Should revert when increasing lock time with unspecified reason", async () => {338 const unspecifiedReason = web3.utils.fromAscii("TRY");339 await assertRevert(tokenController.increaseLockAmount(unspecifiedReason, 1000));340 });341 it("Should not allow to increase lock amount by more than balance", async () => {342 await assertRevert(tokenController.increaseLockAmount(lockReason1, (await plotusToken.balanceOf(owner)).toNumber() + 1));343 });344 it("Should revert when increase lock amount by 0 amount", async () => {345 await assertRevert(tokenController.increaseLockAmount(lockReason1, 0));346 });347 it("Should increaseLockAmount and time for reason3", async () => {348 await plotusToken.approve(tokenController.address, "1000000000000000000000000", { from: account2 });349 await tokenController.lock(lockReason2, lockedAmount, thirtyDayPeriod, { from: account2 });350 let oldStatus = await tokenController.locked(account2, lockReason2);351 await tokenController.increaseLockAmount(lockReason2, 1, { from: account2 });352 let newStatus = await tokenController.locked(account2, lockReason2);353 assert.equal(parseFloat(newStatus.amount), lockedAmount + 1);354 assert.equal(parseFloat(newStatus.validity)-parseFloat(oldStatus.validity), thirtyDayPeriod);355 await time.increase(thirtyDayPeriod * 2 + 5);356 await tokenController.unlock(account2, { from: account2 });357 });358 it("Should increaseLockAmount and time for reason2", async () => {359 await tokenController.lock(lockReason1, lockedAmount, lockPeriod, { from: account2 });360 await tokenController.increaseLockAmount(lockReason1, 1, { from: account2 });361 let newStatus = await tokenController.locked(account2, lockReason1);362 assert.equal(parseFloat(newStatus.amount), lockedAmount + 1);363 await time.increase(lockPeriod + 5);364 await tokenController.unlock(account2, { from: account2 });365 });366 });367 describe("Transfer with lock functionality", () => {368 before(async () => {369 assert(370 (await plotusToken.balanceOf(owner)).toNumber() !== (await tokenController.totalBalanceOf(owner)).toNumber()371 );372 await time.increase(lockPeriod * 2 + 1);373 await tokenController.unlock(owner);374 assert.equal(375 (await plotusToken.balanceOf(owner)).toNumber(),376 (await tokenController.totalBalanceOf(owner)).toNumber()377 );378 await plotusToken.transfer(owner, 300, { from: account2 });379 assert.equal((await plotusToken.balanceOf(owner)).toNumber(), 2000);380 });381 it("Should be able to lock", async () => {382 const ownerBalance = (await plotusToken.balanceOf(owner)).toNumber();383 const account2Balance = (await plotusToken.balanceOf(account2)).toNumber();384 await plotusToken.transfer(account2, lockedAmount);385 let receipt = await tokenController.lock.call(lockReason1, lockedAmount, lockPeriod, {386 from: account2,387 });388 assert.equal(receipt, true);389 const latestTime = await time.latest();390 receipt = await tokenController.lock(lockReason1, lockedAmount, lockPeriod, {391 from: account2,392 });393 await expectRevert(tokenController.lock(lockReason1, account2Balance, lockPeriod, { from: account2 }), ALREADY_LOCKED);394 const tokensLocked = await tokenController.tokensLocked(account2, lockReason1);395 assert.equal((await tokenController.totalBalanceOf(account2)).toNumber(), account2Balance + lockedAmount);396 // assert.equal((await tokenController.totalBalanceOf(owner)).toNumber(), ownerBalance - lockedAmount);397 assert.equal((await plotusToken.balanceOf(account2)).toNumber(), 0);398 assert.equal(tokensLocked.toNumber(), lockedAmount);399 assert.equal(receipt.logs.length, 1);400 // assert.equal(receipt.logs[0].event, "Transfer");401 // assert.equal(receipt.logs[0].args.from, owner);402 // assert.equal(receipt.logs[0].args.to, tokenController.address);403 // assert.equal(receipt.logs[0].args.value.toNumber(), lockedAmount);404 assert.equal(receipt.logs[0].event, "Locked");405 assert.equal(receipt.logs[0].args._of, account2);406 assert.equal(web3.utils.toAscii(receipt.logs[0].args._reason).replace(/\0/g, ""), web3.utils.toAscii(lockReason1));407 assert.equal(receipt.logs[0].args._amount.toNumber(), lockedAmount);408 assert(receipt.logs[0].args._validity.toNumber() >= latestTime.toNumber() + lockPeriod);409 });410 it("Should not unlock before lock time has completed", async () => {411 const balance = await plotusToken.balanceOf(account2);412 const tokensLocked = await tokenController.tokensLocked(account2, lockReason1);413 await tokenController.unlock(account2);414 const newBalance = await plotusToken.balanceOf(account2);415 const newTokensLocked = await tokenController.tokensLocked(account2, lockReason1);416 assert.equal(balance.toNumber(), newBalance.toNumber());417 assert.equal(tokensLocked.toNumber(), newTokensLocked.toNumber());418 });419 it("Should not be able to transfer tokens before unlocking", async () => {420 const totalBalance = await tokenController.totalBalanceOf(account2);421 await assertRevert(plotusToken.transfer(account3, totalBalance.toNumber(), { from: account2 }));422 });423 it("Should be able to transfer token after unlocking", async () => {424 const totalBalance = await tokenController.totalBalanceOf(account2);425 assert.equal((await tokenController.getUnlockableTokens(account2)).toNumber(), 0);426 await time.increase(lockPeriod);427 assert.equal((await tokenController.getUnlockableTokens(account2)).toNumber(), lockedAmount);428 await tokenController.unlock(account2);429 await plotusToken.transfer(account3, totalBalance.toNumber(), { from: account2 });430 assert.equal((await plotusToken.balanceOf(account2)).toNumber(), 0);431 assert.equal((await tokenController.totalBalanceOf(account2)).toNumber(), 0);432 assert.equal((await plotusToken.balanceOf(account3)).toNumber(), lockedAmount);433 assert.equal((await tokenController.totalBalanceOf(account3)).toNumber(), lockedAmount);434 });435 });436 // describe("Burn Commission tokens", () => {437 // it("Burn commission tokens", async () => {438 // const receipt = await tokenController.burnCommissionTokens.call(10);439 // assert.equal(receipt, false);440 // });441 // });...

Full Screen

Full Screen

EJ2-50148.ts

Source:EJ2-50148.ts Github

copy

Full Screen

1import { TreeMap } from '../src/treemap/treemap';2import { TreeMapTooltip } from '../src/treemap/user-interaction/tooltip';3import { DrillDown } from '../demo/Data/Drilldown_Sample';4import { EmitType } from '@syncfusion/ej2-base';5import{ IDrillStartEventArgs } from '../src/treemap/model/interface';6import{ IDrillEndEventArgs } from '../src/treemap/model/interface';7TreeMap.Inject(TreeMapTooltip);8let data: Object[] = [9 { count: 2010, reason1: 'V', reason2: 'A', reason3: 'L' },10 { count: 2012, reason1: 'V', reason2: 'A', reason3: 'M' },11 { count: 529, reason1: 'V', reason2: 'A', reason3: 'N' },12 { count: 2009, reason1: 'V', reason2: 'A', reason3: 'O' },13 { count: 105, reason1: 'V', reason2: 'A', reason3: 'P' },14 { count: 2213, reason1: 'V', reason2: 'B', reason3: 'Q' },15 { count: 3, reason1: 'V', reason2: 'B', reason3: 'R' },16 { count: 7634, reason1: 'W', reason2: 'A' },17 { count: 1877, reason1: 'W', reason2: 'B' },18 { count: 877, reason1: 'V', reason2: 'A', reason3: 'S' },19 { count: 5610, reason1: 'Y', reason2: 'A' },20 { count: 6635, reason1: 'Z', reason2: 'A' },21 { count: 780, reason1: 'Z', reason2: 'B' },22 { count: 225, reason1: 'Z', reason2: 'C' }23];24let treemap: TreeMap = new TreeMap(25 {26 palette: ['#f44336', '#29b6f6', '#ab47bc', '#ffc107', '#5c6bc0', '#009688'],27 layoutType: 'Squarified',28 dataSource: data,29 weightValuePath: 'count',30 enableDrillDown: true,31 enableBreadcrumb: true,32 breadcrumbConnector: ' // ',33 leafItemSettings: {34 showLabels: true,35 36 },37 levels: [38 {39 groupPath: 'reason1',40 groupGap: 0,41 border: { color: 'black', width: 0.5 }42 },43 {44 groupPath: 'reason2',45 groupGap: 10,46 border: { color: 'white', width: 0.5 }47 },48 { groupPath: 'reason3', border: { color: '#fff', width: 1 } }49 ]50 },51 '#container'...

Full Screen

Full Screen

copyemoji.js

Source:copyemoji.js Github

copy

Full Screen

1exports.help={2 name: "copyemoji",3 description: "Copy a certain emoji and add it to your server",4 usage: "copyemoji <:emoji:>",5 type: "fun"6 };7 exports.run = async (client, message, args) => { 8try{9 if(!message.member.hasPermission("MANAGE_EMOJIS")) return message.channel.send("Insufficient permissions");10 if(!args[0]) return message.channel.send("You need to send what emoji you want to copy`");11 let reason1 = args.join(" ")12reason1 = reason1.split(" ");13let emojilist = []14for(var i = 0; i < reason1.length; i++){1516 17let emojiinfo = reason1[i].split(":")[0];18emojiinfo = emojiinfo.split("<")[1];19let emoji = reason1[i].split(":")[2];20emoji = emoji.split(">")[0];2122 //console.log(`${emoji.split(">")[0]} and ${reason1}`)23 // console.log(emojiinfo, emojiinfo === 'a')24 if(emojiinfo === "a"){2526 message.guild.emojis.create(`https://cdn.discordapp.com/emojis/${emoji}.gif`, reason1[i].split(":")[1])27 .then(emoji =>{ 28message.channel.send(`<a:${emoji.name}:${emoji.id}>`)29 }).catch(err=>message.reply(`Error : \`${err}\``))30 }31 32 if(emojiinfo === ""){33 console.log(reason1[i].split(":")[1])34 message.guild.emojis.create(`https://cdn.discordapp.com/emojis/${emoji}.png`, reason1[i].split(":")[1])35 .then(emoji =>{36 message.channel.send(`<:${emoji.name}:${emoji.id}>`) 37 }).catch(err=>message.reply(`Error : \`${err}\``))38}3940}41//console.log(emojilist)424344message.delete();4546}catch(err){47 console.log(err);48 message.reply("I couldnt create that emoji. Make sure you did everything correct and try again.")49} ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptest = require('wptest');2wptest.reason1();3var wptest = require('wptest');4wptest.reason2();5var wptest = require('wptest');6wptest.reason3();7var wptest = require('wptest');8wptest.reason4();9var wptest = require('wptest');10wptest.reason5();11var wptest = require('wptest');12wptest.reason6();13var wptest = require('wptest');14wptest.reason7();15var wptest = require('wptest');16wptest.reason8();17var wptest = require('wptest');18wptest.reason9();19var wptest = require('wptest');20wptest.reason10();21var wptest = require('wptest');22wptest.reason11();23var wptest = require('wptest');24wptest.reason12();25var wptest = require('wptest');26wptest.reason13();27var wptest = require('wptest');28wptest.reason14();29var wptest = require('wptest');30wptest.reason15();31var wptest = require('wptest');32wptest.reason16();

Full Screen

Using AI Code Generation

copy

Full Screen

1 console.log(data);2});3 console.log(data);4});5 console.log(data);6});7 console.log(data);8});9 console.log(data);10});11 console.log(data);12});13 console.log(data);14});15 console.log(data);16});17 console.log(data);18});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4wpt.runTest(testUrl, options, function(err, data) {5 if (err) return console.error(err);6 console.log('Test Results for: ' + data.data.testUrl);7 console.log('First View (ms): ' + data.data.average.firstView.loadTime);8 console.log('Repeat View (ms): ' + data.data.average.repeatView.loadTime);9 console.log('Speed Index (ms): ' + data.data.average.firstView.SpeedIndex);10 console.log('Video: ' + data.data.runs[1].firstView.video);11 console.log('Video: ' + data.data.runs[1].repeatView.video);12});

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