How to use checkAccount method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

order_from_pass.js

Source:order_from_pass.js Github

copy

Full Screen

1let test = require('test');2test.setup();3let test_util = require('../test_util');4test_util.runBIOS();5let fmt = test_util.fmt;6let checkaccount = test_util.checkaccount;7let fmtDate = test_util.fmtDate;8let checkunswapmarket = test_util.checkunswapmarket;9let checkmarketpool = test_util.checkmarketpool;10let checkmarketorder = test_util.checkmarketorder;11let now;12var users = {};13describe(`order from pass`, () => {14 let symbol = "AAA";15 let contract = "user1"16 let fibos, ctx, name, name1;17 let precision = 4;18 before(() => {19 fibos = test_util.getFIBOS();20 name = contract;21 if (name !== 'eosio' && name !== 'fibos' && !users[name]) {22 users[name] = true;23 test_util.user(fibos, name);24 }25 name1 = test_util.user(fibos);26 ctx = fibos.contractSync("eosio.token");27 ctx.createSync("eosio", "50000000.0000 EOS", {28 authorization: "eosio"29 });30 ctx.setpositionSync(fmt(1000000000, 4, "EOS", "eosio"), 1, "setposition", {31 authorization: "fibos"32 });33 ctx.excreateSync("eosio", `10000000.0000 FO`, 0, `10000000.0000 FO`, `100.0000 FO`, `10000.0000 EOS`, 0, 0, 0, 'eosio', {34 authorization: "eosio"35 });36 ctx.setpositionSync(fmt(1000000000, 4, "FO", "eosio"), 1, "setposition", {37 authorization: "fibos"38 });39 ctx.issueSync("fibos", `10000000.0000 EOS`, `issue 100.0000 EOS`, {40 authorization: "eosio"41 });42 ctx.issueSync("fibos", `1000000.0000 FO`, `issue 100.0000 FO`, {43 authorization: "eosio"44 });45 let transfer_amount = "10000.0000";46 ctx.extransferSync("fibos", name, `${transfer_amount} FO@eosio`, `exchange FO to ${symbol}@${name}`, {47 authorization: "fibos"48 });49 ctx.extransferSync("fibos", name, `${transfer_amount} EOS@eosio`, `exchange FO to ${symbol}@${name}`, {50 authorization: "fibos"51 });52 now = fmtDate();53 ctx.excreateSync(name, fmt(100000000000, precision, symbol), 0, fmt(100000000000, precision, symbol), fmt(300000000, precision, symbol), fmt(1000000, 4, "FO"), now, 0, 0, 'eosio', {54 authorization: name55 });56 ctx.setpositionSync(fmt(1000000000, 4, symbol, name), 1, "setposition", {57 authorization: name58 });59 ctx.exissueSync(name, `1000000.0000 AAA@${name}`, `issue 1000000.0000 AAA`, {60 authorization: name61 });62 });63 it(`create market`, () => {64 checkaccount(fibos, "fibos", "EOS", "eosio", {65 "quantity": "9990000.0000 EOS",66 "contract": "eosio"67 });68 checkaccount(fibos, "fibos", "FO", "eosio", {69 "quantity": "990000.0000 FO",70 "contract": "eosio"71 });72 ctx.addreservesSync("fibos", "10000.0000 EOS@eosio", "1000.0000 FO@eosio", {73 authorization: "fibos"74 });75 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {76 "primary": 0,77 "tokenx": {78 "quantity": "10000.0000 EOS",79 "contract": "eosio"80 },81 "tokeny": {82 "quantity": "1000.0000 FO",83 "contract": "eosio"84 },85 "total_weights": "10000.00000000000000000"86 })87 checkaccount(fibos, "fibos", "EOS", "eosio", {88 "quantity": "9980000.0000 EOS",89 "contract": "eosio"90 });91 checkaccount(fibos, "fibos", "FO", "eosio", {92 "quantity": "989000.0000 FO",93 "contract": "eosio"94 });95 checkmarketpool(fibos, "fibos", 0, {96 "owner": "fibos",97 "weights": "10000.00000000000000000"98 });99 });100 it(`使用fibos来进行限价交易,以11的价格卖10000个FO ,权限错误,应抛出异常 `, () => {101 assert.throws(() => {102 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test", "memo", {103 authorization: name104 });105 });106 });107 it(`使用fibos来进行限价交易,以11的价格卖10000个FO, to不为0,应抛出异常 `, () => {108 assert.throws(() => {109 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "10.0000 FO@eosio", 11, "test", "memo", {110 authorization: "fibos"111 });112 });113 });114 it(`使用fibos来进行限价交易,from为0,to为0,应抛出异常 `, () => {115 assert.throws(() => {116 ctx.exchangeSync("fibos", "0.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test", "memo", {117 authorization: "fibos"118 });119 });120 });121 it(`使用fibos来进行限价交易,from为0,to为0,price为0,应抛出异常 `, () => {122 assert.throws(() => {123 ctx.exchangeSync("fibos", "0.0000 EOS@eosio", "0.0000 FO@eosio", 0, "test", "memo", {124 authorization: "fibos"125 });126 });127 });128 it(`使用fibos来进行限价交易,from,to不为0,price为0,应抛出异常 `, () => {129 assert.throws(() => {130 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "100.0000 FO@eosio", 0, "test", "memo", {131 authorization: "fibos"132 });133 });134 });135 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,from精度错误,应抛出异常 `, () => {136 assert.throws(() => {137 ctx.exchangeSync("fibos", "10000.000 EOS@eosio", "0.0000 FO@eosio", 11, "test", "memo", {138 authorization: "fibos"139 });140 });141 });142 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,to精度错误,应抛出异常 `, () => {143 assert.throws(() => {144 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "0.000 FO@eosio", 11, "test", "memo", {145 authorization: "fibos"146 });147 });148 });149 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,price精度错误,应抛出异常 `, () => {150 assert.throws(() => {151 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "0.000 FO@eosio", 11.000001, "test", "memo", {152 authorization: "fibos"153 });154 });155 });156 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,from为负数,应抛出异常 `, () => {157 assert.throws(() => {158 ctx.exchangeSync("fibos", "-10000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test", "memo", {159 authorization: "fibos"160 });161 });162 });163 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,price为负数,应抛出异常 `, () => {164 assert.throws(() => {165 ctx.exchangeSync("fibos", "10000.0000 EOS@eosio", "0.0000 FO@eosio", -11, "test", "memo", {166 authorization: "fibos"167 });168 });169 });170 it(`使用fibos来进行限价交易,以11的价格卖10000个FO,from、price为负数,应抛出异常 `, () => {171 assert.throws(() => {172 ctx.exchangeSync("fibos", "-10000.0000 EOS@eosio", "0.0000 FO@eosio", -11, "test", "memo", {173 authorization: "fibos"174 });175 });176 });177 it(`使用fibos来进行限价交易,以11的价格卖1000个EOS ,在价格到达设定价格时买不完,剩余的挂单`, () => {178 checkaccount(fibos, "fibos", "EOS", "eosio", {179 "quantity": "9980000.0000 EOS",180 "contract": "eosio"181 });182 checkaccount(fibos, "fibos", "FO", "eosio", {183 "quantity": "989000.0000 FO",184 "contract": "eosio"185 });186 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {187 "primary": 0,188 "tokenx": {189 "quantity": "10000.0000 EOS",190 "contract": "eosio"191 },192 "tokeny": {193 "quantity": "1000.0000 FO",194 "contract": "eosio"195 },196 "total_weights": "10000.00000000000000000"197 })198 let r = ctx.exchangeSync("fibos", "1000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test", "memo", {199 authorization: "fibos"200 });201 assert.deepEqual(r.processed.action_traces[0].inline_traces[1].act.data, {202 "owner": "fibos",203 "oppo": "eosio",204 "from": {205 "quantity": "488.0885 EOS",206 "contract": "eosio"207 },208 "to": {209 "quantity": "46.3977 FO",210 "contract": "eosio"211 },212 "fee": {213 "quantity": "0.1397 FO",214 "contract": "eosio"215 },216 "bid_id": 0217 });218 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {219 "primary": 0,220 "tokenx": {221 "quantity": "10488.0885 EOS",222 "contract": "eosio"223 },224 "tokeny": {225 "quantity": "953.6023 FO",226 "contract": "eosio"227 },228 "total_weights": "10000.00000000000000000"229 })230 checkaccount(fibos, "fibos", "EOS", "eosio", {231 "quantity": "9979000.0000 EOS",232 "contract": "eosio"233 });234 checkaccount(fibos, "fibos", "FO", "eosio", {235 "quantity": "989046.3977 FO",236 "contract": "eosio"237 });238 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");239 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");240 });241 it(`使用name来进行限价交易,以0.092的价格卖46.5375个FO ,在价格超过设定的价格时进行订单撮合,正好与订单全部撮合完 `, () => {242 checkaccount(fibos, "fibos", "EOS", "eosio", {243 "quantity": "9979000.0000 EOS",244 "contract": "eosio"245 });246 checkaccount(fibos, "fibos", "FO", "eosio", {247 "quantity": "989046.3977 FO",248 "contract": "eosio"249 });250 checkaccount(fibos, name, "EOS", "eosio", {251 "quantity": "10000.0000 EOS",252 "contract": "eosio"253 });254 checkaccount(fibos, name, "FO", "eosio", {255 "quantity": "10000.0000 FO",256 "contract": "eosio"257 });258 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {259 "primary": 0,260 "tokenx": {261 "quantity": "10488.0885 EOS",262 "contract": "eosio"263 },264 "tokeny": {265 "quantity": "953.6023 FO",266 "contract": "eosio"267 },268 "total_weights": "10000.00000000000000000"269 })270 ctx.exchangeSync(name, "46.5375 FO@eosio", "0.0000 EOS@eosio", 0.0990, "test2", "memo2", {271 authorization: name272 });273 let r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");274 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");275 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {276 "primary": 0,277 "tokenx": {278 "quantity": "10489.1124 EOS",279 "contract": "eosio"280 },281 "tokeny": {282 "quantity": "953.6489 FO",283 "contract": "eosio"284 },285 "total_weights": "10000.00000000000000000"286 })287 checkaccount(fibos, "fibos", "EOS", "eosio", {288 "quantity": "9979000.0000 EOS",289 "contract": "eosio"290 });291 checkaccount(fibos, "fibos", "FO", "eosio", {292 "quantity": "989092.8886 FO",293 "contract": "eosio"294 });295 checkaccount(fibos, name, "EOS", "eosio", {296 "quantity": "10510.8876 EOS",297 "contract": "eosio"298 });299 checkaccount(fibos, name, "FO", "eosio", {300 "quantity": "9953.4625 FO",301 "contract": "eosio"302 });303 });304 it(`使用fibos来进行限价交易,以11的价格卖1000个EOS ,由于税收的存在,导致目前的市场价格稍低于11,在价格到达设定价格时买不完,进行挂单`, () => {305 checkaccount(fibos, "fibos", "EOS", "eosio", {306 "quantity": "9979000.0000 EOS",307 "contract": "eosio"308 });309 checkaccount(fibos, "fibos", "FO", "eosio", {310 "quantity": "989092.8886 FO",311 "contract": "eosio"312 });313 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {314 "primary": 0,315 "tokenx": {316 "quantity": "10489.1124 EOS",317 "contract": "eosio"318 },319 "tokeny": {320 "quantity": "953.6489 FO",321 "contract": "eosio"322 },323 "total_weights": "10000.00000000000000000"324 })325 let r = ctx.exchangeSync("fibos", "1000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test3", "memo3", {326 authorization: "fibos"327 });328 assert.deepEqual(r.processed.action_traces[0].inline_traces[1].act.data, {329 "owner": "fibos",330 "oppo": "eosio",331 "from": {332 "quantity": "0.5127 EOS",333 "contract": "eosio"334 },335 "to": {336 "quantity": "0.0464 FO",337 "contract": "eosio"338 },339 "fee": {340 "quantity": "0.0002 FO",341 "contract": "eosio"342 },343 "bid_id": 0344 });345 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {346 "primary": 0,347 "tokenx": {348 "quantity": "10489.6251 EOS",349 "contract": "eosio"350 },351 "tokeny": {352 "quantity": "953.6025 FO",353 "contract": "eosio"354 },355 "total_weights": "10000.00000000000000000"356 })357 checkaccount(fibos, "fibos", "EOS", "eosio", {358 "quantity": "9978000.0000 EOS",359 "contract": "eosio"360 });361 checkaccount(fibos, "fibos", "FO", "eosio", {362 "quantity": "989092.9350 FO",363 "contract": "eosio"364 });365 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");366 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");367 });368 it(`使用name来进行限价交易,以0.0959的价格卖200个FO ,在价格超过设定的价格时进行订单撮合,将订单全部撮合完,撮合后剩余部分和市场uniswap `, () => {369 checkaccount(fibos, "fibos", "EOS", "eosio", {370 "quantity": "9978000.0000 EOS",371 "contract": "eosio"372 });373 checkaccount(fibos, "fibos", "FO", "eosio", {374 "quantity": "989092.9350 FO",375 "contract": "eosio"376 });377 checkaccount(fibos, name, "EOS", "eosio", {378 "quantity": "10510.8876 EOS",379 "contract": "eosio"380 });381 checkaccount(fibos, name, "FO", "eosio", {382 "quantity": "9953.4625 FO",383 "contract": "eosio"384 });385 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {386 "primary": 0,387 "tokenx": {388 "quantity": "10489.6251 EOS",389 "contract": "eosio"390 },391 "tokeny": {392 "quantity": "953.6025 FO",393 "contract": "eosio"394 },395 "total_weights": "10000.00000000000000000"396 })397 let r = ctx.exchangeSync(name, "200.0000 FO@eosio", "0.0000 EOS@eosio", 0.0959, "test2", "memo2", {398 authorization: name399 });400 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");401 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");402 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {403 "primary": 0,404 "tokenx": {405 "quantity": "10215.8533 EOS",406 "contract": "eosio"407 },408 "tokeny": {409 "quantity": "979.5199 FO",410 "contract": "eosio"411 },412 "total_weights": "10000.00000000000000000"413 })414 checkaccount(fibos, "fibos", "EOS", "eosio", {415 "quantity": "9978000.0000 EOS",416 "contract": "eosio"417 });418 checkaccount(fibos, "fibos", "FO", "eosio", {419 "quantity": "989183.7066 FO",420 "contract": "eosio"421 });422 checkaccount(fibos, name, "EOS", "eosio", {423 "quantity": "11784.1467 EOS",424 "contract": "eosio"425 });426 checkaccount(fibos, name, "FO", "eosio", {427 "quantity": "9753.4625 FO",428 "contract": "eosio"429 });430 });431 it(`使用name来进行限价交易,以0.0959的价格卖100个FO ,由于手续费的存在,价格再上一次操作后稍微低于0.0959,故会先和市场进行uniswap交易,剩余部分进行挂单,两个挂单会进行合并 `, () => {432 checkaccount(fibos, name, "EOS", "eosio", {433 "quantity": "11784.1467 EOS",434 "contract": "eosio"435 });436 checkaccount(fibos, name, "FO", "eosio", {437 "quantity": "9753.4625 FO",438 "contract": "eosio"439 });440 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {441 "primary": 0,442 "tokenx": {443 "quantity": "10215.8533 EOS",444 "contract": "eosio"445 },446 "tokeny": {447 "quantity": "979.5199 FO",448 "contract": "eosio"449 },450 "total_weights": "10000.00000000000000000"451 })452 let r = ctx.exchangeSync(name, "100.0000 FO@eosio", "0.0000 EOS@eosio", 0.0959, "test3", "memo3", {453 authorization: name454 });455 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");456 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");457 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {458 "primary": 0,459 "tokenx": {460 "quantity": "10214.9154 EOS",461 "contract": "eosio"462 },463 "tokeny": {464 "quantity": "979.6101 FO",465 "contract": "eosio"466 },467 "total_weights": "10000.00000000000000000"468 })469 checkaccount(fibos, name, "EOS", "eosio", {470 "quantity": "11785.0846 EOS",471 "contract": "eosio"472 });473 checkaccount(fibos, name, "FO", "eosio", {474 "quantity": "9653.4625 FO",475 "contract": "eosio"476 });477 });478 it(`使用name来进行限价交易,以0.0969的价格卖100个FO ,由于手续费的存在,价格再上一次操作后稍微低于0.0959,会先和市场进行uniswap交易至价格达到0.0969,剩余部分进行挂单,由于和之前的价格不同,故会有两个挂单 `, () => {479 checkaccount(fibos, name, "EOS", "eosio", {480 "quantity": "11785.0846 EOS",481 "contract": "eosio"482 });483 checkaccount(fibos, name, "FO", "eosio", {484 "quantity": "9653.4625 FO",485 "contract": "eosio"486 });487 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {488 "primary": 0,489 "tokenx": {490 "quantity": "10214.9154 EOS",491 "contract": "eosio"492 },493 "tokeny": {494 "quantity": "979.6101 FO",495 "contract": "eosio"496 },497 "total_weights": "10000.00000000000000000"498 })499 let r = ctx.exchangeSync(name, "100.0000 FO@eosio", "0.0000 EOS@eosio", 0.0969, "test3", "memo3", {500 authorization: name501 });502 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");503 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");504 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {505 "primary": 0,506 "tokenx": {507 "quantity": "10162.2273 EOS",508 "contract": "eosio"509 },510 "tokeny": {511 "quantity": "984.7045 FO",512 "contract": "eosio"513 },514 "total_weights": "10000.00000000000000000"515 })516 checkaccount(fibos, name, "EOS", "eosio", {517 "quantity": "11837.7727 EOS",518 "contract": "eosio"519 });520 checkaccount(fibos, name, "FO", "eosio", {521 "quantity": "9553.4625 FO",522 "contract": "eosio"523 });524 });525 it(`使用fibos来进行限价交易,以11的价格卖1000个EOS ,首先会吃点低于市场价的挂单,还有剩余和市场进行uniswap,交易完价格还没有达到其他挂单的价格,故还剩下一个挂单`, () => {526 checkaccount(fibos, "fibos", "EOS", "eosio", {527 "quantity": "9978000.0000 EOS",528 "contract": "eosio"529 });530 checkaccount(fibos, "fibos", "FO", "eosio", {531 "quantity": "989183.7066 FO",532 "contract": "eosio"533 });534 checkaccount(fibos, name, "EOS", "eosio", {535 "quantity": "11837.7727 EOS",536 "contract": "eosio"537 });538 checkaccount(fibos, name, "FO", "eosio", {539 "quantity": "9553.4625 FO",540 "contract": "eosio"541 });542 let r = checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {543 "primary": 0,544 "tokenx": {545 "quantity": "10162.2273 EOS",546 "contract": "eosio"547 },548 "tokeny": {549 "quantity": "984.7045 FO",550 "contract": "eosio"551 },552 "total_weights": "10000.00000000000000000"553 })554 r = ctx.exchangeSync("fibos", "1000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test4", "memo4", {555 authorization: "fibos"556 });557 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {558 "primary": 0,559 "tokenx": {560 "quantity": "10183.7888 EOS",561 "contract": "eosio"562 },563 "tokeny": {564 "quantity": "982.9101 FO",565 "contract": "eosio"566 },567 "total_weights": "10000.00000000000000000"568 })569 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");570 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");571 checkaccount(fibos, "fibos", "EOS", "eosio", {572 "quantity": "9977000.0000 EOS",573 "contract": "eosio"574 });575 checkaccount(fibos, "fibos", "FO", "eosio", {576 "quantity": "989280.4066 FO",577 "contract": "eosio"578 });579 checkaccount(fibos, name, "EOS", "eosio", {580 "quantity": "12816.2112 EOS",581 "contract": "eosio"582 });583 checkaccount(fibos, name, "FO", "eosio", {584 "quantity": "9553.4625 FO",585 "contract": "eosio"586 });587 });588 it(`使用fibos来进行限价交易,以0.0969的价格卖100个FO ,价格低于市场价和存在的挂单价格,故会全部进行挂单,当前市面上会存在一笔user的挂单,一笔fibos的挂单 `, () => {589 checkaccount(fibos, "fibos", "EOS", "eosio", {590 "quantity": "9977000.0000 EOS",591 "contract": "eosio"592 });593 checkaccount(fibos, "fibos", "FO", "eosio", {594 "quantity": "989280.4066 FO",595 "contract": "eosio"596 });597 checkaccount(fibos, name, "EOS", "eosio", {598 "quantity": "12816.2112 EOS",599 "contract": "eosio"600 });601 checkaccount(fibos, name, "FO", "eosio", {602 "quantity": "9553.4625 FO",603 "contract": "eosio"604 });605 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {606 "primary": 0,607 "tokenx": {608 "quantity": "10183.7888 EOS",609 "contract": "eosio"610 },611 "tokeny": {612 "quantity": "982.9101 FO",613 "contract": "eosio"614 },615 "total_weights": "10000.00000000000000000"616 })617 let r = ctx.exchangeSync("fibos", "100.0000 FO@eosio", "0.0000 EOS@eosio", 0.0964, "test3", "memo3", {618 authorization: "fibos"619 });620 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");621 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");622 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {623 "primary": 0,624 "tokenx": {625 "quantity": "10183.7888 EOS",626 "contract": "eosio"627 },628 "tokeny": {629 "quantity": "982.9101 FO",630 "contract": "eosio"631 },632 "total_weights": "10000.00000000000000000"633 })634 checkaccount(fibos, "fibos", "EOS", "eosio", {635 "quantity": "9977000.0000 EOS",636 "contract": "eosio"637 });638 checkaccount(fibos, "fibos", "FO", "eosio", {639 "quantity": "989180.4066 FO",640 "contract": "eosio"641 });642 checkaccount(fibos, name, "EOS", "eosio", {643 "quantity": "12816.2112 EOS",644 "contract": "eosio"645 });646 checkaccount(fibos, name, "FO", "eosio", {647 "quantity": "9553.4625 FO",648 "contract": "eosio"649 });650 });651 it(`使用fibos来进行限价交易,以11的价格卖3000个EOS ,首先会吃点低于市场价的挂单,将所有的挂单全部吃掉,包括吃掉自己的单子,还有剩余和市场进行uniswap,`, () => {652 checkaccount(fibos, "fibos", "EOS", "eosio", {653 "quantity": "9977000.0000 EOS",654 "contract": "eosio"655 });656 checkaccount(fibos, "fibos", "FO", "eosio", {657 "quantity": "989180.4066 FO",658 "contract": "eosio"659 });660 checkaccount(fibos, name, "EOS", "eosio", {661 "quantity": "12816.2112 EOS",662 "contract": "eosio"663 });664 checkaccount(fibos, name, "FO", "eosio", {665 "quantity": "9553.4625 FO",666 "contract": "eosio"667 });668 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {669 "primary": 0,670 "tokenx": {671 "quantity": "10183.7888 EOS",672 "contract": "eosio"673 },674 "tokeny": {675 "quantity": "982.9101 FO",676 "contract": "eosio"677 },678 "total_weights": "10000.00000000000000000"679 })680 r = ctx.exchangeSync("fibos", "3000.0000 EOS@eosio", "0.0000 FO@eosio", 11, "test4", "memo4", {681 authorization: "fibos"682 });683 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {684 "primary": 0,685 "tokenx": {686 "quantity": "10238.8522 EOS",687 "contract": "eosio"688 },689 "tokeny": {690 "quantity": "978.4874 FO",691 "contract": "eosio"692 },693 "total_weights": "10000.00000000000000000"694 })695 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");696 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");697 checkaccount(fibos, "fibos", "EOS", "eosio", {698 "quantity": "9975036.3070 EOS",699 "contract": "eosio"700 });701 checkaccount(fibos, "fibos", "FO", "eosio", {702 "quantity": "989468.0501 FO",703 "contract": "eosio"704 });705 checkaccount(fibos, name, "EOS", "eosio", {706 "quantity": "14724.8408 EOS",707 "contract": "eosio"708 });709 checkaccount(fibos, name, "FO", "eosio", {710 "quantity": "9553.4625 FO",711 "contract": "eosio"712 });713 });714 it(`使用name来进行限价交易,以0.0954的价格卖100个FO ,由于低于市场价格,全部挂单 `, () => {715 checkaccount(fibos, "fibos", "EOS", "eosio", {716 "quantity": "9975036.3070 EOS",717 "contract": "eosio"718 });719 checkaccount(fibos, "fibos", "FO", "eosio", {720 "quantity": "989468.0501 FO",721 "contract": "eosio"722 });723 checkaccount(fibos, name, "EOS", "eosio", {724 "quantity": "14724.8408 EOS",725 "contract": "eosio"726 });727 checkaccount(fibos, name, "FO", "eosio", {728 "quantity": "9553.4625 FO",729 "contract": "eosio"730 });731 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {732 "primary": 0,733 "tokenx": {734 "quantity": "10238.8522 EOS",735 "contract": "eosio"736 },737 "tokeny": {738 "quantity": "978.4874 FO",739 "contract": "eosio"740 },741 "total_weights": "10000.00000000000000000"742 })743 let r = ctx.exchangeSync(name, "100.0000 FO@eosio", "0.0000 EOS@eosio", 0.0954, "test3", "memo3", {744 authorization: name745 });746 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");747 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");748 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {749 "primary": 0,750 "tokenx": {751 "quantity": "10238.8522 EOS",752 "contract": "eosio"753 },754 "tokeny": {755 "quantity": "978.4874 FO",756 "contract": "eosio"757 },758 "total_weights": "10000.00000000000000000"759 })760 checkaccount(fibos, "fibos", "EOS", "eosio", {761 "quantity": "9975036.3070 EOS",762 "contract": "eosio"763 });764 checkaccount(fibos, "fibos", "FO", "eosio", {765 "quantity": "989468.0501 FO",766 "contract": "eosio"767 });768 checkaccount(fibos, name, "EOS", "eosio", {769 "quantity": "14724.8408 EOS",770 "contract": "eosio"771 });772 checkaccount(fibos, name, "FO", "eosio", {773 "quantity": "9453.4625 FO",774 "contract": "eosio"775 });776 });777 it(`使用name来进行限价交易,以0.0956的价格卖100个FO ,由于高于市场价格,会先和市场价进行uniswap,剩余部分挂单 `, () => {778 checkaccount(fibos, "fibos", "EOS", "eosio", {779 "quantity": "9975036.3070 EOS",780 "contract": "eosio"781 });782 checkaccount(fibos, "fibos", "FO", "eosio", {783 "quantity": "989468.0501 FO",784 "contract": "eosio"785 });786 checkaccount(fibos, name, "EOS", "eosio", {787 "quantity": "14724.8408 EOS",788 "contract": "eosio"789 });790 checkaccount(fibos, name, "FO", "eosio", {791 "quantity": "9453.4625 FO",792 "contract": "eosio"793 });794 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {795 "primary": 0,796 "tokenx": {797 "quantity": "10238.8522 EOS",798 "contract": "eosio"799 },800 "tokeny": {801 "quantity": "978.4874 FO",802 "contract": "eosio"803 },804 "total_weights": "10000.00000000000000000"805 })806 let r = ctx.exchangeSync(name, "100.0000 FO@eosio", "0.0000 EOS@eosio", 0.0956, "test4", "memo4", {807 authorization: name808 });809 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");810 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");811 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {812 "primary": 0,813 "tokenx": {814 "quantity": "10237.0434 EOS",815 "contract": "eosio"816 },817 "tokeny": {818 "quantity": "978.6608 FO",819 "contract": "eosio"820 },821 "total_weights": "10000.00000000000000000"822 })823 checkaccount(fibos, "fibos", "EOS", "eosio", {824 "quantity": "9975036.3070 EOS",825 "contract": "eosio"826 });827 checkaccount(fibos, "fibos", "FO", "eosio", {828 "quantity": "989468.0501 FO",829 "contract": "eosio"830 });831 checkaccount(fibos, name, "EOS", "eosio", {832 "quantity": "14726.6496 EOS",833 "contract": "eosio"834 });835 checkaccount(fibos, name, "FO", "eosio", {836 "quantity": "9353.4625 FO",837 "contract": "eosio"838 });839 });840 it(`使用fibos来进行限价交易,以10.50的价格卖3000个EOS ,首先会吃点低于市场价的挂单,将低于市场价格的单子吃掉,还有剩余和市场进行uniswap,最后超过市场价格的进行挂单`, () => {841 checkaccount(fibos, "fibos", "EOS", "eosio", {842 "quantity": "9975036.3070 EOS",843 "contract": "eosio"844 });845 checkaccount(fibos, "fibos", "FO", "eosio", {846 "quantity": "989468.0501 FO",847 "contract": "eosio"848 });849 checkaccount(fibos, name, "EOS", "eosio", {850 "quantity": "14726.6496 EOS",851 "contract": "eosio"852 });853 checkaccount(fibos, name, "FO", "eosio", {854 "quantity": "9353.4625 FO",855 "contract": "eosio"856 });857 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {858 "primary": 0,859 "tokenx": {860 "quantity": "10237.0434 EOS",861 "contract": "eosio"862 },863 "tokeny": {864 "quantity": "978.6608 FO",865 "contract": "eosio"866 },867 "total_weights": "10000.00000000000000000"868 })869 r = ctx.exchangeSync("fibos", "3000.0000 EOS@eosio", "0.0000 FO@eosio", 10.50, "test5", "memo5", {870 authorization: "fibos"871 });872 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {873 "primary": 0,874 "tokenx": {875 "quantity": "10258.5651 EOS",876 "contract": "eosio"877 },878 "tokeny": {879 "quantity": "977.2122 FO",880 "contract": "eosio"881 },882 "total_weights": "10000.00000000000000000"883 })884 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");885 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");886 checkaccount(fibos, "fibos", "EOS", "eosio", {887 "quantity": "9972036.3070 EOS",888 "contract": "eosio"889 });890 checkaccount(fibos, "fibos", "FO", "eosio", {891 "quantity": "989669.3253 FO",892 "contract": "eosio"893 });894 checkaccount(fibos, name, "EOS", "eosio", {895 "quantity": "16816.9864 EOS",896 "contract": "eosio"897 });898 checkaccount(fibos, name, "FO", "eosio", {899 "quantity": "9353.4625 FO",900 "contract": "eosio"901 });902 });903 it(`使用fibos来进行撤单`, () => {904 checkaccount(fibos, "fibos", "EOS", "eosio", {905 "quantity": "9972036.3070 EOS",906 "contract": "eosio"907 });908 checkaccount(fibos, "fibos", "FO", "eosio", {909 "quantity": "989669.3253 FO",910 "contract": "eosio"911 });912 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {913 "primary": 0,914 "tokenx": {915 "quantity": "10258.5651 EOS",916 "contract": "eosio"917 },918 "tokeny": {919 "quantity": "977.2122 FO",920 "contract": "eosio"921 },922 "total_weights": "10000.00000000000000000"923 })924 let r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");925 let bid_id = r.rows[0].bid_id;926 r = ctx.withdrawSync("fibos", "0.0000 FO@eosio", "0.0000 EOS@eosio", bid_id, {927 authorization: "fibos"928 });929 checkunswapmarket(fibos, "FO@eosio", "EOS@eosio", {930 "primary": 0,931 "tokenx": {932 "quantity": "10258.5651 EOS",933 "contract": "eosio"934 },935 "tokeny": {936 "quantity": "977.2122 FO",937 "contract": "eosio"938 },939 "total_weights": "10000.00000000000000000"940 })941 r = fibos.getTableRowsSync(true, "eosio.token", "18374686479671623680", "swaporder");942 r = fibos.getTableRowsSync(true, "eosio.token", 0, "swaporder");943 checkaccount(fibos, "fibos", "EOS", "eosio", {944 "quantity": "9972924.4485 EOS",945 "contract": "eosio"946 });947 checkaccount(fibos, "fibos", "FO", "eosio", {948 "quantity": "989669.3253 FO",949 "contract": "eosio"950 });951 });952});...

Full Screen

Full Screen

user.js

Source:user.js Github

copy

Full Screen

1const { check } = require('../public/js/check');2const collection = require("../config/mongoCollections");3const bcrypt = require("bcryptjs");4const saltRounds = 10;5module.exports = {6 create,7 login,8 updateInformation,9 forgetPassword,10 findOne,11 search12}13async function create(account, password, nickname, gender, address) {14 let errors = [];15 if (arguments.length != 5) errors.push("arguments");16 if (!(account = check(account, "account"))) errors.push("account");17 if (!(password = check(password, "password"))) errors.push("password");18 if (!(nickname = check(nickname, "nickname"))) errors.push("nickname");19 if (!(gender = check(gender, "gender"))) errors.push("gender");20 if (!(address = check(address, "address"))) errors.push("address");21 if (errors.length > 0) return { "hasErrors": true, "errors": errors };22 let user = {23 "account": account,24 "password": await bcrypt.hash(password, saltRounds),25 "nickname": nickname,26 "gender": gender,27 "address": address,28 "cart": []29 }30 const userCol = await collection.getCollection('user');31 const checkAccount = await userCol.findOne({ "account": account });32 if (checkAccount != null) {33 await collection.closeCollection();34 errors.push("account exist");35 return { "hasErrors": true, "errors": errors };36 }37 const insertInfo = await userCol.insertOne(user);38 if (insertInfo.insertedCount === 0) {39 await collection.closeCollection();40 throw "Can't create account in mongodb, something went wrong, please try again!";41 }42 const insertedUser = await userCol.findOne({ _id: insertInfo.insertedId });43 if (insertedUser === null) {44 await collection.closeCollection();45 throw "Can't find created account in mongodb, something went wrong! Please try again!";46 }47 await collection.closeCollection();48 insertedUser._id = insertedUser._id.toString();49 return { "hasErrors": false, "user": insertedUser };50}51async function login(account, password) {52 let errors = [];53 if (arguments.length != 2) errors.push("arguments");54 if (!(account = check(account, "account"))) errors.push("account");55 if (!(password = check(password, "password"))) errors.push("password");56 if (errors.length > 0) return { "hasErrors": true, "errors": errors };57 const userCol = await collection.getCollection('user');58 const checkAccount = await userCol.findOne({ "account": account });59 if (checkAccount == null) {60 await collection.closeCollection();61 errors.push("account not exist");62 return { "hasErrors": true, "errors": errors };63 }64 if (! await bcrypt.compare(password, checkAccount.password)) {65 await collection.closeCollection();66 errors.push("password not correct");67 return { "hasErrors": true, "errors": errors };68 }69 await collection.closeCollection();70 checkAccount._id = checkAccount._id.toString();71 for (let i = 0; i < checkAccount.cart.length; i++) {72 checkAccount.cart[i] = checkAccount.cart[i].toString();73 }74 return { "hasErrors": false, "user": checkAccount };75}76async function forgetPassword(account, newPassword) {77 let errors = [];78 if (arguments.length != 2) errors.push("arguments");79 if (!(account = check(account, "account"))) errors.push("account");80 if (!(newPassword = check(newPassword, "password"))) errors.push("password");81 if (errors.length > 0) return { "hasErrors": true, "errors": errors };82 const userCol = await collection.getCollection('user');83 const checkAccount = await userCol.findOne({ "account": account });84 if (checkAccount == null) {85 await collection.closeCollection();86 errors.push("account not exist!");87 return { "hasErrors": true, "errors": errors };88 }89 if (await bcrypt.compare(newPassword, checkAccount.password)) {90 await collection.closeCollection();91 errors.push("same");92 return { "hasErrors": true, "errors": errors };93 }94 const updatedInfo = await userCol.updateOne(95 { "account": account },96 { $set: { "password": await bcrypt.hash(newPassword, saltRounds) } }97 );98 if (updatedInfo.modifiedCount === 0) {99 await collection.closeCollection();100 throw "Can't update password in mongodb, something went wrong, please try again!";101 }102 const updatedUser = await userCol.findOne({ "account": account });103 if (updatedUser === null) {104 await collection.closeCollection();105 throw "Can't find updated account in mongodb, something went wrong! Please try again!";106 }107 await collection.closeCollection();108 updatedUser._id = updatedUser._id.toString();109 for (let i = 0; i < updatedUser.cart.length; i++) {110 updatedUser.cart[i] = updatedUser.cart[i].toString();111 }112 return { "hasErrors": false, "user": updatedUser };113}114async function updateInformation(account, nickname, gender, address) {115 let errors = [];116 if (arguments.length != 4) errors.push("arguments");117 if (!(account = check(account, "account"))) errors.push("account");118 if (!(nickname = check(nickname, "nickname"))) errors.push("nickname");119 if (!(gender = check(gender, "gender"))) errors.push("gender");120 if (!(address = check(address, "address"))) errors.push("address");121 if (errors.length > 0) return { "hasErrors": true, "errors": errors };122 const userCol = await collection.getCollection('user');123 const checkAccount = await userCol.findOne({ "account": account });124 if (checkAccount == null) {125 await collection.closeCollection();126 errors.push("account not exist!");127 return { "hasErrors": true, "errors": errors };128 }129 if (checkAccount.nickname == nickname &&130 checkAccount.gender == gender &&131 checkAccount.address.street == address.street &&132 checkAccount.address.apt == address.apt &&133 checkAccount.address.city == address.city &&134 checkAccount.address.state == address.state &&135 checkAccount.address.zipCode == address.zipCode) {136 await collection.closeCollection();137 errors.push("same");138 return { "hasErrors": true, "errors": errors };139 }140 let newUser = {141 "account": account,142 "password": checkAccount.password,143 "nickname": nickname,144 "gender": gender,145 "address": address,146 "cart": checkAccount.cart147 }148 const updatedInfo = await userCol.updateOne(149 { "account": account },150 { $set: newUser }151 );152 if (updatedInfo.modifiedCount === 0) {153 await collection.closeCollection();154 throw "Can't update password in mongodb, something went wrong, please try again!";155 }156 const updatedUser = await userCol.findOne({ "account": account });157 if (updatedUser === null) {158 await collection.closeCollection();159 throw "Can't find updated account in mongodb, something went wrong, Please try again!";160 }161 await collection.closeCollection();162 updatedUser._id = updatedUser._id.toString();163 for (let i = 0; i < updatedUser.cart.length; i++) {164 updatedUser.cart[i] = updatedUser.cart[i].toString();165 }166 return { "hasErrors": false, "user": updatedUser };167}168async function findOne(account) {169 let errors = [];170 if (arguments.length != 1) errors.push("arguments");171 if (!(account = check(account, "account"))) errors.push("account");172 if (errors.length > 0) return { "hasErrors": true, "errors": errors };173 const userCol = await collection.getCollection('user');174 const checkAccount = await userCol.findOne({ "account": account });175 if (checkAccount == null) {176 await collection.closeCollection();177 errors.push("account not exist!");178 return { "hasErrors": true, "errors": errors };179 }180 await collection.closeCollection();181 checkAccount._id = checkAccount._id.toString();182 for (let i = 0; i < checkAccount.cart.length; i++) {183 checkAccount.cart[i] = checkAccount.cart[i].toString();184 }185 return { "hasErrors": false, "user": checkAccount };186}187async function search(keyword, account) {188 let errors = [];189 if (arguments.length != 2) errors.push("arguments");190 if ((keyword = check(keyword, "keyword")) === false) errors.push("keyword");191 if (!(account = check(account, "account"))) errors.push("account");192 if (errors.length > 0) return { "hasErrors": true, "errors": errors };193 const userCol = await collection.getCollection('user');194 const users = await userCol.find(195 {196 $and: [{ "account": { $ne: account } },197 { "account": new RegExp(keyword) }]198 },199 { projection: { "account": 1, "_id": 0 } }).toArray();200 await collection.closeCollection();201 return { "hasErrors": false, "users": users };...

Full Screen

Full Screen

cashiers-check.js

Source:cashiers-check.js Github

copy

Full Screen

1const anchor = require("@project-serum/anchor");2const serumCmn = require("@project-serum/common");3const { assert } = require("chai");4const { TOKEN_PROGRAM_ID } = require("@solana/spl-token");5describe("cashiers-check", () => {6 // Configure the client to use the local cluster.7 const provider = anchor.AnchorProvider.env();8 // hack so we don't have to update serum-common library9 // to the new AnchorProvider class and Provider interface10 provider.send = provider.sendAndConfirm;11 anchor.setProvider(provider);12 const program = anchor.workspace.CashiersCheck;13 let mint = null;14 let god = null;15 let receiver = null;16 it("Sets up initial test state", async () => {17 const [_mint, _god] = await serumCmn.createMintAndVault(18 program.provider,19 new anchor.BN(1000000)20 );21 mint = _mint;22 god = _god;23 receiver = await serumCmn.createTokenAccount(24 program.provider,25 mint,26 program.provider.wallet.publicKey27 );28 });29 const check = anchor.web3.Keypair.generate();30 const vault = anchor.web3.Keypair.generate();31 let checkSigner = null;32 it("Creates a check!", async () => {33 let [_checkSigner, nonce] = await anchor.web3.PublicKey.findProgramAddress(34 [check.publicKey.toBuffer()],35 program.programId36 );37 checkSigner = _checkSigner;38 await program.rpc.createCheck(new anchor.BN(100), "Hello world", nonce, {39 accounts: {40 check: check.publicKey,41 vault: vault.publicKey,42 checkSigner,43 from: god,44 to: receiver,45 owner: program.provider.wallet.publicKey,46 tokenProgram: TOKEN_PROGRAM_ID,47 rent: anchor.web3.SYSVAR_RENT_PUBKEY,48 },49 signers: [check, vault],50 instructions: [51 await program.account.check.createInstruction(check, 300),52 ...(await serumCmn.createTokenAccountInstrs(53 program.provider,54 vault.publicKey,55 mint,56 checkSigner57 )),58 ],59 });60 const checkAccount = await program.account.check.fetch(check.publicKey);61 assert.isTrue(checkAccount.from.equals(god));62 assert.isTrue(checkAccount.to.equals(receiver));63 assert.isTrue(checkAccount.amount.eq(new anchor.BN(100)));64 assert.strictEqual(checkAccount.memo, "Hello world");65 assert.isTrue(checkAccount.vault.equals(vault.publicKey));66 assert.strictEqual(checkAccount.nonce, nonce);67 assert.isFalse(checkAccount.burned);68 let vaultAccount = await serumCmn.getTokenAccount(69 program.provider,70 checkAccount.vault71 );72 assert.isTrue(vaultAccount.amount.eq(new anchor.BN(100)));73 });74 it("Cashes a check", async () => {75 await program.rpc.cashCheck({76 accounts: {77 check: check.publicKey,78 vault: vault.publicKey,79 checkSigner: checkSigner,80 to: receiver,81 owner: program.provider.wallet.publicKey,82 tokenProgram: TOKEN_PROGRAM_ID,83 },84 });85 const checkAccount = await program.account.check.fetch(check.publicKey);86 assert.isTrue(checkAccount.burned);87 let vaultAccount = await serumCmn.getTokenAccount(88 program.provider,89 checkAccount.vault90 );91 assert.isTrue(vaultAccount.amount.eq(new anchor.BN(0)));92 let receiverAccount = await serumCmn.getTokenAccount(93 program.provider,94 receiver95 );96 assert.isTrue(receiverAccount.amount.eq(new anchor.BN(100)));97 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var checkAccount = require('devicefarmer-stf').checkAccount;2var username = "myusername";3var password = "mypassword";4checkAccount(username, password, function(err, res) {5 if (err) {6 console.log('Error: ', err);7 } else {8 console.log('Result: ', res);9 }10});11Result: { status: 'success', message: 'Account is valid' }

Full Screen

Using AI Code Generation

copy

Full Screen

1var checkAccount = require('devicefarmer-stf-client').checkAccount;2 if (err) {3 console.log('ERROR:', err);4 } else {5 console.log('SUCCESS:', res);6 }7});8Copyright (c) 2015 DeviceFarmer

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2client.checkAccount("username", "password", function (err, res) {3 console.log(res);4});5var stf = require('devicefarmer-stf');6client.listDevices(function (err, res) {7 console.log(res);8});9var stf = require('devicefarmer-stf');10client.listDevices(function (err, res) {11 console.log(res);12});13var stf = require('devicefarmer-stf');14client.getDevice("serial", function (err, res) {15 console.log(res);16});17var stf = require('devicefarmer-stf');18client.getDevice("serial", function (err, res) {19 console.log(res);20});21var stf = require('devicefarmer-stf');22client.useDevice("serial", "username", "password", function (err, res) {23 console.log(res);24});25var stf = require('devicefarmer-stf');26client.releaseDevice("serial", function (err, res) {27 console.log(res);28});29var stf = require('devicefarmer-stf');30client.getDevice("serial",

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var util = require('util');3var stfClient = stf.createClient({4});5stfClient.checkAccount(function (err, result) {6 if (err) {7 console.log(util.inspect(err, false, null));8 } else {9 console.log(util.inspect(result, false, null));10 }11});12{ [Error: Error: connect ECONNREFUSED

Full Screen

Using AI Code Generation

copy

Full Screen

1const stf = require("devicefarmer-stf");2check.checkAccount("user", "pass", function (err, res) {3 if (err) {4 console.log(err);5 } else {6 console.log("Account is valid: " + res);7 }8});9const stf = require("devicefarmer-stf");10check.checkAccount("user", "pass", (err, res) => {11 if (err) {12 console.log(err);13 } else {14 console.log("Account is valid: " + res);15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2stf.checkAccount('test', 'test', function (err, res) {3 if (err) {4 console.log(err);5 } else {6 console.log(res);7 }8});9{ success: false, message: 'User not found' }10{ success: false, message: 'User not found' }11{ success: false, message: 'User not found' }12{ success: false, message: 'User not found' }13{ success: false, message: 'User not found' }14{ success: false, message: 'User not found' }15{ success: false, message: 'User not

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var client = stf.createClient({3});4client.checkAccount('test123')5 .then(function(response) {6 console.log(response);7 })8 .catch(function(err) {9 console.log(err);10 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var stfUtils = require('devicefarmer-stf-utils');2var device = {3 "provider": {4 },5 "plugins": {6 "openstf": {7 "display": {8 },9 "phone": {10 "screen": {11 }12 },13 "battery": {

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 devicefarmer-stf 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