| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,9 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | 18 | require = require('esm')(module /*, options */) // use to handle es6 import/export | |
| 19 | 19 | ||
| 20 | + const { TransactionValidator, Node } = require('@aeternity/aepp-sdk'); | ||
| 20 | 21 | const utils = require('aeproject-utils'); | |
| 21 | 22 | ||
| 22 | - const TxValidator = utils.txValidator; | ||
| 23 | 23 | const httpGet = utils.httpGet; | |
| 24 | 24 | ||
| 25 | 25 | const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; | |
@@ -36,13 +36,12 @@ async function run (option) { | |||
| 36 | 36 | ||
| 37 | 37 | const network = utils.getNetwork(option.network ? option.network : 'local', option.networkId); | |
| 38 | 38 | ||
| 39 | - const validator = await TxValidator({ | ||
| 40 | - url: network.url, | ||
| 41 | - internalUrl: network.url + '/internal', | ||
| 39 | + const validator = await TransactionValidator({ | ||
| 40 | + nodes: [{ name: 'temp', instance: await Node({ url: network.url }) }], | ||
| 42 | 41 | forceCompatibility: true | |
| 43 | 42 | }); | |
| 44 | 43 | ||
| 45 | - let result = await validator.unpackAndVerify(option.tx, network.networkId); | ||
| 44 | + let result = await validator.unpackAndVerify(option.tx, { networkId: network.networkId }); | ||
| 46 | 45 | ||
| 47 | 46 | let publicKey = getPublicKeyFromTx(result.txType, result.tx); | |
| 48 | 47 | ||
@@ -163,4 +162,4 @@ function printValidationResult (data) { | |||
| 163 | 162 | ||
| 164 | 163 | module.exports = { | |
| 165 | 164 | run | |
| 166 | - } | ||
| 165 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ const timeout = aeprojectUtils.timeout; | |||
| 30 | 30 | const contractCompile = aeprojectUtils.contractCompile; | |
| 31 | 31 | const checkNestedProperty = aeprojectUtils.checkNestedProperty; | |
| 32 | 32 | const winExec = aeprojectUtils.winExec; | |
| 33 | - const txValidator = aeprojectUtils.TransactionValidator; | ||
| 34 | 33 | const readSpawnOutput = aeprojectUtils.readSpawnOutput; | |
| 35 | 34 | const readErrorSpawnOutput = aeprojectUtils.readErrorSpawnOutput; | |
| 36 | 35 | const capitalize = aeprojectUtils.capitalize; | |
@@ -83,11 +82,10 @@ module.exports = { | |||
| 83 | 82 | createDirIfNotExists, | |
| 84 | 83 | writeFileSync, | |
| 85 | 84 | winExec, | |
| 86 | - txValidator, | ||
| 87 | 85 | httpGet, | |
| 88 | 86 | readSpawnOutput, | |
| 89 | 87 | readErrorSpawnOutput, | |
| 90 | 88 | capitalize, | |
| 91 | 89 | addCaretToDependencyVersion, | |
| 92 | 90 | prompt | |
| 93 | - } | ||
| 91 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ const prompts = require('prompts'); | |||
| 6 | 6 | const AeSDK = require('@aeternity/aepp-sdk'); | |
| 7 | 7 | const Universal = AeSDK.Universal; | |
| 8 | 8 | const Node = AeSDK.Node; | |
| 9 | - const TransactionValidator = AeSDK.TransactionValidator; | ||
| 10 | 9 | ||
| 11 | 10 | let rgx = /^include\s+\"([\d\w\/\.\-\_]+)\"/gmi; | |
| 12 | 11 | let dependencyPathRgx = /"([\d\w\/\.\-\_]+)\"/gmi; | |
@@ -366,10 +365,9 @@ module.exports = { | |||
| 366 | 365 | contractCompile, | |
| 367 | 366 | checkNestedProperty, | |
| 368 | 367 | winExec, | |
| 369 | - TransactionValidator, | ||
| 370 | 368 | readSpawnOutput, | |
| 371 | 369 | readErrorSpawnOutput, | |
| 372 | 370 | capitalize, | |
| 373 | 371 | addCaretToDependencyVersion, | |
| 374 | 372 | prompt | |
| 375 | - } | ||
| 373 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ const chai = require('chai'); | |||
| 2 | 2 | const chaiFiles = require('chai-files'); | |
| 3 | 3 | const assert = chai.assert; | |
| 4 | 4 | chai.use(chaiFiles); | |
| 5 | + chai.use(require('chai-as-promised')); | ||
| 5 | 6 | ||
| 6 | 7 | const fs = require('fs-extra'); | |
| 7 | 8 | const execute = require('../../packages/aeproject-utils/utils/aeproject-utils.js').aeprojectExecute; | |
@@ -57,13 +58,7 @@ describe('Transaction inspector tests', async function () { | |||
| 57 | 58 | txType: 'spendTx'` | |
| 58 | 59 | ||
| 59 | 60 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()); | |
| 60 | - | ||
| 61 | - | ||
| 62 | - expectedResArr.map(x => { | ||
| 63 | - if (!result.includes(x)) { | ||
| 64 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 65 | - } | ||
| 66 | - }); | ||
| 61 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 67 | 62 | }) | |
| 68 | 63 | ||
| 69 | 64 | it('Should inspect valid contract create tx in local network', async function () { | |
@@ -94,16 +89,9 @@ describe('Transaction inspector tests', async function () { | |||
| 94 | 89 | 'sg_FAQ2PoJsqHpv9ZDPiT4yozTNkuQ3YMAiK2e4c1yMuBi3DDsnKFLeBmrAzndeY6iGHesKwLHWaZ3AL54859mYg58RLorZ' | |
| 95 | 90 | txType: 'contractCreateTx'` | |
| 96 | 91 | ||
| 97 | - let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim().toLowerCase()) | ||
| 98 | - | ||
| 99 | - result = result.toLowerCase() | ||
| 100 | - | ||
| 101 | - expectedResArr.map(x => { | ||
| 102 | - | ||
| 103 | - if (!result.includes(x)) { | ||
| 104 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 105 | - } | ||
| 106 | - }); | ||
| 92 | + let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim().toLowerCase()); | ||
| 93 | + result = result.toLowerCase(); | ||
| 94 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 107 | 95 | }) | |
| 108 | 96 | ||
| 109 | 97 | it('Should inspect invalid contract create tx in local network', async function () { | |
@@ -113,7 +101,6 @@ describe('Transaction inspector tests', async function () { | |||
| 113 | 101 | ||
| 114 | 102 | let expectedResultAsText = `'Nonce' - Account not found | |
| 115 | 103 | 'fee' - The account balance 0 is not enough to execute the transaction | |
| 116 | - 'amount' - The account balance 0 is not enough to execute the transaction | ||
| 117 | 104 | tx: | |
| 118 | 105 | tag: '42' | |
| 119 | 106 | VSN: '1' | |
@@ -137,11 +124,7 @@ describe('Transaction inspector tests', async function () { | |||
| 137 | 124 | txType: 'contractCreateTx'` | |
| 138 | 125 | ||
| 139 | 126 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()); | |
| 140 | - expectedResArr.map(x => { | ||
| 141 | - if (!result.includes(x)) { | ||
| 142 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 143 | - } | ||
| 144 | - }); | ||
| 127 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 145 | 128 | }) | |
| 146 | 129 | ||
| 147 | 130 | it('Should inspect contract call tx in local network', async function () { | |
@@ -172,11 +155,7 @@ describe('Transaction inspector tests', async function () { | |||
| 172 | 155 | txType: 'contractCallTx'` | |
| 173 | 156 | ||
| 174 | 157 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 175 | - expectedResArr.map(x => { | ||
| 176 | - if (!result.includes(x)) { | ||
| 177 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 178 | - } | ||
| 179 | - }); | ||
| 158 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 180 | 159 | }) | |
| 181 | 160 | }) | |
| 182 | 161 | ||
@@ -214,11 +193,7 @@ describe('Transaction inspector tests', async function () { | |||
| 214 | 193 | txType: 'spendTx'` | |
| 215 | 194 | ||
| 216 | 195 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 217 | - expectedResArr.map(x => { | ||
| 218 | - if (!result.includes(x)) { | ||
| 219 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 220 | - } | ||
| 221 | - }); | ||
| 196 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 222 | 197 | }) | |
| 223 | 198 | ||
| 224 | 199 | it('Should inspect valid contract create tx in testnet network', async function () { | |
@@ -255,11 +230,7 @@ describe('Transaction inspector tests', async function () { | |||
| 255 | 230 | txType: 'contractCreateTx'` | |
| 256 | 231 | ||
| 257 | 232 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 258 | - expectedResArr.map(x => { | ||
| 259 | - if (!result.includes(x)) { | ||
| 260 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 261 | - } | ||
| 262 | - }); | ||
| 233 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 263 | 234 | }) | |
| 264 | 235 | ||
| 265 | 236 | it('Should inspect invalid contract create tx in testnet network', async function () { | |
@@ -272,7 +243,6 @@ describe('Transaction inspector tests', async function () { | |||
| 272 | 243 | let expectedResultAsText = `'Nonce' - Account not found | |
| 273 | 244 | 'ttl' - The TTL is already expired | |
| 274 | 245 | 'fee' - The account balance 0 is not enough to execute the transaction | |
| 275 | - 'amount' - The account balance 0 is not enough to execute the transaction | ||
| 276 | 246 | 'signature' - The signature cannot be verified, please verify that you used the correct network id and the correct private key for the sender address | |
| 277 | 247 | tx: | |
| 278 | 248 | tag: '42' | |
@@ -296,12 +266,8 @@ describe('Transaction inspector tests', async function () { | |||
| 296 | 266 | 'sg_L2o8HWfghDvanAe6wbyvMj7ttCe361fEyDTpqJXPw198z2twfM2Y97bRxFCBvhn75f2qPrnFBVr7pNxYbMYNtrCDwiQVu' | |
| 297 | 267 | txType: 'contractCreateTx'` | |
| 298 | 268 | ||
| 299 | - let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | ||
| 300 | - expectedResArr.map(x => { | ||
| 301 | - if (!result.includes(x)) { | ||
| 302 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 303 | - } | ||
| 304 | - }); | ||
| 269 | + let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()); | ||
| 270 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 305 | 271 | }) | |
| 306 | 272 | ||
| 307 | 273 | it('Should inspect contract call tx in testnet network', async function () { | |
@@ -336,11 +302,7 @@ describe('Transaction inspector tests', async function () { | |||
| 336 | 302 | txType: 'contractCallTx' ` | |
| 337 | 303 | ||
| 338 | 304 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 339 | - expectedResArr.map(x => { | ||
| 340 | - if (!result.includes(x)) { | ||
| 341 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 342 | - } | ||
| 343 | - }); | ||
| 305 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 344 | 306 | }) | |
| 345 | 307 | ||
| 346 | 308 | }) | |
@@ -378,12 +340,8 @@ describe('Transaction inspector tests', async function () { | |||
| 378 | 340 | payload: 'ba_Xfbg4g==' | |
| 379 | 341 | txType: 'spendTx'` | |
| 380 | 342 | ||
| 381 | - let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | ||
| 382 | - expectedResArr.map(x => { | ||
| 383 | - if (!result.includes(x)) { | ||
| 384 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 385 | - } | ||
| 386 | - }); | ||
| 343 | + let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()); | ||
| 344 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 387 | 345 | }) | |
| 388 | 346 | ||
| 389 | 347 | it('Should inspect valid contract create tx in mainnet network', async function () { | |
@@ -396,7 +354,6 @@ describe('Transaction inspector tests', async function () { | |||
| 396 | 354 | let expectedResultAsText = `'Nonce' - Account not found | |
| 397 | 355 | 'ttl' - The TTL is already expired | |
| 398 | 356 | 'fee' - The account balance 0 is not enough to execute the transaction | |
| 399 | - 'amount' - The account balance 0 is not enough to execute the transaction | ||
| 400 | 357 | 'nonce' - The nonce is technically valid but will not be processed immediately by the node | |
| 401 | 358 | 'signature' - The signature cannot be verified, please verify that you used the correct network id and the correct private key for the sender address | |
| 402 | 359 | tx: | |
@@ -421,12 +378,8 @@ describe('Transaction inspector tests', async function () { | |||
| 421 | 378 | 'sg_FAQ2PoJsqHpv9ZDPiT4yozTNkuQ3YMAiK2e4c1yMuBi3DDsnKFLeBmrAzndeY6iGHesKwLHWaZ3AL54859mYg58RLorZ' | |
| 422 | 379 | txType: 'contractCreateTx'` | |
| 423 | 380 | ||
| 424 | - let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | ||
| 425 | - expectedResArr.map(x => { | ||
| 426 | - if (!result.includes(x)) { | ||
| 427 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 428 | - } | ||
| 429 | - }); | ||
| 381 | + let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()); | ||
| 382 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 430 | 383 | }) | |
| 431 | 384 | ||
| 432 | 385 | it('Should inspect invalid contract create tx in testnet network', async function () { | |
@@ -439,7 +392,6 @@ describe('Transaction inspector tests', async function () { | |||
| 439 | 392 | let expectedResultAsText = `'Nonce' - Account not found | |
| 440 | 393 | 'ttl' - The TTL is already expired, | |
| 441 | 394 | 'fee' - The account balance 0 is not enough to execute the transaction | |
| 442 | - 'amount' - The account balance 0 is not enough to execute the transaction | ||
| 443 | 395 | 'signature' - The signature cannot be verified, please verify that you used the correct network id and the correct private key for the sender address | |
| 444 | 396 | tx: | |
| 445 | 397 | tag: '42' | |
@@ -464,11 +416,7 @@ describe('Transaction inspector tests', async function () { | |||
| 464 | 416 | txType: 'contractCreateTx'` | |
| 465 | 417 | ||
| 466 | 418 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 467 | - expectedResArr.map(x => { | ||
| 468 | - if (!result.includes(x)) { | ||
| 469 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 470 | - } | ||
| 471 | - }); | ||
| 419 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 472 | 420 | }) | |
| 473 | 421 | ||
| 474 | 422 | it('Should inspect contract call tx in testnet network', async function () { | |
@@ -480,7 +428,6 @@ describe('Transaction inspector tests', async function () { | |||
| 480 | 428 | ||
| 481 | 429 | let expectedResultAsText = `'Nonce' - Account not found | |
| 482 | 430 | 'fee' - The account balance 0 is not enough to execute the transaction | |
| 483 | - 'amount' - The account balance 0 is not enough to execute the transaction | ||
| 484 | 431 | 'nonce' - The nonce is technically valid but will not be processed immediately by the node (next valid nonce is | |
| 485 | 432 | 'signature' - The signature cannot be verified, please verify that you used the correct network id and the correct private key for the sender address | |
| 486 | 433 | tx: | |
@@ -505,11 +452,7 @@ describe('Transaction inspector tests', async function () { | |||
| 505 | 452 | txType: 'contractCallTx'` | |
| 506 | 453 | ||
| 507 | 454 | let expectedResArr = expectedResultAsText.trim().split('\n').map(x => x.trim()) | |
| 508 | - expectedResArr.map(x => { | ||
| 509 | - if (!result.includes(x)) { | ||
| 510 | - assert.isOk(false, `Non expected data: ${ x }`) | ||
| 511 | - } | ||
| 512 | - }); | ||
| 455 | + expectedResArr.map(x => chai.expect(result).to.include(x)); | ||
| 513 | 456 | }) | |
| 514 | 457 | }) | |
| 515 | 458 | ||
@@ -532,4 +475,4 @@ describe('Transaction inspector tests', async function () { | |||
| 532 | 475 | ||
| 533 | 476 | fs.removeSync(`.${ testFolder }`) | |
| 534 | 477 | }) | |
| 535 | - }) | ||
| 478 | + }) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments