Best JavaScript code snippet using fast-check-monorepo
Header.spec.ts
Source:Header.spec.ts
1import 'mocha';2import { expect } from 'chai';3import Long from 'long';4import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite';5import { CroSDK } from '../../../../core/cro';6import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl';7import { tendermintV2 } from '../../../../cosmos/v1beta1/codec';8import { Bytes } from '../../../../utils/bytes/bytes';9const cro = CroSDK({10 network: {11 defaultNodeUrl: '',12 chainId: 'testnet-croeseid-1',13 addressPrefix: 'tcro',14 validatorAddressPrefix: 'tcrocncl',15 validatorPubKeyPrefix: 'tcrocnclconspub',16 coin: {17 baseDenom: 'basetcro',18 croDenom: 'tcro',19 },20 bip44Path: {21 coinType: 1,22 account: 0,23 },24 rpcUrl: '',25 },26});27describe('Testing IBC.lightclient.Header', function () {28 fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) {29 const anyValidOptions = {30 signedHeader: {31 header: {32 version: {33 block: Long.fromString('11'),34 app: Long.fromString('0'),35 },36 chainId: 'cosmoshub-4',37 height: Long.fromString('5624169'),38 time: {39 nanos: 1000,40 seconds: Long.fromString('10000'),41 },42 lastBlockId: {43 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),44 partSetHeader: {45 total: 1,46 hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(),47 },48 },49 lastCommitHash: Bytes.fromBase64String(50 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',51 ).toUint8Array(),52 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),53 validatorsHash: Bytes.fromBase64String(54 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',55 ).toUint8Array(),56 nextValidatorsHash: Bytes.fromBase64String(57 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',58 ).toUint8Array(),59 consensusHash: Bytes.fromBase64String(60 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',61 ).toUint8Array(),62 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),63 lastResultsHash: Bytes.fromBase64String(64 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',65 ).toUint8Array(),66 evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),67 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),68 },69 commit: {70 height: Long.fromString('5624169'),71 round: 0,72 blockId: {73 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),74 partSetHeader: {75 total: 1,76 hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(),77 },78 },79 signatures: [80 {81 blockIdFlag: null,82 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),83 timestamp: {84 nanos: 10000,85 seconds: Long.fromString('10000'),86 },87 signature: Bytes.fromBase64String(88 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',89 ).toUint8Array(),90 },91 ],92 },93 },94 validatorSet: {95 validators: [96 {97 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),98 pubKey: {99 ed25519: Bytes.fromBase64String(100 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',101 ).toUint8Array(),102 },103 votingPower: Long.fromString('13595989'),104 proposerPriority: Long.fromString('-178446727'),105 },106 ],107 proposer: {108 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),109 pubKey: {110 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),111 },112 votingPower: Long.fromString('13595989'),113 proposerPriority: Long.fromString('-178446727'),114 },115 totalVotingPower: Long.fromString('192042716'),116 },117 trustedHeight: {118 revisionNumber: Long.fromString('4'),119 revisionHeight: Long.fromString('5624044'),120 },121 trustedValidators: {122 validators: [123 {124 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),125 pubKey: {126 ed25519: Bytes.fromBase64String(127 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',128 ).toUint8Array(),129 },130 votingPower: Long.fromString('13595989'),131 proposerPriority: Long.fromString('-178446727'),132 },133 ],134 proposer: {135 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),136 pubKey: {137 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),138 },139 votingPower: Long.fromString('13595989'),140 proposerPriority: Long.fromString('-178446727'),141 },142 totalVotingPower: Long.fromString('192042716'),143 },144 };145 const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions));146 testRunner(function (options) {147 if (options.valid) {148 return;149 }150 expect(() => new cro.ibc.lightclient.Header(options.value)).to.throw(151 'Expected `options` to be of type `object`',152 );153 });154 });155 it('Test Header conversion', function () {156 const Header = new cro.ibc.lightclient.Header({157 signedHeader: {158 header: {159 version: {160 block: Long.fromString('11'),161 app: Long.fromString('0'),162 },163 chainId: 'cosmoshub-4',164 height: Long.fromString('5624169'),165 time: {166 nanos: 1000,167 seconds: Long.fromString('10000'),168 },169 lastBlockId: {170 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),171 partSetHeader: {172 total: 1,173 hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(),174 },175 },176 lastCommitHash: Bytes.fromBase64String(177 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',178 ).toUint8Array(),179 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),180 validatorsHash: Bytes.fromBase64String(181 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',182 ).toUint8Array(),183 nextValidatorsHash: Bytes.fromBase64String(184 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',185 ).toUint8Array(),186 consensusHash: Bytes.fromBase64String(187 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',188 ).toUint8Array(),189 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),190 lastResultsHash: Bytes.fromBase64String(191 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',192 ).toUint8Array(),193 evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),194 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),195 },196 commit: {197 height: Long.fromString('5624169'),198 round: 0,199 blockId: {200 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),201 partSetHeader: {202 total: 1,203 hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(),204 },205 },206 signatures: [207 {208 blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT,209 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),210 timestamp: {211 nanos: 10000,212 seconds: Long.fromString('10000'),213 },214 signature: Bytes.fromBase64String(215 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',216 ).toUint8Array(),217 },218 ],219 },220 },221 validatorSet: {222 validators: [223 {224 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),225 pubKey: {226 ed25519: Bytes.fromBase64String(227 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',228 ).toUint8Array(),229 },230 votingPower: Long.fromString('13595989'),231 proposerPriority: Long.fromString('-178446727'),232 },233 ],234 proposer: {235 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),236 pubKey: {237 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),238 },239 votingPower: Long.fromString('13595989'),240 proposerPriority: Long.fromString('-178446727'),241 },242 totalVotingPower: Long.fromString('192042716'),243 },244 trustedHeight: {245 revisionNumber: Long.fromString('4'),246 revisionHeight: Long.fromString('5624044'),247 },248 trustedValidators: {249 validators: [250 {251 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),252 pubKey: {253 ed25519: Bytes.fromBase64String(254 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',255 ).toUint8Array(),256 },257 votingPower: Long.fromString('13595989'),258 proposerPriority: Long.fromString('-178446727'),259 },260 ],261 proposer: {262 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),263 pubKey: {264 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),265 },266 votingPower: Long.fromString('13595989'),267 proposerPriority: Long.fromString('-178446727'),268 },269 totalVotingPower: Long.fromString('192042716'),270 },271 });272 const rawMsg = {273 typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.Header,274 value: {275 signedHeader: {276 header: {277 version: {278 block: Long.fromString('11'),279 app: Long.fromString('0'),280 },281 chainId: 'cosmoshub-4',282 height: Long.fromString('5624169'),283 time: {284 nanos: 1000,285 seconds: Long.fromString('10000'),286 },287 lastBlockId: {288 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),289 partSetHeader: {290 total: 1,291 hash: Bytes.fromBase64String(292 'EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=',293 ).toUint8Array(),294 },295 },296 lastCommitHash: Bytes.fromBase64String(297 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',298 ).toUint8Array(),299 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),300 validatorsHash: Bytes.fromBase64String(301 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',302 ).toUint8Array(),303 nextValidatorsHash: Bytes.fromBase64String(304 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',305 ).toUint8Array(),306 consensusHash: Bytes.fromBase64String(307 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',308 ).toUint8Array(),309 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),310 lastResultsHash: Bytes.fromBase64String(311 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',312 ).toUint8Array(),313 evidenceHash: Bytes.fromBase64String(314 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',315 ).toUint8Array(),316 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),317 },318 commit: {319 height: Long.fromString('5624169'),320 round: 0,321 blockId: {322 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),323 partSetHeader: {324 total: 1,325 hash: Bytes.fromBase64String(326 'SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=',327 ).toUint8Array(),328 },329 },330 signatures: [331 {332 blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT,333 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),334 timestamp: {335 nanos: 10000,336 seconds: Long.fromString('10000'),337 },338 signature: Bytes.fromBase64String(339 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',340 ).toUint8Array(),341 },342 ],343 },344 },345 validatorSet: {346 validators: [347 {348 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),349 pubKey: {350 ed25519: Bytes.fromBase64String(351 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',352 ).toUint8Array(),353 },354 votingPower: Long.fromString('13595989'),355 proposerPriority: Long.fromString('-178446727'),356 },357 ],358 proposer: {359 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),360 pubKey: {361 ed25519: Bytes.fromBase64String(362 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',363 ).toUint8Array(),364 },365 votingPower: Long.fromString('13595989'),366 proposerPriority: Long.fromString('-178446727'),367 },368 totalVotingPower: Long.fromString('192042716'),369 },370 trustedHeight: {371 revisionNumber: Long.fromString('4'),372 revisionHeight: Long.fromString('5624044'),373 },374 trustedValidators: {375 validators: [376 {377 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),378 pubKey: {379 ed25519: Bytes.fromBase64String(380 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',381 ).toUint8Array(),382 },383 votingPower: Long.fromString('13595989'),384 proposerPriority: Long.fromString('-178446727'),385 },386 ],387 proposer: {388 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),389 pubKey: {390 ed25519: Bytes.fromBase64String(391 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',392 ).toUint8Array(),393 },394 votingPower: Long.fromString('13595989'),395 proposerPriority: Long.fromString('-178446727'),396 },397 totalVotingPower: Long.fromString('192042716'),398 },399 },400 };401 expect(Header.toRawMsg()).to.eqls(rawMsg);402 });403 it('Test Header `getEncoded`', function () {404 const params = {405 signedHeader: {406 header: {407 version: {408 block: Long.fromString('11'),409 app: Long.fromString('0'),410 },411 chainId: 'cosmoshub-4',412 height: Long.fromString('5624169'),413 time: {414 nanos: 1000,415 seconds: Long.fromString('10000'),416 },417 lastBlockId: {418 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),419 partSetHeader: {420 total: 1,421 hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(),422 },423 },424 lastCommitHash: Bytes.fromBase64String(425 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',426 ).toUint8Array(),427 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),428 validatorsHash: Bytes.fromBase64String(429 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',430 ).toUint8Array(),431 nextValidatorsHash: Bytes.fromBase64String(432 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',433 ).toUint8Array(),434 consensusHash: Bytes.fromBase64String(435 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',436 ).toUint8Array(),437 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),438 lastResultsHash: Bytes.fromBase64String(439 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',440 ).toUint8Array(),441 evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),442 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),443 },444 commit: {445 height: Long.fromString('5624169'),446 round: 0,447 blockId: {448 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),449 partSetHeader: {450 total: 1,451 hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(),452 },453 },454 signatures: [455 {456 blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT,457 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),458 timestamp: {459 nanos: 10000,460 seconds: Long.fromString('10000'),461 },462 signature: Bytes.fromBase64String(463 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',464 ).toUint8Array(),465 },466 ],467 },468 },469 validatorSet: {470 validators: [471 {472 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),473 pubKey: {474 ed25519: Bytes.fromBase64String(475 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',476 ).toUint8Array(),477 },478 votingPower: Long.fromString('13595989'),479 proposerPriority: Long.fromString('-178446727'),480 },481 ],482 proposer: {483 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),484 pubKey: {485 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),486 },487 votingPower: Long.fromString('13595989'),488 proposerPriority: Long.fromString('-178446727'),489 },490 totalVotingPower: Long.fromString('192042716'),491 },492 trustedHeight: {493 revisionNumber: Long.fromString('4'),494 revisionHeight: Long.fromString('5624044'),495 },496 trustedValidators: {497 validators: [498 {499 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),500 pubKey: {501 ed25519: Bytes.fromBase64String(502 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',503 ).toUint8Array(),504 },505 votingPower: Long.fromString('13595989'),506 proposerPriority: Long.fromString('-178446727'),507 },508 ],509 proposer: {510 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),511 pubKey: {512 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),513 },514 votingPower: Long.fromString('13595989'),515 proposerPriority: Long.fromString('-178446727'),516 },517 totalVotingPower: Long.fromString('192042716'),518 },519 };520 const Header = new cro.ibc.lightclient.Header(params);521 expect(Header.getEncoded().value).instanceOf(Uint8Array);522 expect(Header.getEncoded().type_url).to.equal('/ibc.lightclients.tendermint.v1.Header');523 });524 it('should throw on invalid values', function () {525 const params = {526 signedHeader: {527 header: {528 version: {529 block: Long.fromString('11'),530 app: Long.fromString('0'),531 },532 chainId: 'cosmoshub-4',533 height: Long.fromString('5624169'),534 time: {535 nanos: 1000,536 seconds: Long.fromString('10000'),537 },538 lastBlockId: {539 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),540 partSetHeader: {541 total: 1,542 hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(),543 },544 },545 lastCommitHash: Bytes.fromBase64String(546 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',547 ).toUint8Array(),548 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),549 validatorsHash: Bytes.fromBase64String(550 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',551 ).toUint8Array(),552 nextValidatorsHash: Bytes.fromBase64String(553 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',554 ).toUint8Array(),555 consensusHash: Bytes.fromBase64String(556 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',557 ).toUint8Array(),558 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),559 lastResultsHash: Bytes.fromBase64String(560 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',561 ).toUint8Array(),562 evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),563 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),564 },565 commit: {566 height: Long.fromString('5624169'),567 round: 0,568 blockId: {569 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),570 partSetHeader: {571 total: 1,572 hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(),573 },574 },575 signatures: [576 {577 blockIdFlag: 4,578 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),579 timestamp: {580 nanos: 10000,581 seconds: Long.fromString('10000'),582 },583 signature: Bytes.fromBase64String(584 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',585 ).toUint8Array(),586 },587 ],588 },589 },590 validatorSet: {591 validators: [592 {593 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),594 pubKey: {595 ed25519: Bytes.fromBase64String(596 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',597 ).toUint8Array(),598 },599 votingPower: Long.fromString('13595989'),600 proposerPriority: Long.fromString('-178446727'),601 },602 ],603 proposer: {604 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),605 pubKey: {606 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),607 },608 votingPower: Long.fromString('13595989'),609 proposerPriority: Long.fromString('-178446727'),610 },611 totalVotingPower: Long.fromString('192042716'),612 },613 trustedHeight: {614 revisionNumber: Long.fromString('4'),615 revisionHeight: Long.fromString('5624044'),616 },617 trustedValidators: {618 validators: [619 {620 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),621 pubKey: {622 ed25519: Bytes.fromBase64String(623 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',624 ).toUint8Array(),625 },626 votingPower: Long.fromString('13595989'),627 proposerPriority: Long.fromString('-178446727'),628 },629 ],630 proposer: {631 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),632 pubKey: {633 ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(),634 },635 votingPower: Long.fromString('13595989'),636 proposerPriority: Long.fromString('-178446727'),637 },638 totalVotingPower: Long.fromString('192042716'),639 },640 };641 expect(() => new cro.ibc.lightclient.Header(params)).to.throw(642 "(array `signatures`) Expected property property property property number `blockIdFlag` to be one of enum 'tendermintV2.types.BlockIDFlag', got `4` in object `t` in object `commit` in object `signedHeader` in object `options`",643 );644 });645 context('should throw on unsupported functionalities', function () {646 it('should throw on calling .toRawAminoMsg', function () {647 const params = {648 signedHeader: {649 header: {650 version: {651 block: Long.fromString('11'),652 app: Long.fromString('0'),653 },654 chainId: 'cosmoshub-4',655 height: Long.fromString('5624169'),656 time: {657 nanos: 1000,658 seconds: Long.fromString('10000'),659 },660 lastBlockId: {661 hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(),662 partSetHeader: {663 total: 1,664 hash: Bytes.fromBase64String(665 'EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=',666 ).toUint8Array(),667 },668 },669 lastCommitHash: Bytes.fromBase64String(670 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=',671 ).toUint8Array(),672 dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(),673 validatorsHash: Bytes.fromBase64String(674 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',675 ).toUint8Array(),676 nextValidatorsHash: Bytes.fromBase64String(677 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=',678 ).toUint8Array(),679 consensusHash: Bytes.fromBase64String(680 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=',681 ).toUint8Array(),682 appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(),683 lastResultsHash: Bytes.fromBase64String(684 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',685 ).toUint8Array(),686 evidenceHash: Bytes.fromBase64String(687 '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',688 ).toUint8Array(),689 proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(),690 },691 commit: {692 height: Long.fromString('5624169'),693 round: 0,694 blockId: {695 hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(),696 partSetHeader: {697 total: 1,698 hash: Bytes.fromBase64String(699 'SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=',700 ).toUint8Array(),701 },702 },703 signatures: [704 {705 blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT,706 validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),707 timestamp: {708 nanos: 10000,709 seconds: Long.fromString('10000'),710 },711 signature: Bytes.fromBase64String(712 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==',713 ).toUint8Array(),714 },715 ],716 },717 },718 validatorSet: {719 validators: [720 {721 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),722 pubKey: {723 ed25519: Bytes.fromBase64String(724 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',725 ).toUint8Array(),726 },727 votingPower: Long.fromString('13595989'),728 proposerPriority: Long.fromString('-178446727'),729 },730 ],731 proposer: {732 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),733 pubKey: {734 ed25519: Bytes.fromBase64String(735 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',736 ).toUint8Array(),737 },738 votingPower: Long.fromString('13595989'),739 proposerPriority: Long.fromString('-178446727'),740 },741 totalVotingPower: Long.fromString('192042716'),742 },743 trustedHeight: {744 revisionNumber: Long.fromString('4'),745 revisionHeight: Long.fromString('5624044'),746 },747 trustedValidators: {748 validators: [749 {750 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),751 pubKey: {752 ed25519: Bytes.fromBase64String(753 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',754 ).toUint8Array(),755 },756 votingPower: Long.fromString('13595989'),757 proposerPriority: Long.fromString('-178446727'),758 },759 ],760 proposer: {761 address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(),762 pubKey: {763 ed25519: Bytes.fromBase64String(764 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=',765 ).toUint8Array(),766 },767 votingPower: Long.fromString('13595989'),768 proposerPriority: Long.fromString('-178446727'),769 },770 totalVotingPower: Long.fromString('192042716'),771 },772 };773 expect(() => new cro.ibc.lightclient.Header(params).toRawAminoMsg()).to.throw(774 'IBC Module not supported under amino encoding scheme',775 );776 });777 it('should throw on calling .fromCosmosMsgJSON', function () {778 expect(() => cro.ibc.lightclient.Header.fromCosmosMsgJSON('json')).to.throw(779 'IBC Module does not support JSON decoding.',780 );781 });782 });...
data-util.service.js
Source:data-util.service.js
1'use strict';2angular.module('latticegamesApp')3 .service('DataUtils', function ($filter) {4 this.byteSize = function (base64String) {5 if (!angular.isString(base64String)) {6 return '';7 }8 function endsWith(suffix, str) {9 return str.indexOf(suffix, str.length - suffix.length) !== -1;10 }11 function paddingSize(base64String) {12 if (endsWith('==', base64String)) {13 return 2;14 }15 if (endsWith('=', base64String)) {16 return 1;17 }18 return 0;19 }20 function size(base64String) {21 return base64String.length / 4 * 3 - paddingSize(base64String);22 }23 function formatAsBytes(size) {24 return size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ") + " bytes";25 }26 return formatAsBytes(size(base64String));27 };28 this.abbreviate = function (text) {29 if (!angular.isString(text)) {30 return '';31 }32 if (text.length < 30) {33 return text;34 }35 return text ? (text.substring(0, 15) + '...' + text.slice(-10)) : '';36 };...
url.js
Source:url.js
1// The token is encoded URL safe by replacing '+' with '-', '\' with '_' and removing '='2// NOTE: the token is not encoded using valid base64 anymore3module.exports.encodeBase64 = function encodeBase64(base64String) {4 return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');5};6// Decode url safe base64 encoding and add padding ('=')7module.exports.decodeBase64 = function decodeBase64(base64String) {8 base64String = base64String.replace(/-/g, '+').replace(/_/g, '/');9 while (base64String.length % 4) {10 base64String += '=';11 }12 return base64String;...
Using AI Code Generation
1const { base64String } = require('fast-check');2const { base64String } = require('fast-check');3const { base64String } = require('fast-check');4const { base64String } = require('fast-check');5const { base64String } = require('fast-check');6const { base64String } = require('fast-check');7const { base64String } = require('fast-check');8const { base64String } = require('fast-check');9const { base64String } = require('fast-check');10const { base64String } = require('fast-check');11const { base64String } = require('fast-check');12const { base64String } = require('fast-check');13const { base64String } = require('fast-check');14const { base64String } = require('fast-check');15const { base64String } = require('fast-check');16const { base64String } = require('fast-check');17const { base64String } = require('fast-check');18const { base64String } = require('fast-check');19const { base64String } = require('fast-check');
Using AI Code Generation
1const fc = require('fast-check');2const base64String = require('fast-check-monorepo').base64String;3fc.assert(4 fc.property(base64String(), (s) => s.length > 0)5);6const fc = require('fast-check');7const base64String = require('fast-check-monorepo').base64String;8fc.assert(9 fc.property(base64String(), (s) => s.length > 0)10);11const fc = require('fast-check');12const base64String = require('fast-check-monorepo').base64String;13fc.assert(14 fc.property(base64String(), (s) => s.length > 0)15);16const fc = require('fast-check');17const base64String = require('fast-check-monorepo').base64String;18fc.assert(19 fc.property(base64String(), (s) => s.length > 0)20);21const fc = require('fast-check');22const base64String = require('fast-check-monorepo').base64String;23fc.assert(24 fc.property(base64String(), (s) => s.length > 0)25);26const fc = require('fast-check');27const base64String = require('fast-check-monorepo').base64String;28fc.assert(29 fc.property(base64String(), (s) => s.length > 0)30);31const fc = require('fast-check');32const base64String = require('fast-check-monorepo').base64String;33fc.assert(34 fc.property(base64String(), (s) => s.length > 0)35);36const fc = require('fast-check');37const base64String = require('fast-check-monorepo').base
Using AI Code Generation
1const fc = require('fast-check');2const { base64String } = require('fast-check');3const arbs = fc.array(base64String());4fc.assert(5 fc.property(arbs, (a) => {6 return a.every((s) => typeof s === 'string');7 })8);9const fc = require('fast-check');10const { base64String } = require('fast-check');11const arbs = fc.array(base64String());12fc.assert(13 fc.property(arbs, (a) => {14 return a.every((s) => typeof s === 'string');15 })16);
Using AI Code Generation
1var fastCheck = require("fast-check");2var base64String = fastCheck.base64String;3var fc = fastCheck.default;4var fc = fastCheck.fc;5var base64String = fastCheck.base64String;6var base64String = fc.base64String;7var fastCheck = require("fast-check");8var base64String = fastCheck.base64String;9var fc = fastCheck.default;10var fc = fastCheck.fc;11var base64String = fastCheck.base64String;12var base64String = fc.base64String;13var fastCheck = require("fast-check");14var base64String = fastCheck.base64String;15var fc = fastCheck.default;16var fc = fastCheck.fc;17var base64String = fastCheck.base64String;18var base64String = fc.base64String;19var fastCheck = require("fast-check");20var base64String = fastCheck.base64String;21var fc = fastCheck.default;22var fc = fastCheck.fc;23var base64String = fastCheck.base64String;24var base64String = fc.base64String;25var fastCheck = require("fast-check");26var base64String = fastCheck.base64String;27var fc = fastCheck.default;28var fc = fastCheck.fc;29var base64String = fastCheck.base64String;30var base64String = fc.base64String;31var fastCheck = require("fast-check");32var base64String = fastCheck.base64String;33var fc = fastCheck.default;34var fc = fastCheck.fc;35var base64String = fastCheck.base64String;36var base64String = fc.base64String;37var fastCheck = require("fast-check");38var base64String = fastCheck.base64String;39var fc = fastCheck.default;40var fc = fastCheck.fc;
Using AI Code Generation
1const { base64String } = require('fast-check');2const base64String = base64String();3console.log(base64String);4base64String { _isStrict: false, _maxArbitrarySize: 1000 }5base64String { _isStrict: false, _maxArbitrarySize: 1000 }6base64String { _isStrict: false, _maxArbitrarySize: 1000 }7base64String { _isStrict: false, _maxArbitrarySize: 1000 }8base64String { _isStrict: false, _maxArbitrarySize: 1000 }9base64String { _isStrict: false, _maxArbitrarySize: 1000 }10base64String { _isStrict: false, _maxArbitrarySize: 1000 }11base64String { _isStrict: false, _maxArbitrarySize: 1000 }12base64String { _isStrict: false, _maxArbitrarySize: 1000 }13base64String { _isStrict: false, _maxArbitrarySize: 1000 }14base64String { _isStrict: false, _maxArbitrarySize: 1000 }15base64String { _isStrict: false, _maxArbitrarySize: 1000 }16base64String { _isStrict: false, _maxArbitrarySize: 1000 }
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!