From 85bd680c76f28f695e1cf589469a9239d2bacc01 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Tue, 28 Jan 2025 18:50:51 +0100 Subject: [PATCH 1/3] test: don't use `should` if rarely --- test/integration/account-generalized.ts | 8 ++--- test/integration/aens.ts | 2 +- test/integration/channel-other.ts | 48 +++++++++++++------------ test/integration/contract.ts | 14 ++++---- test/integration/delegation.ts | 18 +++++----- test/integration/node.ts | 6 ++-- test/integration/oracle.ts | 13 +++---- test/integration/transaction.ts | 2 +- test/unit/bytes.ts | 8 ++--- test/unit/crypto.ts | 16 ++++----- test/unit/tx.ts | 14 ++++---- 11 files changed, 77 insertions(+), 72 deletions(-) diff --git a/test/integration/account-generalized.ts b/test/integration/account-generalized.ts index 51d53f0626..c4ae3a8b11 100644 --- a/test/integration/account-generalized.ts +++ b/test/integration/account-generalized.ts @@ -61,9 +61,9 @@ describe('Generalized Account', () => { }); it('Fail on make GA on already GA', async () => { - await aeSdk - .createGeneralizedAccount('authorize', [], { sourceCode }) - .should.be.rejectedWith(`Account ${gaAccountAddress} is already GA`); + await expect( + aeSdk.createGeneralizedAccount('authorize', [], { sourceCode }), + ).to.be.rejectedWith(`Account ${gaAccountAddress} is already GA`); }); it('fails to build GaAttachTx with non-1 nonce', () => { @@ -98,7 +98,7 @@ describe('Generalized Account', () => { await aeSdk.spend(10000, recipient, { authData: { callData } }); await aeSdk.spend(10000, recipient, { authData: { sourceCode, args: [genSalt()] } }); const balanceAfter = await aeSdk.getBalance(recipient); - balanceAfter.should.be.equal('20000'); + expect(balanceAfter).to.equal('20000'); }); it('throws error if gasLimit exceeds the maximum value', async () => { diff --git a/test/integration/aens.ts b/test/integration/aens.ts index 5d4ecb05b7..3b60d53796 100644 --- a/test/integration/aens.ts +++ b/test/integration/aens.ts @@ -210,7 +210,7 @@ describe('Aens', () => { it('fails to spend to name with invalid pointers', async () => { const { pointers } = await name.getState(); - pointers.length.should.be.equal(0); + expect(pointers).to.have.length(0); await expect(aeSdk.spend(100, name.value)).to.be.rejectedWith( AensPointerContextError, `Name ${name.value} don't have pointers for account_pubkey`, diff --git a/test/integration/channel-other.ts b/test/integration/channel-other.ts index b58c55d526..0b9884cf0f 100644 --- a/test/integration/channel-other.ts +++ b/test/integration/channel-other.ts @@ -93,16 +93,18 @@ describe('Channel other', () => { await aeSdk.sendTransaction(settleTx, { onAccount: initiator }); const [initiatorBalanceAfterClose, responderBalanceAfterClose] = await getBalances(); - new BigNumber(initiatorBalanceAfterClose) - .minus(initiatorBalanceBeforeClose) - .plus(closeSoloTxFee) - .plus(settleTxFee) - .isEqualTo(balances[initiator.address]) - .should.be.equal(true); - new BigNumber(responderBalanceAfterClose) - .minus(responderBalanceBeforeClose) - .isEqualTo(balances[responder.address]) - .should.be.equal(true); + expect( + new BigNumber(initiatorBalanceAfterClose) + .minus(initiatorBalanceBeforeClose) + .plus(closeSoloTxFee) + .plus(settleTxFee) + .isEqualTo(balances[initiator.address]), + ).to.equal(true); + expect( + new BigNumber(responderBalanceAfterClose) + .minus(responderBalanceBeforeClose) + .isEqualTo(balances[responder.address]), + ).to.equal(true); }).timeout(timeoutBlock); it('can dispute via slash tx', async () => { @@ -158,17 +160,19 @@ describe('Channel other', () => { await aeSdk.sendTransaction(settleTx, { onAccount: responder }); const [initiatorBalanceAfterClose, responderBalanceAfterClose] = await getBalances(); - new BigNumber(initiatorBalanceAfterClose) - .minus(initiatorBalanceBeforeClose) - .plus(closeSoloTxFee) - .isEqualTo(recentBalances[initiator.address]) - .should.be.equal(true); - new BigNumber(responderBalanceAfterClose) - .minus(responderBalanceBeforeClose) - .plus(slashTxFee) - .plus(settleTxFee) - .isEqualTo(recentBalances[responder.address]) - .should.be.equal(true); + expect( + new BigNumber(initiatorBalanceAfterClose) + .minus(initiatorBalanceBeforeClose) + .plus(closeSoloTxFee) + .isEqualTo(recentBalances[initiator.address]), + ).to.equal(true); + expect( + new BigNumber(responderBalanceAfterClose) + .minus(responderBalanceBeforeClose) + .plus(slashTxFee) + .plus(settleTxFee) + .isEqualTo(recentBalances[responder.address]), + ).to.equal(true); }).timeout(timeoutBlock); it('can reconnect a channel without leave', async () => { @@ -213,7 +217,7 @@ describe('Channel other', () => { 100, async (transaction) => appendSignature(await responderSign(transaction), initiatorSign), ); - result.accepted.should.equal(true); + expect(result.accepted).to.equal(true); expect(responderCh.round()).to.be.equal(2); expect(result.signedTx).to.be.a('string'); }); diff --git a/test/integration/contract.ts b/test/integration/contract.ts index 2ede912366..1cc863a42e 100644 --- a/test/integration/contract.ts +++ b/test/integration/contract.ts @@ -141,16 +141,16 @@ describe('Contract', () => { it('Call-Static deploy transaction', async () => { const { result } = await identityContract.$deploy([], { callStatic: true }); assertNotNull(result); - result.should.have.property('gasUsed'); - result.should.have.property('returnType'); + expect(result).to.have.property('gasUsed'); + expect(result).to.have.property('returnType'); }); it('Call-Static deploy transaction on specific hash', async () => { const hash = (await aeSdk.api.getTopHeader()).hash as Encoded.MicroBlockHash; const { result } = await identityContract.$deploy([], { callStatic: true, top: hash }); assertNotNull(result); - result.should.have.property('gasUsed'); - result.should.have.property('returnType'); + expect(result).to.have.property('gasUsed'); + expect(result).to.have.property('returnType'); }); it('throws error on deploy', async () => { @@ -194,7 +194,7 @@ describe('Contract', () => { }); const { result } = await contract.getArg(42); assertNotNull(result); - result.callerId.should.be.equal(DRY_RUN_ACCOUNT.pub); + expect(result.callerId).to.be.equal(DRY_RUN_ACCOUNT.pub); }); it('Dry-run at specific height', async () => { @@ -240,10 +240,10 @@ describe('Contract', () => { assertNotNull(deployInfo.transaction); await aeSdk.poll(deployInfo.transaction); expect(deployInfo.result).to.be.equal(undefined); - deployInfo.txData.should.not.be.equal(undefined); + expect(deployInfo.txData).to.not.be.equal(undefined); const result = await identityContract.getArg(42, { callStatic: false, waitMined: false }); expect(result.result).to.be.equal(undefined); - result.txData.should.not.be.equal(undefined); + expect(result.txData).to.not.be.equal(undefined); await aeSdk.poll(result.hash as Encoded.TxHash); }); diff --git a/test/integration/delegation.ts b/test/integration/delegation.ts index 30e7557e5d..db5fd1bc05 100644 --- a/test/integration/delegation.ts +++ b/test/integration/delegation.ts @@ -119,7 +119,7 @@ contract DelegateTest = decode(preclaimSig), ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); delegationSignature = await aeSdk.signDelegation( packDelegation({ tag: DelegationTag.AensName, @@ -140,7 +140,7 @@ contract DelegateTest = decode(delegationSignature), ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); }).timeout(timeoutBlock); it('updates', async () => { @@ -197,7 +197,7 @@ contract DelegateTest = decode(delegationSignature), ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); }); it('revokes', async () => { @@ -212,7 +212,7 @@ contract DelegateTest = ); const { result } = await contract.signedRevoke(newOwner, name, decode(revokeSig)); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); await expect(aeSdk.api.getNameEntryByName(name)).to.be.rejectedWith(Error); }); @@ -266,7 +266,7 @@ contract DelegateTest = ); const { result } = await contract.signedClaim(aeSdk.address, n, 0, nameFee, decode(dlgSig)); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); }); }); @@ -347,7 +347,7 @@ contract DelegateTest = ttl, ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); }); it('extends', async () => { @@ -358,7 +358,7 @@ contract DelegateTest = ttl, ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); const state = await oracle.getState(); expect(state.ttl).to.be.equal(prevState.ttl + 50); }); @@ -374,7 +374,7 @@ contract DelegateTest = amount: 5 * queryFee, }); assertNotNull(query.result); - query.result.returnType.should.be.equal('ok'); + expect(query.result.returnType).to.be.equal('ok'); queryObject = await oracle.getQuery(query.decodedResult); expect(queryObject.decodedQuery).to.be.equal(q); }); @@ -396,7 +396,7 @@ contract DelegateTest = r, ); assertNotNull(result); - result.returnType.should.be.equal('ok'); + expect(result.returnType).to.be.equal('ok'); const queryObject2 = await oracle.getQuery(queryObject.id); expect(queryObject2.decodedResponse).to.be.equal(r); }); diff --git a/test/integration/node.ts b/test/integration/node.ts index 57f94dae7f..10ac86d78f 100644 --- a/test/integration/node.ts +++ b/test/integration/node.ts @@ -178,10 +178,10 @@ describe('Node client', () => { ], }); const activeNode = await nodes.getNodeInfo(); - activeNode.name.should.be.equal('first'); + expect(activeNode.name).to.be.equal('first'); nodes.selectNode('second'); const secondNodeInfo = await nodes.getNodeInfo(); - secondNodeInfo.name.should.be.equal('second'); + expect(secondNodeInfo.name).to.be.equal('second'); }); it('Fail on undefined node', async () => { @@ -202,7 +202,7 @@ describe('Node client', () => { nodes: [{ name: 'first', instance: node }], }); const nodesList = await nodes.getNodesInPool(); - nodesList.length.should.be.equal(1); + expect(nodesList).to.have.length(1); }); }); }); diff --git a/test/integration/oracle.ts b/test/integration/oracle.ts index 0a73e4fadf..d1a5eb961a 100644 --- a/test/integration/oracle.ts +++ b/test/integration/oracle.ts @@ -175,17 +175,18 @@ describe('Oracle', () => { it('polls for response for query without response', async () => { const { queryId } = await oracleClient.postQuery('{"city": "Berlin"}', { queryTtlValue: 1 }); - await oracleClient - .pollForResponse(queryId) - .should.be.rejectedWith(/Giving up at height|error: Query not found/); + await expect(oracleClient.pollForResponse(queryId)).to.be.rejectedWith( + /Giving up at height|error: Query not found/, + ); }).timeout(timeoutBlock); it('polls for response for query that is already expired without response', async () => { const { queryId } = await oracleClient.postQuery('{"city": "Berlin"}', { queryTtlValue: 1 }); await aeSdk.awaitHeight((await aeSdk.getHeight()) + 2); - await oracleClient - .pollForResponse(queryId) - .should.be.rejectedWith(RestError, 'Query not found'); + await expect(oracleClient.pollForResponse(queryId)).to.be.rejectedWith( + RestError, + 'Query not found', + ); }).timeout(timeoutBlock * 2); it('queries oracle', async () => { diff --git a/test/integration/transaction.ts b/test/integration/transaction.ts index 6645489420..e288361bae 100644 --- a/test/integration/transaction.ts +++ b/test/integration/transaction.ts @@ -78,7 +78,7 @@ describe('Transaction', () => { denomination: AE_AMOUNT_FORMATS.AE, }); const spendAettos = await aeSdk.buildTx({ ...params, tag: Tag.SpendTx, amount: 1e18 }); - spendAe.should.be.equal(spendAettos); + expect(spendAe).to.be.equal(spendAettos); }); describe('gas price from node', () => { diff --git a/test/unit/bytes.ts b/test/unit/bytes.ts index be845bc8bb..90f12ddc70 100644 --- a/test/unit/bytes.ts +++ b/test/unit/bytes.ts @@ -7,19 +7,19 @@ import { snakeToPascal, pascalToSnake } from '../../src/utils/string'; describe('Bytes', () => { it('toBytes: converts null to empty array', () => { - toBytes(null).should.be.eql(Buffer.from([])); + expect(toBytes(null)).to.be.eql(Buffer.from([])); }); const testCase = 'test_test-testTest'; it('converts snake to pascal case', () => - snakeToPascal(testCase).should.be.equal('testTest-testTest')); + expect(snakeToPascal(testCase)).to.be.equal('testTest-testTest')); it('converts pascal to snake case', () => - pascalToSnake(testCase).should.be.equal('test_test-test_test')); + expect(pascalToSnake(testCase)).to.be.equal('test_test-test_test')); it('converts BigNumber to Buffer', () => - toBytes(new BigNumber('1000')).readInt16BE().should.be.equal(1000)); + expect(toBytes(new BigNumber('1000')).readInt16BE()).to.be.equal(1000)); it('throws error if BigNumber is not integer', () => expect(() => toBytes(new BigNumber('1.5'))).to.throw( diff --git a/test/unit/crypto.ts b/test/unit/crypto.ts index b40c536912..d557edfa3f 100644 --- a/test/unit/crypto.ts +++ b/test/unit/crypto.ts @@ -104,21 +104,21 @@ describe('crypto', () => { it('hashing produces 256 bit blake2b byte buffers', () => { const h = hash('foobar'); - h.should.be.a('Uint8Array'); - Buffer.from(h) - .toString('hex') - .should.be.equal('93a0e84a8cdd4166267dbe1263e937f08087723ac24e7dcc35b3d5941775ef47'); + expect(h).to.be.a('Uint8Array'); + expect(Buffer.from(h).toString('hex')).to.be.equal( + '93a0e84a8cdd4166267dbe1263e937f08087723ac24e7dcc35b3d5941775ef47', + ); }); it('salt produces random sequences every time', () => { const salt1 = genSalt(); const salt2 = genSalt(); - salt1.should.be.a('Number'); - salt2.should.be.a('Number'); - salt1.should.not.be.equal(salt2); + expect(salt1).to.be.a('Number'); + expect(salt2).to.be.a('Number'); + expect(salt1).to.not.be.equal(salt2); }); it('Can produce tx hash', () => { - buildTxHash(decode(txRaw)).should.be.equal(expectedHash); + expect(buildTxHash(decode(txRaw))).to.be.equal(expectedHash); }); }); diff --git a/test/unit/tx.ts b/test/unit/tx.ts index 586e8cffae..8d17687e01 100644 --- a/test/unit/tx.ts +++ b/test/unit/tx.ts @@ -34,8 +34,8 @@ describe('Tx', () => { it('reproducible commitment hashes can be generated', async () => { const salt = genSalt(); const hash = await commitmentHash('foobar.chain', salt); - hash.should.be.a('string'); - hash.should.be.equal(await commitmentHash('foobar.chain', salt)); + expect(hash).to.be.a('string'); + expect(hash).to.be.equal(await commitmentHash('foobar.chain', salt)); }); it('test from big number to bytes', async () => { @@ -55,12 +55,12 @@ describe('Tx', () => { } data.forEach((n) => { - n.toString(10).should.be.equal(bnFromBytes(n)); + expect(n.toString(10)).to.be.equal(bnFromBytes(n)); }); }); it('Produce name id for `.chain`', () => { - produceNameId('asdas.chain').should.be.equal( + expect(produceNameId('asdas.chain')).to.equal( 'nm_2DMazuJNrGkQYve9eMttgdteaigeeuBk3fmRYSThJZ2NpX3r8R', ); }); @@ -68,14 +68,14 @@ describe('Tx', () => { describe('getMinimumNameFee', () => { it('returns correct name fees', () => { for (let i = 1; i <= Object.keys(NAME_BID_RANGES).length; i += 1) { - getMinimumNameFee(randomName(i)).toString().should.be.equal(NAME_BID_RANGES[i].toString()); + expect(getMinimumNameFee(randomName(i)).toString()).to.equal(NAME_BID_RANGES[i].toString()); } }); }); describe('isNameValid', () => { - it('validates domain', () => isNameValid('asdasdasd.unknown').should.be.equal(false)); - it("don't throws exception", () => isNameValid('asdasdasd.chain').should.be.equal(true)); + it('validates domain', () => expect(isNameValid('asdasdasd.unknown')).to.be.equal(false)); + it("don't throws exception", () => expect(isNameValid('asdasdasd.chain')).to.be.equal(true)); }); const payload = Buffer.from([1, 2, 42]); From d11d3581967febb302d1aa1790a862386ef409cd Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Tue, 28 Jan 2025 18:51:32 +0100 Subject: [PATCH 2/3] test: enable `should` only where used --- test/index.ts | 3 +-- test/integration/accounts.ts | 4 +++- test/integration/chain.ts | 4 +++- test/integration/channel-contracts.ts | 3 ++- test/integration/channel.ts | 4 +++- test/integration/contract-aci.ts | 4 +++- test/integration/rpc.ts | 4 +++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/test/index.ts b/test/index.ts index a6a1a608c8..98fa6fe1e8 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1,5 +1,4 @@ -import { use, should } from 'chai'; +import { use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; use(chaiAsPromised); -should(); diff --git a/test/integration/accounts.ts b/test/integration/accounts.ts index c0acd33509..349f3a74b5 100644 --- a/test/integration/accounts.ts +++ b/test/integration/accounts.ts @@ -1,5 +1,5 @@ import { describe, it, before } from 'mocha'; -import { expect } from 'chai'; +import { expect, should } from 'chai'; import BigNumber from 'bignumber.js'; import { getSdk, networkId } from '.'; import { assertNotNull } from '../utils'; @@ -15,6 +15,8 @@ import { Encoded, } from '../../src'; +should(); + describe('Accounts', () => { let aeSdk: AeSdk; let aeSdkNoCoins: AeSdk; diff --git a/test/integration/chain.ts b/test/integration/chain.ts index 1b732fc9be..4c8567b60d 100644 --- a/test/integration/chain.ts +++ b/test/integration/chain.ts @@ -1,10 +1,12 @@ import { describe, it, before } from 'mocha'; -import { expect } from 'chai'; +import { expect, should } from 'chai'; import { stub } from 'sinon'; import { getSdk, timeoutBlock, url } from '.'; import { AeSdk, Tag, MemoryAccount, Encoded, Node, Contract } from '../../src'; import { assertNotNull, bindRequestCounter, indent } from '../utils'; +should(); + describe('Node Chain', () => { let aeSdk: AeSdk; let aeSdkWithoutAccount: AeSdk; diff --git a/test/integration/channel-contracts.ts b/test/integration/channel-contracts.ts index 5126bdfb54..ab38ea34f5 100644 --- a/test/integration/channel-contracts.ts +++ b/test/integration/channel-contracts.ts @@ -1,5 +1,5 @@ import { describe, it, before, after, beforeEach, afterEach } from 'mocha'; -import { expect } from 'chai'; +import { expect, should } from 'chai'; import * as sinon from 'sinon'; import { getSdk, networkId } from '.'; import { @@ -21,6 +21,7 @@ import { SignTxWithTag } from '../../src/channel/internal'; import { assertNotNull } from '../utils'; import { initializeChannels, recreateAccounts } from './channel-utils'; +should(); const contractSourceCode = ` contract Identity = entrypoint getArg(x : int) : int = x diff --git a/test/integration/channel.ts b/test/integration/channel.ts index ea95ba5003..84d9d0d6c7 100644 --- a/test/integration/channel.ts +++ b/test/integration/channel.ts @@ -1,5 +1,5 @@ import { describe, it, before, after, beforeEach, afterEach } from 'mocha'; -import { expect } from 'chai'; +import { expect, should } from 'chai'; import * as sinon from 'sinon'; import { getSdk, networkId } from '.'; import { @@ -25,6 +25,8 @@ import { recreateAccounts, } from './channel-utils'; +should(); + describe('Channel', () => { let aeSdk: AeSdk; let initiator: MemoryAccount; diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index f87a9b439e..b339fbf047 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai'; +import { expect, should } from 'chai'; import { before, describe, it } from 'mocha'; import BigNumber from 'bignumber.js'; import { @@ -30,6 +30,8 @@ import { Aci } from '../../src/contract/compiler/Base'; import { ContractCallObject } from '../../src/contract/Contract'; import includesAci from './contracts/Includes.json'; +should(); + const identityContractSourceCode = ` contract Identity = entrypoint getArg(x: int) = x diff --git a/test/integration/rpc.ts b/test/integration/rpc.ts index 723c391513..a88e319459 100644 --- a/test/integration/rpc.ts +++ b/test/integration/rpc.ts @@ -1,5 +1,5 @@ import { after, before, describe, it } from 'mocha'; -import { expect } from 'chai'; +import { expect, should } from 'chai'; import { stub, createSandbox } from 'sinon'; import { AeSdk, @@ -43,6 +43,8 @@ import { getSdk, networkId, compilerUrl } from '.'; import { Accounts, Network } from '../../src/aepp-wallet-communication/rpc/types'; import { assertNotNull, indent } from '../utils'; +should(); + const WindowPostMessageFake = ( name: string, ): ImplPostMessage & { name: string; messages: any[] } => { From 4d8bf1993d584f6c72411d768d184464c0b42345 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Tue, 28 Jan 2025 18:59:07 +0100 Subject: [PATCH 3/3] test: remove extra `be` in chai assertions --- test/integration/AeSdk.ts | 8 +- test/integration/AeSdkMethods.ts | 4 +- test/integration/Middleware.ts | 74 +++++++------- test/integration/MiddlewareSubscriber.ts | 32 +++--- test/integration/account-generalized.ts | 16 +-- test/integration/accounts.ts | 18 ++-- test/integration/aens.ts | 38 +++---- test/integration/chain.ts | 26 ++--- test/integration/channel-contracts.ts | 18 ++-- test/integration/channel-other.ts | 18 ++-- test/integration/channel.ts | 32 +++--- test/integration/compiler.ts | 16 +-- test/integration/contract-aci.ts | 120 +++++++++++------------ test/integration/contract.ts | 28 +++--- test/integration/delegation.ts | 34 +++---- test/integration/node.ts | 10 +- test/integration/oracle.ts | 30 +++--- test/integration/paying-for.ts | 4 +- test/integration/rpc.ts | 54 +++++----- test/integration/transaction.ts | 18 ++-- test/integration/txVerification.ts | 4 +- test/integration/typed-data.ts | 28 +++--- test/integration/~execution-cost.ts | 10 +- test/unit/ae-sdk.ts | 2 +- test/unit/aens.ts | 18 ++-- test/unit/amount-formatter.ts | 6 +- test/unit/bytes.ts | 8 +- test/unit/crypto.ts | 18 ++-- test/unit/delegation.ts | 2 +- test/unit/entry-packing.ts | 8 +- test/unit/jwt.ts | 30 +++--- test/unit/ledger.ts | 26 ++--- test/unit/memory-account.ts | 16 +-- test/unit/metamask.ts | 20 ++-- test/unit/mnemonic.ts | 14 +-- test/unit/mptree.ts | 12 +-- test/unit/pretty-numbers.ts | 8 +- test/unit/tx.ts | 34 +++---- test/unit/utils.ts | 12 +-- test/utils.ts | 4 +- 40 files changed, 436 insertions(+), 442 deletions(-) diff --git a/test/integration/AeSdk.ts b/test/integration/AeSdk.ts index 42745e093d..80923d06d1 100644 --- a/test/integration/AeSdk.ts +++ b/test/integration/AeSdk.ts @@ -8,8 +8,8 @@ describe('AeSdk', () => { const aeSdk = await getSdk(0); aeSdk._options._expectedMineRate = 1000; aeSdk._options._microBlockCycle = 300; - expect(await aeSdk._getPollInterval('key-block')).to.be.equal(333); - expect(await aeSdk._getPollInterval('micro-block')).to.be.equal(100); + expect(await aeSdk._getPollInterval('key-block')).to.equal(333); + expect(await aeSdk._getPollInterval('micro-block')).to.equal(100); }); it('returns correct value', async () => { @@ -17,8 +17,8 @@ describe('AeSdk', () => { delete aeSdk._options._expectedMineRate; delete aeSdk._options._microBlockCycle; const [kb, mb] = networkId === 'ae_dev' ? [0, 0] : [60000, 1000]; - expect(await aeSdk._getPollInterval('key-block')).to.be.equal(kb); - expect(await aeSdk._getPollInterval('micro-block')).to.be.equal(mb); + expect(await aeSdk._getPollInterval('key-block')).to.equal(kb); + expect(await aeSdk._getPollInterval('micro-block')).to.equal(mb); }); }); }); diff --git a/test/integration/AeSdkMethods.ts b/test/integration/AeSdkMethods.ts index 0ba59010c2..07299ae58e 100644 --- a/test/integration/AeSdkMethods.ts +++ b/test/integration/AeSdkMethods.ts @@ -32,9 +32,9 @@ describe('AeSdkMethods', () => { contract Identity = entrypoint getArg(x : int) = x`, }); - expect(contract.$options.onAccount?.address).to.be.eql(accounts[0].address); + expect(contract.$options.onAccount?.address).to.eql(accounts[0].address); [, aeSdkMethods._options.onAccount] = accounts; - expect(contract.$options.onAccount?.address).to.be.eql(accounts[1].address); + expect(contract.$options.onAccount?.address).to.eql(accounts[1].address); }); it('converts context to JSON', () => { diff --git a/test/integration/Middleware.ts b/test/integration/Middleware.ts index 368de51be4..b70b56159a 100644 --- a/test/integration/Middleware.ts +++ b/test/integration/Middleware.ts @@ -22,10 +22,10 @@ function copyFields( fields .filter((key) => source[key] != null) .forEach((key) => { - expect(typeof target[key]).to.be.equal(typeof source[key]); - expect(target[key]?.constructor).to.be.equal(source[key]?.constructor); + expect(typeof target[key]).to.equal(typeof source[key]); + expect(target[key]?.constructor).to.equal(source[key]?.constructor); if (typeof target[key] === 'string' && target[key][2] === '_') { - expect(target[key].slice(0, 2)).to.be.equal(source[key].slice(0, 2)); + expect(target[key].slice(0, 2)).to.equal(source[key].slice(0, 2)); } target[key] = source[key]; }); @@ -64,7 +64,7 @@ describe('Middleware API', () => { nodeSyncing: false, nodeVersion: '7.1.0', }; - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); describe('blocks', () => { @@ -96,7 +96,7 @@ describe('Middleware API', () => { ); expectedRes.data.unshift(...res.data.slice(0, -1)); expect(res.data[0].time.getFullYear()).to.be.within(2024, 2030); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets micro block', async () => { @@ -122,7 +122,7 @@ describe('Middleware API', () => { txsHash: 'bx_2i471KqJ5XTLVQJS4x95FyLuwbAcj4SetvemPUs4oV47S9dFb3', }; copyFields(expectedRes, res, ['time', 'hash', 'prevHash', 'prevKeyHash', 'signature']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -293,7 +293,7 @@ describe('Middleware API', () => { copyFields(item, res.data[idx], ['blockHash', 'blockTime']); copyFields(item.payload, res.data[idx].payload, ['blockHash', 'microTime']); }); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets transactions', async () => { @@ -335,13 +335,13 @@ describe('Middleware API', () => { res.data.length = 0; res.data.push(tx); copyFields(expectedRes.data[0], res.data[0], ['blockHash', 'microTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets transactions count', async () => { const res = await middleware.getTransactionsCount(); const expectedRes: typeof res = { body: 10 }; - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets transfers', async () => { @@ -366,7 +366,7 @@ describe('Middleware API', () => { ); expectedRes.data.push(...res.data.slice(1)); copyFields(expectedRes.data[0], res.data[0], ['refTxType']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -403,7 +403,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['blockHash']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets contract logs', async () => { @@ -435,7 +435,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['blockHash', 'blockTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets contract', async () => { @@ -463,7 +463,7 @@ describe('Middleware API', () => { sourceTxType: 'ContractCreateTx', }; copyFields(expectedRes, res, ['blockHash']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -507,13 +507,13 @@ describe('Middleware API', () => { 'approximateExpireTime', 'expireHeight', ]); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets names count', async () => { const res = await middleware.getNamesCount(); const expectedRes: typeof res = { body: 2 }; - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets name claims', async () => { @@ -545,7 +545,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['blockHash']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets name updates', async () => { @@ -589,7 +589,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['blockHash']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets account pointees pointers', async () => { @@ -635,7 +635,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['blockHash', 'blockTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets auctions', async () => { @@ -686,7 +686,7 @@ describe('Middleware API', () => { 'auctionEnd', ]); copyFields(expectedRes.data[0].lastBid, res.data[0].lastBid, ['blockHash', 'microTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -748,7 +748,7 @@ describe('Middleware API', () => { ); copyFields(expectedRes.data[0].register, res.data[0].register, ['blockHash', 'microTime']); copyFields(expectedRes.data[0], res.data[0], ['registerTime', 'approximateExpireTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets oracle', async () => { @@ -771,7 +771,7 @@ describe('Middleware API', () => { registerTxHash: 'th_299u2zPGuFDJPpmYM6ZpRaAiCnRViGwW4aph12Hz9Qr1Cc7tPP', }; copyFields(expectedRes, res, ['registerTime', 'approximateExpireTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -812,7 +812,7 @@ describe('Middleware API', () => { middleware, ); copyFields(expectedRes.data[0], res.data[0], ['lastUpdatedTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets channel', async () => { @@ -843,7 +843,7 @@ describe('Middleware API', () => { updatesCount: 1, }; copyFields(expectedRes, res, ['lastUpdatedTime']); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -881,7 +881,7 @@ describe('Middleware API', () => { middleware, ); expectedRes.data.push(...res.data.slice(1)); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets total', async () => { @@ -913,7 +913,7 @@ describe('Middleware API', () => { middleware, ); expectedRes.data.push(...res.data.slice(1)); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets miner', async () => { @@ -922,7 +922,7 @@ describe('Middleware API', () => { { data: [], next: null, prev: null }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets blocks', async () => { @@ -935,7 +935,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets transactions', async () => { @@ -948,7 +948,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets names', async () => { @@ -961,7 +961,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -976,7 +976,7 @@ describe('Middleware API', () => { it('gets not paginated data', async () => { const res = await middleware.requestByPath('/v3/status'); const expectedRes: typeof res = await middleware.getStatus(); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets first page', async () => { @@ -984,7 +984,7 @@ describe('Middleware API', () => { `/v3/accounts/${presetAccount1Address}/activities`, ); const expectedRes: typeof res = await middleware.getAccountActivities(presetAccount1Address); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets first page with query parameters', async () => { @@ -999,7 +999,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('gets second page', async () => { @@ -1014,7 +1014,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); }); @@ -1030,15 +1030,15 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('nevigates to the previous page', async () => { const first = await middleware.getTransactions({ limit: 1 }); const second = await first.next(); const res = await second.prev(); - expect(res).to.be.eql(first); - expect(res.prevPath).to.be.eql(null); + expect(res).to.eql(first); + expect(res.prevPath).to.eql(null); const expectedRes: typeof res = new MiddlewarePage( { data: (await middleware.getTransactions()).data.slice(0, 1), @@ -1047,7 +1047,7 @@ describe('Middleware API', () => { }, middleware, ); - expect(res).to.be.eql(expectedRes); + expect(res).to.eql(expectedRes); }); it('fails to navigate out of page range', async () => { diff --git a/test/integration/MiddlewareSubscriber.ts b/test/integration/MiddlewareSubscriber.ts index e18455e111..6108f5807e 100644 --- a/test/integration/MiddlewareSubscriber.ts +++ b/test/integration/MiddlewareSubscriber.ts @@ -33,7 +33,7 @@ describe('MiddlewareSubscriber', () => { }); }); await expect(promise).to.be.rejectedWith('Unexpected server response: 200'); - expect(middleware.webSocket).to.be.equal(undefined); + expect(middleware.webSocket).to.equal(undefined); }); it('fails to subscribe to invalid address', async () => { @@ -63,18 +63,18 @@ describe('MiddlewareSubscriber', () => { } it('reconnects if subscribed again', async () => { - expect(middleware.webSocket).to.be.equal(undefined); + expect(middleware.webSocket).to.equal(undefined); let unsubscribe = middleware.subscribeTransactions(() => {}); await ensureConnected(middleware); assertNotNull(middleware.webSocket); unsubscribe(); - expect(middleware.webSocket).to.be.equal(undefined); + expect(middleware.webSocket).to.equal(undefined); unsubscribe = middleware.subscribeTransactions(() => {}); await ensureConnected(middleware); assertNotNull(middleware.webSocket); unsubscribe(); - expect(middleware.webSocket).to.be.equal(undefined); + expect(middleware.webSocket).to.equal(undefined); }); it('can be reconnected', async () => { @@ -87,16 +87,16 @@ describe('MiddlewareSubscriber', () => { assertNotNull(middleware.webSocket); middleware.webSocket.addEventListener('close', resolve); }); - expect(handleTx.callCount).to.be.equal(1); - expect(handleTx.firstCall.args[0]).to.be.equal(undefined); - expect(handleTx.firstCall.args[1]).to.be.instanceOf(MiddlewareSubscriberDisconnected); - expect(middleware.webSocket).to.be.equal(undefined); + expect(handleTx.callCount).to.equal(1); + expect(handleTx.firstCall.args[0]).to.equal(undefined); + expect(handleTx.firstCall.args[1]).to.be.an.instanceOf(MiddlewareSubscriberDisconnected); + expect(middleware.webSocket).to.equal(undefined); middleware.reconnect(); await ensureConnected(middleware); assertNotNull(middleware.webSocket); unsubscribe(); - expect(handleTx.callCount).to.be.equal(1); + expect(handleTx.callCount).to.equal(1); }); async function fetchNodeRaw(path: string): Promise { @@ -116,7 +116,7 @@ describe('MiddlewareSubscriber', () => { }); }), ]); - expect(transaction).to.be.eql({ + expect(transaction).to.eql({ ...(await fetchNodeRaw(`transactions/${hash}`)), tx_index: transaction.tx_index, micro_index: transaction.micro_index, @@ -135,7 +135,7 @@ describe('MiddlewareSubscriber', () => { }); }), ]); - expect(transaction).to.be.eql({ + expect(transaction).to.eql({ ...(await fetchNodeRaw(`transactions/${hash}`)), tx_index: transaction.tx_index, micro_index: transaction.micro_index, @@ -160,8 +160,8 @@ describe('MiddlewareSubscriber', () => { } unsubscribe1(); unsubscribe2(); - expect(events1.map((ev) => ev.hash)).to.be.eql([tx1.hash, tx3.hash]); - expect(events2.map((ev) => ev.hash)).to.be.eql([tx1.hash, tx2.hash]); + expect(events1.map((ev) => ev.hash)).to.eql([tx1.hash, tx3.hash]); + expect(events2.map((ev) => ev.hash)).to.eql([tx1.hash, tx2.hash]); }); it('subscribes for micro block', async () => { @@ -177,7 +177,7 @@ describe('MiddlewareSubscriber', () => { }); }), ]); - expect(microBlock).to.be.eql({ + expect(microBlock).to.eql({ ...(await fetchNodeRaw(`micro-blocks/hash/${blockHash}/header`)), transactions_count: 1, micro_block_index: 0, @@ -203,13 +203,13 @@ describe('MiddlewareSubscriber', () => { }); }), ]); - expect(transaction).to.be.eql({ + expect(transaction).to.eql({ ...(await fetchNodeRaw(`transactions/${hash}`)), tx_index: transaction.tx_index, micro_index: transaction.micro_index, micro_time: transaction.micro_time, }); - expect(microBlock).to.be.eql({ + expect(microBlock).to.eql({ ...(await fetchNodeRaw(`micro-blocks/hash/${blockHash}/header`)), transactions_count: 1, micro_block_index: 0, diff --git a/test/integration/account-generalized.ts b/test/integration/account-generalized.ts index c4ae3a8b11..dcf24c0ca3 100644 --- a/test/integration/account-generalized.ts +++ b/test/integration/account-generalized.ts @@ -52,7 +52,7 @@ describe('Generalized Account', () => { it('Make account GA', async () => { accountBeforeGa = Object.values(aeSdk.accounts)[0] as MemoryAccount; const { gaContractId } = await aeSdk.createGeneralizedAccount('authorize', [], { sourceCode }); - expect((await aeSdk.getAccount(gaAccountAddress)).kind).to.be.equal('generalized'); + expect((await aeSdk.getAccount(gaAccountAddress)).kind).to.equal('generalized'); authContract = await Contract.initialize({ ...aeSdk.getContext(), sourceCode, @@ -113,7 +113,7 @@ describe('Generalized Account', () => { authData: { sourceCode, args: [genSalt()] }, }); - expect(new Uint8Array(await aeSdk.buildAuthTxHashByGaMetaTx(rawTx))).to.be.eql( + expect(new Uint8Array(await aeSdk.buildAuthTxHashByGaMetaTx(rawTx))).to.eql( (await authContract.getTxHash()).decodedResult, ); @@ -121,7 +121,7 @@ describe('Generalized Account', () => { ensureEqual(gaMetaTxParams.tag, Tag.GaMetaTx); const spendTx = buildTx(gaMetaTxParams.tx.encodedTx); const { fee, gasPrice } = gaMetaTxParams; - expect(new Uint8Array(await aeSdk.buildAuthTxHash(spendTx, { fee, gasPrice }))).to.be.eql( + expect(new Uint8Array(await aeSdk.buildAuthTxHash(spendTx, { fee, gasPrice }))).to.eql( (await authContract.getTxHash()).decodedResult, ); }); @@ -143,9 +143,9 @@ describe('Generalized Account', () => { }); const txParams = unpackTx(rawTx, Tag.SignedTx); ensureEqual(txParams.encodedTx.tag, Tag.GaMetaTx); - expect(buildTx(txParams.encodedTx.tx.encodedTx)).to.be.equal(spendTx); - expect(txParams.encodedTx.fee).to.be.equal(fee.toString()); - expect(txParams.encodedTx.gasPrice).to.be.equal(gasPrice.toString()); + expect(buildTx(txParams.encodedTx.tx.encodedTx)).to.equal(spendTx); + expect(txParams.encodedTx.fee).to.equal(fee.toString()); + expect(txParams.encodedTx.gasPrice).to.equal(gasPrice.toString()); }); it('fails trying to send SignedTx using generalized account', async () => { @@ -182,8 +182,8 @@ describe('Generalized Account', () => { put(state{ value = _value })`, }); await contract.$deploy([42], { authData: { sourceCode, args: [genSalt()] } }); - expect((await contract.getState()).decodedResult).to.be.equal(42); + expect((await contract.getState()).decodedResult).to.equal(42); await contract.setState(43, { authData: { sourceCode, args: [genSalt()] } }); - expect((await contract.getState()).decodedResult).to.be.equal(43); + expect((await contract.getState()).decodedResult).to.equal(43); }); }); diff --git a/test/integration/accounts.ts b/test/integration/accounts.ts index 349f3a74b5..2429a33d36 100644 --- a/test/integration/accounts.ts +++ b/test/integration/accounts.ts @@ -33,7 +33,7 @@ describe('Accounts', () => { const account = aeSdk.accounts[address]; aeSdk.removeAccount(address); expect(Object.keys(aeSdk.accounts)).to.have.length(1); - expect(aeSdk.selectedAddress).to.be.equal(undefined); + expect(aeSdk.selectedAddress).to.equal(undefined); aeSdk.addAccount(account, { select: true }); }); @@ -125,23 +125,23 @@ describe('Accounts', () => { it('spends with a payload', async () => { const payload = encode(Buffer.from([1, 2, 3, 4]), Encoding.Bytearray); const { tx } = await aeSdk.spend(1, receiver.address, { payload }); - expect(tx?.payload).to.be.equal('ba_AQIDBI3kcuI='); + expect(tx?.payload).to.equal('ba_AQIDBI3kcuI='); }); it('Get Account by block height/hash', async () => { const address = 'ak_2swhLkgBPeeADxVTAVCJnZLY5NZtCFiM93JxsEaMuC59euuFRQ'; if (networkId === 'ae_uat') { - expect(await aeSdk.getBalance(address, { height: 500000 })).to.be.equal( + expect(await aeSdk.getBalance(address, { height: 500000 })).to.equal( '4577590840980663351396', ); return; } if (networkId === 'ae_mainnet') { - expect(await aeSdk.getBalance(address, { height: 362055 })).to.be.equal('100000000000000'); + expect(await aeSdk.getBalance(address, { height: 362055 })).to.equal('100000000000000'); return; } const genesis = 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E'; - expect(await aeSdk.getBalance(genesis, { height: 0 })).to.be.equal('10000000000000000000000'); + expect(await aeSdk.getBalance(genesis, { height: 0 })).to.equal('10000000000000000000000'); }); (networkId === 'ae_dev' ? it : it.skip)( @@ -158,11 +158,11 @@ describe('Accounts', () => { const afterSpend = await getBalance(); assertNotNull(spend.tx?.amount); - expect(beforeSpend - afterSpend).to.be.equal(spend.tx.fee + spend.tx.amount); - expect(await getBalance(beforeHeight)).to.be.equal(beforeSpend); + expect(beforeSpend - afterSpend).to.equal(spend.tx.fee + spend.tx.amount); + expect(await getBalance(beforeHeight)).to.equal(beforeSpend); assertNotNull(spend.blockHeight); await aeSdk.awaitHeight(spend.blockHeight + 1); - expect(await getBalance(spend.blockHeight + 1)).to.be.equal(afterSpend); + expect(await getBalance(spend.blockHeight + 1)).to.equal(afterSpend); }, ); @@ -218,7 +218,7 @@ describe('Accounts', () => { const data = 'Hello'; const signature = await account.sign(data); const sigUsingMemoryAccount = await aeSdk.sign(data, { onAccount: account }); - expect(signature).to.be.eql(sigUsingMemoryAccount); + expect(signature).to.eql(sigUsingMemoryAccount); }); }); diff --git a/test/integration/aens.ts b/test/integration/aens.ts index 3b60d53796..77472029f6 100644 --- a/test/integration/aens.ts +++ b/test/integration/aens.ts @@ -40,7 +40,7 @@ describe('Aens', () => { assertNotNull(preclaimRes.signatures); expect(preclaimRes.tx.fee).to.satisfy((fee: bigint) => fee >= 16620000000000n); expect(preclaimRes.tx.fee).to.satisfy((fee: bigint) => fee < 16860000000000n); - expect(preclaimRes).to.be.eql({ + expect(preclaimRes).to.eql({ tx: { fee: preclaimRes.tx.fee, nonce: preclaimRes.tx.nonce, @@ -64,7 +64,7 @@ describe('Aens', () => { assertNotNull(claimRes.signatures); expect(claimRes.tx.fee).to.satisfy((fee: bigint) => fee >= 16660000000000n); expect(claimRes.tx.fee).to.satisfy((fee: bigint) => fee <= 17080000000000n); - expect(claimRes).to.be.eql({ + expect(claimRes).to.eql({ tx: { fee: claimRes.tx.fee, nonce: claimRes.tx.nonce, @@ -85,7 +85,7 @@ describe('Aens', () => { }); assertNotNull(claimRes.blockHeight); - expect(await aeSdk.api.getNameEntryByName(name.value)).to.be.eql({ + expect(await aeSdk.api.getNameEntryByName(name.value)).to.eql({ id: produceNameId(name.value), owner: aeSdk.address, pointers: [], @@ -102,7 +102,7 @@ describe('Aens', () => { assertNotNull(claimed.signatures); expect(claimed.tx.fee).to.satisfy((fee: bigint) => fee >= 16860000000000n); expect(claimed.tx.fee).to.satisfy((fee: bigint) => fee < 17000000000000n); - expect(claimed).to.be.eql({ + expect(claimed).to.eql({ tx: { fee: claimed.tx.fee, nonce: claimed.tx.nonce, @@ -138,11 +138,11 @@ describe('Aens', () => { assertNotNull(claimRes.tx); expect(claimRes.tx.fee).to.satisfy((fee: bigint) => fee >= 16940000000000n); expect(claimRes.tx.fee).to.satisfy((fee: bigint) => fee < 17100000000000n); - expect(claimRes.tx.name).to.be.equal(n.value); - expect(claimRes.tx.nameFee).to.be.equal(300000000000000n); + expect(claimRes.tx.name).to.equal(n.value); + expect(claimRes.tx.nameFee).to.equal(300000000000000n); assertNotNull(claimRes.blockHeight); - expect(await aeSdk.api.getNameEntryByName(n.value)).to.be.eql({ + expect(await aeSdk.api.getNameEntryByName(n.value)).to.eql({ id: produceNameId(n.value), owner: aeSdk.address, pointers: [], @@ -155,7 +155,7 @@ describe('Aens', () => { const n = new Name(randomName(30), aeSdk.getContext()); const preclaimRes = await n.preclaim({ onAccount }); assertNotNull(preclaimRes.tx); - expect(preclaimRes.tx.accountId).to.be.equal(onAccount.address); + expect(preclaimRes.tx.accountId).to.equal(onAccount.address); }); (isLimitedCoins ? it.skip : it)('starts a unicode name auction and makes a bid', async () => { @@ -170,7 +170,7 @@ describe('Aens', () => { const bidRes = await n.bid(bidFee, { onAccount }); assertNotNull(bidRes.tx); assertNotNull(bidRes.signatures); - expect(bidRes).to.be.eql({ + expect(bidRes).to.eql({ tx: { fee: bidRes.tx.fee, nonce: bidRes.tx.nonce, @@ -197,7 +197,7 @@ describe('Aens', () => { it('queries state from the node', async () => { const state = await name.getState(); - expect(state).to.be.eql(await aeSdk.api.getNameEntryByName(name.value)); + expect(state).to.eql(await aeSdk.api.getNameEntryByName(name.value)); }); it('throws error on querying non-existent name', async () => { @@ -235,9 +235,9 @@ describe('Aens', () => { address: name.value, }); // TODO: should be name id instead - expect(contractName.$options.address).to.be.equal(contract.$options.address); - expect((await contract.getArg(42, { callStatic: true })).decodedResult).to.be.equal(42n); - expect((await contract.getArg(42, { callStatic: false })).decodedResult).to.be.equal(42n); + expect(contractName.$options.address).to.equal(contract.$options.address); + expect((await contract.getArg(42, { callStatic: true })).decodedResult).to.equal(42n); + expect((await contract.getArg(42, { callStatic: false })).decodedResult).to.equal(42n); }); const { address } = MemoryAccount.generate(); @@ -266,7 +266,7 @@ describe('Aens', () => { assertNotNull(updateRes.signatures); expect(updateRes.tx.fee).to.satisfy((fee: bigint) => fee >= 22140000000000n); expect(updateRes.tx.fee).to.satisfy((fee: bigint) => fee <= 22240000000000n); - expect(updateRes).to.be.eql({ + expect(updateRes).to.eql({ tx: { fee: updateRes.tx.fee, nonce: updateRes.tx.nonce, @@ -315,7 +315,7 @@ describe('Aens', () => { { extendPointers: true }, ); assertNotNull(updateRes.tx); - expect(updateRes.tx.pointers).to.be.eql([ + expect(updateRes.tx.pointers).to.eql([ ...pointersNode.filter((pointer) => pointer.key !== 'contract_pubkey'), { key: 'contract_pubkey', @@ -346,14 +346,14 @@ describe('Aens', () => { const extendRes = await name.extendTtl(10000); assertNotNull(extendRes.blockHeight); const { ttl } = await name.getState(); - expect(ttl).to.be.equal(extendRes.blockHeight + 10000); + expect(ttl).to.equal(extendRes.blockHeight + 10000); }); it('spends by name', async () => { const onAccount = Object.values(aeSdk.accounts)[1]; const spendRes = await aeSdk.spend(100, name.value, { onAccount }); assertNotNull(spendRes.tx); - expect(spendRes.tx.recipientId).to.be.equal(produceNameId(name.value)); + expect(spendRes.tx.recipientId).to.equal(produceNameId(name.value)); }); it('transfers name', async () => { @@ -363,7 +363,7 @@ describe('Aens', () => { assertNotNull(transferRes.signatures); expect(transferRes.tx.fee).to.satisfy((fee: bigint) => fee >= 17300000000000n); expect(transferRes.tx.fee).to.satisfy((fee: bigint) => fee <= 17400000000000n); - expect(transferRes).to.be.eql({ + expect(transferRes).to.eql({ tx: { fee: transferRes.tx.fee, nonce: transferRes.tx.nonce, @@ -391,7 +391,7 @@ describe('Aens', () => { assertNotNull(revokeRes.signatures); expect(revokeRes.tx.fee).to.satisfy((fee: bigint) => fee >= 16620000000000n); expect(revokeRes.tx.fee).to.satisfy((fee: bigint) => fee <= 16700000000000n); - expect(revokeRes).to.be.eql({ + expect(revokeRes).to.eql({ tx: { fee: revokeRes.tx.fee, nonce: revokeRes.tx.nonce, diff --git a/test/integration/chain.ts b/test/integration/chain.ts index 4c8567b60d..1b2cb52c0f 100644 --- a/test/integration/chain.ts +++ b/test/integration/chain.ts @@ -28,22 +28,22 @@ describe('Node Chain', () => { new Array(5).fill(undefined).map(async () => aeSdk.getHeight()), ); expect(heights).to.eql(heights.map(() => heights[0])); - expect(getCount()).to.be.equal(1); + expect(getCount()).to.equal(1); }); it('returns height from cache', async () => { const height = await aeSdk.getHeight(); const getCount = bindRequestCounter(aeSdk.api); - expect(await aeSdk.getHeight({ cached: true })).to.be.equal(height); - expect(getCount()).to.be.equal(0); + expect(await aeSdk.getHeight({ cached: true })).to.equal(height); + expect(getCount()).to.equal(0); }); it('returns not cached height if network changed', async () => { const height = await aeSdk.getHeight(); aeSdk.addNode('test-2', new Node(`${aeSdk.api.$host}/`), true); const getCount = bindRequestCounter(aeSdk.api); - expect(await aeSdk.getHeight({ cached: true })).to.be.equal(height); - expect(getCount()).to.be.equal(2); // status, height + expect(await aeSdk.getHeight({ cached: true })).to.equal(height); + expect(getCount()).to.equal(2); // status, height aeSdk.selectNode('test'); aeSdk.pool.delete('test-2'); }); @@ -116,7 +116,7 @@ describe('Node Chain', () => { it('Wait for transaction confirmation', async () => { const res = await aeSdk.spend(1000, aeSdk.address, { confirm: 1 }); assertNotNull(res.blockHeight); - expect((await aeSdk.getHeight()) >= res.blockHeight + 1).to.be.equal(true); + expect((await aeSdk.getHeight()) >= res.blockHeight + 1).to.equal(true); }).timeout(timeoutBlock); it("doesn't make extra requests", async () => { @@ -126,19 +126,19 @@ describe('Node Chain', () => { await aeSdk.getHeight({ cached: false }); getCount = bindRequestCounter(aeSdk.api); hash = (await aeSdk.spend(100, recipient, { waitMined: false, verify: false })).hash; - expect(getCount()).to.be.equal(2); // nonce, post tx + expect(getCount()).to.equal(2); // nonce, post tx await aeSdk.poll(hash); await aeSdk.getHeight({ cached: false }); getCount = bindRequestCounter(aeSdk.api); hash = (await aeSdk.spend(100, recipient, { waitMined: false, verify: false })).hash; - expect(getCount()).to.be.equal(2); // nonce, post tx + expect(getCount()).to.equal(2); // nonce, post tx await aeSdk.poll(hash); await aeSdk.getHeight({ cached: false }); getCount = bindRequestCounter(aeSdk.api); hash = (await aeSdk.spend(100, recipient, { waitMined: false })).hash; - expect(getCount()).to.be.equal(6); // nonce, validator(acc, recipient, height, status), post tx + expect(getCount()).to.equal(6); // nonce, validator(acc, recipient, height, status), post tx await aeSdk.poll(hash); }); @@ -161,7 +161,7 @@ describe('Node Chain', () => { ); transactions.push(...spends.map(({ hash }) => hash)); const txPostCount = accounts.length; - expect(getCount({ exclude: [txPostRetry] })).to.be.equal(txPostCount); + expect(getCount({ exclude: [txPostRetry] })).to.equal(txPostCount); }); it('multiple spends from different accounts', async () => { @@ -183,7 +183,7 @@ describe('Node Chain', () => { s.restore(); transactions.push(...spends.map(({ hash }) => hash)); const txPostCount = accounts.length; - expect(getCount()).to.be.equal(txPostCount); + expect(getCount()).to.equal(txPostCount); }); it('ensure transactions mined', async () => @@ -210,7 +210,7 @@ describe('Node Chain', () => { ), ) ).map((r) => r.decodedResult); - expect(results).to.be.eql(numbers.map((v) => BigInt(v * 100))); - expect(getCount()).to.be.equal(1); + expect(results).to.eql(numbers.map((v) => BigInt(v * 100))); + expect(getCount()).to.equal(1); }); }); diff --git a/test/integration/channel-contracts.ts b/test/integration/channel-contracts.ts index ab38ea34f5..9804c5a263 100644 --- a/test/integration/channel-contracts.ts +++ b/test/integration/channel-contracts.ts @@ -249,7 +249,7 @@ describe('Channel contracts', () => { const hash = buildTxHash(forceTx.tx); const { callInfo } = await aeSdk.api.getTransactionInfoByHash(hash); assertNotNull(callInfo); - expect(callInfo.returnType).to.be.equal('ok'); + expect(callInfo.returnType).to.equal('ok'); }); it('can call a contract and reject', async () => { @@ -317,10 +317,10 @@ describe('Channel contracts', () => { returnType: 'ok', returnValue: result.returnValue, }); - expect(result.returnType).to.be.equal('ok'); - expect( - contract._calldata.decode('Identity', 'getArg', result.returnValue).toString(), - ).to.be.equal('42'); + expect(result.returnType).to.equal('ok'); + expect(contract._calldata.decode('Identity', 'getArg', result.returnValue).toString()).to.equal( + '42', + ); }); it('can call a contract using dry-run', async () => { @@ -341,10 +341,10 @@ describe('Channel contracts', () => { returnType: 'ok', returnValue: result.returnValue, }); - expect(result.returnType).to.be.equal('ok'); - expect( - contract._calldata.decode('Identity', 'getArg', result.returnValue).toString(), - ).to.be.equal('42'); + expect(result.returnType).to.equal('ok'); + expect(contract._calldata.decode('Identity', 'getArg', result.returnValue).toString()).to.equal( + '42', + ); }); it('can clean contract calls', async () => { diff --git a/test/integration/channel-other.ts b/test/integration/channel-other.ts index 0b9884cf0f..359fcff565 100644 --- a/test/integration/channel-other.ts +++ b/test/integration/channel-other.ts @@ -176,9 +176,9 @@ describe('Channel other', () => { }).timeout(timeoutBlock); it('can reconnect a channel without leave', async () => { - expect(initiatorCh.round()).to.be.equal(1); + expect(initiatorCh.round()).to.equal(1); await initiatorCh.update(initiator.address, responder.address, 100, initiatorSign); - expect(initiatorCh.round()).to.be.equal(2); + expect(initiatorCh.round()).to.equal(2); const channelId = initiatorCh.id(); const fsmId = initiatorCh.fsmId(); initiatorCh.disconnect(); @@ -190,18 +190,18 @@ describe('Channel other', () => { existingFsmId: fsmId, }); await waitForChannel(ch, ['open']); - expect(ch.fsmId()).to.be.equal(fsmId); - expect(ch.round()).to.be.equal(2); + expect(ch.fsmId()).to.equal(fsmId); + expect(ch.round()).to.equal(2); const state = await ch.state(); assertNotNull(state.signedTx); - expect(state.signedTx.encodedTx.tag).to.be.equal(Tag.ChannelOffChainTx); + expect(state.signedTx.encodedTx.tag).to.equal(Tag.ChannelOffChainTx); await ch.update(initiator.address, responder.address, 100, initiatorSign); - expect(ch.round()).to.be.equal(3); + expect(ch.round()).to.equal(3); ch.disconnect(); }); it('can post backchannel update', async () => { - expect(responderCh.round()).to.be.equal(1); + expect(responderCh.round()).to.equal(1); initiatorCh.disconnect(); const { accepted } = await responderCh.update( initiator.address, @@ -210,7 +210,7 @@ describe('Channel other', () => { responderSign, ); expect(accepted).to.equal(false); - expect(responderCh.round()).to.be.equal(1); + expect(responderCh.round()).to.equal(1); const result = await responderCh.update( initiator.address, responder.address, @@ -218,7 +218,7 @@ describe('Channel other', () => { async (transaction) => appendSignature(await responderSign(transaction), initiatorSign), ); expect(result.accepted).to.equal(true); - expect(responderCh.round()).to.be.equal(2); + expect(responderCh.round()).to.equal(2); expect(result.signedTx).to.be.a('string'); }); }); diff --git a/test/integration/channel.ts b/test/integration/channel.ts index 84d9d0d6c7..58399cf6e4 100644 --- a/test/integration/channel.ts +++ b/test/integration/channel.ts @@ -135,7 +135,7 @@ describe('Channel', () => { notify(initiatorCh, 'not-existing-method'); const error = await getError; ensureInstanceOf(error, ChannelIncomingMessageError); - expect(error.incomingMessage.error.message).to.be.equal('Method not found'); + expect(error.incomingMessage.error.message).to.equal('Method not found'); expect(() => { throw error.handlerError; }).to.throw(UnknownChannelStateError, 'State Channels FSM entered unknown state'); @@ -229,7 +229,7 @@ describe('Channel', () => { ], }); const tx = unpackTx(initiatorSign.firstCall.args[0]); - expect(tx.tag).to.be.equal(Tag.ChannelOffChainTx); + expect(tx.tag).to.equal(Tag.ChannelOffChainTx); expect(initiatorSign.firstCall.args[1]).to.eql({ updates: [ { @@ -285,8 +285,8 @@ describe('Channel', () => { const params = { accounts: [initiator.address, responder.address] }; const initiatorPoi = await initiatorCh.poi(params); const responderPoi = await responderCh.poi(params); - expect(initiatorPoi).to.be.eql(responderPoi); - expect(initiatorPoi.accounts[0].isEqual(responderPoi.accounts[0])).to.be.equal(true); + expect(initiatorPoi).to.eql(responderPoi); + expect(initiatorPoi.accounts[0].isEqual(responderPoi.accounts[0])).to.equal(true); }); it('can send a message', async () => { @@ -345,8 +345,8 @@ describe('Channel', () => { }); const tx = unpackTx(initiatorSign.firstCall.args[0]); ensureEqual(tx.tag, Tag.ChannelWithdrawTx); - expect(tx.toId).to.be.equal(initiator.address); - expect(tx.amount).to.be.equal(amount.toString()); + expect(tx.toId).to.equal(initiator.address); + expect(tx.amount).to.equal(amount.toString()); }); it('can request a withdraw and reject', async () => { @@ -389,8 +389,8 @@ describe('Channel', () => { }); const tx = unpackTx(initiatorSign.firstCall.args[0]); ensureEqual(tx.tag, Tag.ChannelWithdrawTx); - expect(tx.toId).to.be.equal(initiator.address); - expect(tx.amount).to.be.equal(amount.toString()); + expect(tx.toId).to.equal(initiator.address); + expect(tx.amount).to.equal(amount.toString()); }); it('can abort withdraw sign request', async () => { @@ -451,8 +451,8 @@ describe('Channel', () => { }); const tx = unpackTx(initiatorSign.firstCall.args[0]); ensureEqual(tx.tag, Tag.ChannelDepositTx); - expect(tx.fromId).to.be.equal(initiator.address); - expect(tx.amount).to.be.equal(amount.toString()); + expect(tx.fromId).to.equal(initiator.address); + expect(tx.amount).to.equal(amount.toString()); }); it('can request a deposit and reject', async () => { @@ -485,8 +485,8 @@ describe('Channel', () => { }); const tx = unpackTx(initiatorSign.firstCall.args[0]); ensureEqual(tx.tag, Tag.ChannelDepositTx); - expect(tx.fromId).to.be.equal(initiator.address); - expect(tx.amount).to.be.equal(amount.toString()); + expect(tx.fromId).to.equal(initiator.address); + expect(tx.amount).to.equal(amount.toString()); }); it('can abort deposit sign request', async () => { @@ -520,7 +520,7 @@ describe('Channel', () => { sinon.assert.calledWithExactly(initiatorSign, sinon.match.string); const tx = unpackTx(initiatorSign.firstCall.args[0]); ensureEqual(tx.tag, Tag.ChannelCloseMutualTx); - expect(tx.fromId).to.be.equal(initiator.address); + expect(tx.fromId).to.equal(initiator.address); // TODO: check `initiatorAmountFinal` and `responderAmountFinal` }); @@ -536,7 +536,7 @@ describe('Channel', () => { // https://github.com/aeternity/protocol/blob/d634e7a3f3110657900759b183d0734e61e5803a/node/api/channels_api_usage.md#reestablish it('can reestablish a channel', async () => { - expect(initiatorCh.round()).to.be.equal(2); + expect(initiatorCh.round()).to.equal(2); initiatorCh = await Channel.initialize({ ...sharedParams, ...initiatorParams, @@ -545,11 +545,11 @@ describe('Channel', () => { existingFsmId: initiatorCh.fsmId(), }); await waitForChannel(initiatorCh, ['open']); - expect(initiatorCh.round()).to.be.equal(2); + expect(initiatorCh.round()).to.equal(2); sinon.assert.notCalled(initiatorSignTag); sinon.assert.notCalled(responderSignTag); await initiatorCh.update(initiator.address, responder.address, 100, initiatorSign); - expect(initiatorCh.round()).to.be.equal(3); + expect(initiatorCh.round()).to.equal(3); }); describe('throws errors', () => { diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index 6c5675d99d..c3dce94e0e 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -73,7 +73,7 @@ function testCompiler(compiler: CompilerBase): void { }); it('returns version', async () => { - expect(await compiler.version()).to.be.equal('8.0.0'); + expect(await compiler.version()).to.equal('8.0.0'); }); it('compiles and generates aci by path', async () => { @@ -152,23 +152,23 @@ function testCompiler(compiler: CompilerBase): void { }); it('validates bytecode by path', async () => { - expect(await compiler.validate(inclBytecode, inclSourceCodePath)).to.be.equal(true); - expect(await compiler.validate(testBytecode, inclSourceCodePath)).to.be.equal(false); + expect(await compiler.validate(inclBytecode, inclSourceCodePath)).to.equal(true); + expect(await compiler.validate(testBytecode, inclSourceCodePath)).to.equal(false); const invalidBytecode = `${testBytecode}test` as Encoded.ContractBytearray; - expect(await compiler.validate(invalidBytecode, inclSourceCodePath)).to.be.equal(false); + expect(await compiler.validate(invalidBytecode, inclSourceCodePath)).to.equal(false); }); it('validates bytecode by source code', async () => { expect( await compiler.validateBySourceCode(inclBytecode, inclSourceCode, inclFileSystem), - ).to.be.equal(true); + ).to.equal(true); expect( await compiler.validateBySourceCode(testBytecode, inclSourceCode, inclFileSystem), - ).to.be.equal(false); + ).to.equal(false); const invalidBytecode = `${testBytecode}test` as Encoded.ContractBytearray; expect( await compiler.validateBySourceCode(invalidBytecode, inclSourceCode, inclFileSystem), - ).to.be.equal(false); + ).to.equal(false); }); } @@ -184,7 +184,7 @@ describe('CompilerHttp', () => { describe('getFileSystem', () => { it('reads file system', async () => { - expect(await getFileSystem('./test/integration/contracts/Includes.aes')).to.be.eql({ + expect(await getFileSystem('./test/integration/contracts/Includes.aes')).to.eql({ './lib/Library.aes': indent` include"lib/Sublibrary.aes" diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index b339fbf047..c6daacc6db 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -218,12 +218,12 @@ describe('Contract instance', () => { gasLimit: 15000, }); delete aeSdk._options.gasPrice; - expect(testContract.$options.gasPrice).to.be.equal(100); + expect(testContract.$options.gasPrice).to.equal(100); delete testContract.$options.gasPrice; testContract.should.have.property('$compile'); testContract.should.have.property('$call'); testContract.should.have.property('$deploy'); - expect(testContract.$options.ttl).to.be.equal(0); + expect(testContract.$options.ttl).to.equal(0); testContract.$options.should.have.property('sourceCode'); testContract.$options.should.have.property('bytecode'); assertNotNull(testContract.$options.fileSystem); @@ -266,12 +266,12 @@ describe('Contract instance', () => { }); expect(deployInfo.address).to.satisfy((b: string) => b.startsWith('ct_')); assertNotNull(deployInfo.txData.tx); - expect(deployInfo.txData.tx.gas).to.be.equal(16000); - expect(deployInfo.txData.tx.amount).to.be.equal(42n); + expect(deployInfo.txData.tx.gas).to.equal(16000); + expect(deployInfo.txData.tx.amount).to.equal(42n); assertNotNull(deployInfo.result); - expect(deployInfo.result.gasUsed).to.be.equal(209); - expect(deployInfo.result.gasPrice).to.be.equal(1000000000n); - expect(deployInfo.txData.tx.deposit).to.be.equal(0n); + expect(deployInfo.result.gasUsed).to.equal(209); + expect(deployInfo.result.gasPrice).to.equal(1000000000n); + expect(deployInfo.txData.tx.deposit).to.equal(0n); expect(testContract.$options.bytecode).to.satisfy((b: string) => b.startsWith('cb_')); assertNotNull(deployInfo.address); testContractAddress = deployInfo.address; @@ -287,22 +287,22 @@ describe('Contract instance', () => { it('calls', async () => { const res = await testContract.intFn(2); - expect(res.decodedResult).to.be.equal(2n); + expect(res.decodedResult).to.equal(2n); ensureEqual(res.tx.tag, Tag.ContractCallTx); - expect(res.tx.fee).to.be.equal('182000000000000'); + expect(res.tx.fee).to.equal('182000000000000'); }); it('calls with fallback account if onAccount is not provided', async () => { const account = testContract.$options.onAccount; delete testContract.$options.onAccount; const res = await testContract.intFn(2); - expect(res.decodedResult).to.be.equal(2n); + expect(res.decodedResult).to.equal(2n); testContract.$options.onAccount = account; }); it('calls on chain', async () => { const res = await testContract.intFn(2, { callStatic: false }); - expect(res.decodedResult).to.be.equal(2n); + expect(res.decodedResult).to.equal(2n); ensureEqual(res.tx.tag, Tag.SignedTx); ensureEqual(res.tx.encodedTx.tag, Tag.ContractCallTx); expect(res.tx.encodedTx.fee).to.satisfy((fee: string) => +fee >= 182000000000000); @@ -316,7 +316,7 @@ describe('Contract instance', () => { }); await aeSdk.poll(txHash); const { decodedResult } = await testContract.$getCallResultByTxHash(txHash, 'stringFn'); - expect(decodedResult).to.be.equal('test'); + expect(decodedResult).to.equal('test'); }); it('calls with correct nonce if transaction stuck in mempool', async () => { @@ -328,7 +328,7 @@ describe('Contract instance', () => { sdk.getAccount(sdk.address).then((res) => res.nonce), sdk.api.getAccountNextNonce(sdk.address).then((res) => res.nextNonce), ]); - expect(nonce + 2).to.be.equal(nextNonce); + expect(nonce + 2).to.equal(nextNonce); const contract = await Contract.initialize({ ...sdk.getContext(), @@ -349,11 +349,11 @@ describe('Contract instance', () => { const [address1, address2] = aeSdk.addresses(); let { result } = await testContract.intFn(2); assertNotNull(result); - expect(result.callerId).to.be.equal(address1); + expect(result.callerId).to.equal(address1); aeSdk.selectAccount(address2); result = (await testContract.intFn(2)).result; assertNotNull(result); - expect(result.callerId).to.be.equal(address2); + expect(result.callerId).to.equal(address2); aeSdk.selectAccount(address1); }); @@ -407,7 +407,7 @@ describe('Contract instance', () => { aci: testContractAci, address: testContract.$options.address, }); - expect((await contract.intFn(3)).decodedResult).to.be.equal(3n); + expect((await contract.intFn(3)).decodedResult).to.equal(3n); }); it("fails if aci doesn't match called contract", async () => { @@ -431,7 +431,7 @@ describe('Contract instance', () => { aci: testContractAci, }); await contract.$deploy(['test', 1]); - expect((await contract.intFn(3)).decodedResult).to.be.equal(3n); + expect((await contract.intFn(3)).decodedResult).to.equal(3n); }); it('supports contract interfaces polymorphism', async () => { @@ -462,8 +462,8 @@ describe('Contract instance', () => { }); await contract.$deploy([]); - expect((await contract.soundByDog()).decodedResult).to.be.equal('animal sound: bark'); - expect((await contract.soundByCat()).decodedResult).to.be.equal('animal sound: meow'); + expect((await contract.soundByDog()).decodedResult).to.equal('animal sound: bark'); + expect((await contract.soundByCat()).decodedResult).to.equal('animal sound: meow'); }); const intHolderSourceCode = indent` @@ -491,16 +491,16 @@ describe('Contract instance', () => { }); await factory.$deploy([]); const { decodedResult: address, result } = await factory.new(42); - expect(isAddressValid(address, Encoding.ContractAddress)).to.be.equal(true); + expect(isAddressValid(address, Encoding.ContractAddress)).to.equal(true); assertNotNull(result); - expect(result.gasUsed).to.be.equal(15567); + expect(result.gasUsed).to.equal(15567); const contract = await Contract.initialize({ ...aeSdk.getContext(), sourceCode: intHolderSourceCode, address, }); - expect((await contract.get()).decodedResult).to.be.equal(42n); + expect((await contract.get()).decodedResult).to.equal(42n); }); it('can clone a contract via factory call', async () => { @@ -510,7 +510,7 @@ describe('Contract instance', () => { }); const { address: templateAddress } = await templateAuction.$deploy([43]); assertNotNull(templateAddress); - expect((await templateAuction.get()).decodedResult).to.be.equal(43n); + expect((await templateAuction.get()).decodedResult).to.equal(43n); const market = await Contract.initialize<{ new: (template: Encoded.ContractAddress, value: number) => Encoded.ContractAddress; @@ -530,16 +530,16 @@ describe('Contract instance', () => { }); await market.$deploy([]); const { decodedResult: address, result } = await market.new(templateAddress, 44); - expect(isAddressValid(address, Encoding.ContractAddress)).to.be.equal(true); + expect(isAddressValid(address, Encoding.ContractAddress)).to.equal(true); assertNotNull(result); - expect(result.gasUsed).to.be.equal(10097); + expect(result.gasUsed).to.equal(10097); const auction = await Contract.initialize({ ...aeSdk.getContext(), sourceCode: intHolderSourceCode, address, }); - expect((await auction.get()).decodedResult).to.be.equal(44n); + expect((await auction.get()).decodedResult).to.equal(44n); }); it('accepts matching source code with enabled validation', async () => @@ -593,7 +593,7 @@ describe('Contract instance', () => { assertNotNull(result); result.should.have.property('gasUsed'); result.should.have.property('returnType'); - expect(decodedResult).to.be.equal(undefined); + expect(decodedResult).to.equal(undefined); }); it('dry-runs init function on specific account', async () => { @@ -637,7 +637,7 @@ describe('Contract instance', () => { InvalidTxError, 'Transaction verification errors: Recipient account is not payable', ); - expect(error.validation).to.be.eql([ + expect(error.validation).to.eql([ { message: 'Recipient account is not payable', key: 'RecipientAccountNotPayable', @@ -657,7 +657,7 @@ describe('Contract instance', () => { const { address } = await contract.$deploy([]); assertNotNull(address); await aeSdk.spend(42, address); - expect(await aeSdk.getBalance(address)).to.be.equal('42'); + expect(await aeSdk.getBalance(address)).to.equal('42'); }); it('calls on specific account', async () => { @@ -690,7 +690,7 @@ describe('Contract instance', () => { expect(contract1._aci).to.be.an('array'); expect(contract1.$options).to.be.an('object'); await contract1.$deploy([]); - expect((await contract1.getArg(42)).decodedResult).to.be.equal(42n); + expect((await contract1.getArg(42)).decodedResult).to.equal(42n); const contract2 = await TestContract.initialize({ ...aeSdk.getContext(), @@ -698,7 +698,7 @@ describe('Contract instance', () => { }); expect(contract2._aci).to.be.an('array'); expect(contract2.$options).to.be.an('object'); - expect((await contract2.getArg(42)).decodedResult).to.be.equal(42n); + expect((await contract2.getArg(42)).decodedResult).to.equal(42n); }); describe('Gas', () => { @@ -719,8 +719,8 @@ describe('Contract instance', () => { } = await contract.$deploy(['test', 42]); assertNotNull(tx); assertNotNull(result); - expect(result.gasUsed).to.be.equal(160); - expect(tx.gas).to.be.equal(200); + expect(result.gasUsed).to.equal(160); + expect(tx.gas).to.equal(200); }); it('overrides gas through Contract options for contract deployments', async () => { @@ -736,8 +736,8 @@ describe('Contract instance', () => { } = await ct.$deploy(['test', 42]); assertNotNull(tx); assertNotNull(result); - expect(result.gasUsed).to.be.equal(160); - expect(tx.gas).to.be.equal(300); + expect(result.gasUsed).to.equal(160); + expect(tx.gas).to.equal(300); }); it('estimates gas by default for contract calls', async () => { @@ -747,8 +747,8 @@ describe('Contract instance', () => { } = await contract.setKey(2); assertNotNull(tx); assertNotNull(result); - expect(result.gasUsed).to.be.equal(61); - expect(tx.gas).to.be.equal(76); + expect(result.gasUsed).to.equal(61); + expect(tx.gas).to.equal(76); }); it('overrides gas through options for contract calls', async () => { @@ -758,8 +758,8 @@ describe('Contract instance', () => { } = await contract.setKey(3, { gasLimit: 100 }); assertNotNull(tx); assertNotNull(result); - expect(result.gasUsed).to.be.equal(61); - expect(tx.gas).to.be.equal(100); + expect(result.gasUsed).to.equal(61); + expect(tx.gas).to.equal(100); }); it('runs out of gasLimit with correct message', async () => { @@ -783,7 +783,7 @@ describe('Contract instance', () => { const { tx } = await contract.intFn(4); ensureEqual(tx.tag, Tag.ContractCallTx); const { gasLimit } = tx; - expect(gasLimit).to.be.equal(5817980); + expect(gasLimit).to.equal(5817980); await expect(contract.intFn(4, { gasLimit: gasLimit + 1 })).to.be.rejectedWith( IllegalArgumentError, 'Gas limit 5817981 must be less or equal to 58', @@ -846,7 +846,7 @@ describe('Contract instance', () => { }); it('decodes events', () => { - expect(eventResult.decodedEvents).to.be.eql([ + expect(eventResult.decodedEvents).to.eql([ { name: 'AnotherEvent2', args: [true, 'This is not indexed', 1n], @@ -886,11 +886,11 @@ describe('Contract instance', () => { assertNotNull(eventResult.decodedEvents); const events = [...eventResult.decodedEvents]; events.splice(1, 1); - expect(deployResult.decodedEvents).to.be.eql(events); + expect(deployResult.decodedEvents).to.eql(events); }); it('decodes events using decodeEvents', () => { - expect(contract.$decodeEvents(eventResultLog)).to.be.eql(eventResult.decodedEvents); + expect(contract.$decodeEvents(eventResultLog)).to.eql(eventResult.decodedEvents); }); it("throws error if can't find event definition", () => { @@ -907,7 +907,7 @@ describe('Contract instance', () => { it('omits events without definition using omitUnknown option', () => { const event = eventResultLog[0]; event.topics[0] = BigInt(event.topics[0].toString().replace('0', '1')); - expect(contract.$decodeEvents([event], { omitUnknown: true })).to.be.eql([]); + expect(contract.$decodeEvents([event], { omitUnknown: true })).to.eql([]); }); const getDuplicateLog = (eventName: string): ContractCallObject['log'] => { @@ -935,7 +935,7 @@ describe('Contract instance', () => { contract.$decodeEvents(getDuplicateLog('Duplicate'), { contractAddressToName: { [remoteContract.$options.address ?? '']: 'RemoteI' }, }), - ).to.be.eql([ + ).to.eql([ { name: 'Duplicate', args: [0n], @@ -948,7 +948,7 @@ describe('Contract instance', () => { }); it("don't throws error if found multiple event definitions with the same type", () => { - expect(contract.$decodeEvents(getDuplicateLog('DuplicateSameType'))).to.be.eql([ + expect(contract.$decodeEvents(getDuplicateLog('DuplicateSameType'))).to.eql([ { name: 'DuplicateSameType', args: [0n], @@ -969,7 +969,7 @@ describe('Contract instance', () => { address: remoteContract.$options.address, }); const result = await c.emitEvents(false, { omitUnknown: true }); - expect(result.decodedEvents).to.be.eql([]); + expect(result.decodedEvents).to.eql([]); }); }); @@ -983,7 +983,7 @@ describe('Contract instance', () => { it('Valid', async () => { const { decodedResult } = await testContract.unitFn([]); - expect(decodedResult).to.be.eql([]); + expect(decodedResult).to.eql([]); }); }); @@ -996,18 +996,18 @@ describe('Contract instance', () => { it('Valid', async () => { const { decodedResult } = await testContract.intFn(1); - expect(decodedResult).to.be.equal(1n); + expect(decodedResult).to.equal(1n); }); const unsafeInt = BigInt(`${Number.MAX_SAFE_INTEGER.toString()}0`); it('Supports unsafe integer', async () => { const { decodedResult } = await testContract.intFn(unsafeInt); - expect(decodedResult).to.be.equal(unsafeInt); + expect(decodedResult).to.equal(unsafeInt); }); it('Supports BigNumber', async () => { const { decodedResult } = await testContract.intFn(new BigNumber(unsafeInt.toString())); - expect(decodedResult).to.be.equal(unsafeInt); + expect(decodedResult).to.equal(unsafeInt); }); }); @@ -1209,7 +1209,7 @@ describe('Contract instance', () => { it('Set None Option Value(Cast from JS value/Convert to JS)', async () => { const optionRes = await testContract.intOption(null); - expect(optionRes.decodedResult).to.be.equal(undefined); + expect(optionRes.decodedResult).to.equal(undefined); }); it('Invalid option type', async () => { @@ -1336,8 +1336,8 @@ describe('Contract instance', () => { const { decodedResult: hashAsHex } = await testContract.bytesAnySizeFn( decoded.toString('hex'), ); - expect(hashAsBuffer).to.be.eql(decoded); - expect(hashAsHex).to.be.eql(decoded); + expect(hashAsBuffer).to.eql(decoded); + expect(hashAsHex).to.eql(decoded); }); }); @@ -1356,7 +1356,7 @@ describe('Contract instance', () => { (await testContract.bitsFn(value)).decodedResult, ]), ) - ).forEach(([v1, v2]) => expect(v2).to.be.equal(BigInt(v1))); + ).forEach(([v1, v2]) => expect(v2).to.equal(BigInt(v1))); }); }); @@ -1369,7 +1369,7 @@ describe('Contract instance', () => { it('Valid', async () => { const value: ChainTtl = { FixedTTL: [50n] }; - expect((await testContract.chainTtlFn(value)).decodedResult).to.be.eql(value); + expect((await testContract.chainTtlFn(value)).decodedResult).to.eql(value); }); }); @@ -1396,7 +1396,7 @@ describe('Contract instance', () => { ]), ], }; - expect((await testContract.aensV2Name(value)).decodedResult).to.be.eql(value); + expect((await testContract.aensV2Name(value)).decodedResult).to.eql(value); }); }); }); @@ -1404,16 +1404,14 @@ describe('Contract instance', () => { describe('Call contract', () => { it('Call contract using using js type arguments', async () => { const res = await testContract.listFn([1, 2]); - expect(res.decodedResult).to.be.eql([1n, 2n]); + expect(res.decodedResult).to.eql([1n, 2n]); }); it('Call contract with contract type argument', async () => { const result = await testContract.approve( 'ct_AUUhhVZ9de4SbeRk8ekos4vZJwMJohwW5X8KQjBMUVduUmoUh', ); - expect(result.decodedResult).to.be.equal( - 'ct_AUUhhVZ9de4SbeRk8ekos4vZJwMJohwW5X8KQjBMUVduUmoUh', - ); + expect(result.decodedResult).to.equal('ct_AUUhhVZ9de4SbeRk8ekos4vZJwMJohwW5X8KQjBMUVduUmoUh'); }); }); }); diff --git a/test/integration/contract.ts b/test/integration/contract.ts index 1cc863a42e..fda25e5f33 100644 --- a/test/integration/contract.ts +++ b/test/integration/contract.ts @@ -71,7 +71,7 @@ describe('Contract', () => { await signContract.$deploy([]); const data = Buffer.from(new Array(32).fill(0).map((_, idx) => idx ** 2)); const signature = await aeSdk.sign(data); - expect((await signContract.verify(data, aeSdk.address, signature)).decodedResult).to.be.equal( + expect((await signContract.verify(data, aeSdk.address, signature)).decodedResult).to.equal( true, ); }); @@ -110,13 +110,13 @@ describe('Contract', () => { await Promise.all( ['Hello', 'H'.repeat(127)].map(async (message) => { - expect((await signContract.message_to_hash(message)).decodedResult).to.be.eql( + expect((await signContract.message_to_hash(message)).decodedResult).to.eql( messageToHash(message), ); const signature = await aeSdk.signMessage(message); expect( (await signContract.verify(message, aeSdk.address, signature)).decodedResult, - ).to.be.equal(true); + ).to.equal(true); }), ); }); @@ -128,13 +128,13 @@ describe('Contract', () => { identityContract.$options.onAccount = onAccount; deployed = await identityContract.$deploy([]); if (deployed?.result?.callerId == null) throw new UnexpectedTsError(); - expect(deployed.result.callerId).to.be.equal(onAccount.address); + expect(deployed.result.callerId).to.equal(onAccount.address); let { result } = await identityContract.getArg(42, { callStatic: true }); assertNotNull(result); - expect(result.callerId).to.be.equal(onAccount.address); + expect(result.callerId).to.equal(onAccount.address); result = (await identityContract.getArg(42, { callStatic: false })).result; assertNotNull(result); - expect(result.callerId).to.be.equal(onAccount.address); + expect(result.callerId).to.equal(onAccount.address); identityContract.$options.onAccount = accountBefore; }); @@ -194,7 +194,7 @@ describe('Contract', () => { }); const { result } = await contract.getArg(42); assertNotNull(result); - expect(result.callerId).to.be.equal(DRY_RUN_ACCOUNT.pub); + expect(result.callerId).to.equal(DRY_RUN_ACCOUNT.pub); }); it('Dry-run at specific height', async () => { @@ -239,17 +239,17 @@ describe('Contract', () => { const deployInfo = await identityContract.$deploy([], { waitMined: false }); assertNotNull(deployInfo.transaction); await aeSdk.poll(deployInfo.transaction); - expect(deployInfo.result).to.be.equal(undefined); + expect(deployInfo.result).to.equal(undefined); expect(deployInfo.txData).to.not.be.equal(undefined); const result = await identityContract.getArg(42, { callStatic: false, waitMined: false }); - expect(result.result).to.be.equal(undefined); + expect(result.result).to.equal(undefined); expect(result.txData).to.not.be.equal(undefined); await aeSdk.poll(result.hash as Encoded.TxHash); }); it('calls deployed contracts static', async () => { const result = await identityContract.getArg(42, { callStatic: true }); - expect(result.decodedResult).to.be.equal(42n); + expect(result.decodedResult).to.equal(42n); }); it('initializes contract state', async () => { @@ -266,7 +266,7 @@ describe('Contract', () => { }); const data = 'Hello World!'; await contract.$deploy([data]); - expect((await contract.retrieve()).decodedResult).to.be.equal(data); + expect((await contract.retrieve()).decodedResult).to.equal(data); }); describe('Namespaces', () => { @@ -306,10 +306,8 @@ describe('Contract', () => { }); it('Can call contract with external deps', async () => { - expect((await contract.sumNumbers(1, 2, { callStatic: false })).decodedResult).to.be.equal( - 3n, - ); - expect((await contract.sumNumbers(1, 2, { callStatic: true })).decodedResult).to.be.equal(3n); + expect((await contract.sumNumbers(1, 2, { callStatic: false })).decodedResult).to.equal(3n); + expect((await contract.sumNumbers(1, 2, { callStatic: true })).decodedResult).to.equal(3n); }); }); }); diff --git a/test/integration/delegation.ts b/test/integration/delegation.ts index db5fd1bc05..61571163b9 100644 --- a/test/integration/delegation.ts +++ b/test/integration/delegation.ts @@ -119,7 +119,7 @@ contract DelegateTest = decode(preclaimSig), ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); delegationSignature = await aeSdk.signDelegation( packDelegation({ tag: DelegationTag.AensName, @@ -140,7 +140,7 @@ contract DelegateTest = decode(delegationSignature), ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); }).timeout(timeoutBlock); it('updates', async () => { @@ -153,8 +153,8 @@ contract DelegateTest = decode(delegationSignature), ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); - expect((await aeSdk.api.getNameEntryByName(name)).pointers).to.be.eql([ + expect(result.returnType).to.equal('ok'); + expect((await aeSdk.api.getNameEntryByName(name)).pointers).to.eql([ { key: 'oracle', id: newOwner.replace('ak', 'ok'), @@ -168,7 +168,7 @@ contract DelegateTest = it('updates with raw pointer', async () => { const pointee: Pointee = { 'AENSv2.DataPt': [dataPt] }; await contract.signedUpdate(owner, name, 'test key', pointee, decode(delegationSignature)); - expect((await aeSdk.api.getNameEntryByName(name)).pointers[0]).to.be.eql({ + expect((await aeSdk.api.getNameEntryByName(name)).pointers[0]).to.eql({ key: 'test key', id: encode(dataPt, Encoding.Bytearray), encodedKey: 'ba_dGVzdCBrZXk//Xo5', @@ -179,7 +179,7 @@ contract DelegateTest = const nameEntry = (await contract.getName(name)).decodedResult['AENSv2.Name']; const ttl = nameEntry[1].FixedTTL[0]; expect(ttl).to.be.a('bigint'); - expect(nameEntry).to.be.eql([ + expect(nameEntry).to.eql([ owner, { FixedTTL: [ttl] }, new Map([ @@ -197,7 +197,7 @@ contract DelegateTest = decode(delegationSignature), ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); }); it('revokes', async () => { @@ -212,7 +212,7 @@ contract DelegateTest = ); const { result } = await contract.signedRevoke(newOwner, name, decode(revokeSig)); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); await expect(aeSdk.api.getNameEntryByName(name)).to.be.rejectedWith(Error); }); @@ -240,7 +240,7 @@ contract DelegateTest = const nameEntry = (await contract.getName(n)).decodedResult['AENSv2.Name']; const ttl = nameEntry[1].FixedTTL[0]; expect(ttl).to.be.a('bigint'); - expect(nameEntry).to.be.eql([ + expect(nameEntry).to.eql([ owner, { FixedTTL: [ttl] }, new Map([['oracle', { 'AENSv2.OraclePt': [newOwner] }]]), @@ -266,7 +266,7 @@ contract DelegateTest = ); const { result } = await contract.signedClaim(aeSdk.address, n, 0, nameFee, decode(dlgSig)); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); }); }); @@ -347,7 +347,7 @@ contract DelegateTest = ttl, ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); }); it('extends', async () => { @@ -358,9 +358,9 @@ contract DelegateTest = ttl, ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); const state = await oracle.getState(); - expect(state.ttl).to.be.equal(prevState.ttl + 50); + expect(state.ttl).to.equal(prevState.ttl + 50); }); it('creates query', async () => { @@ -374,9 +374,9 @@ contract DelegateTest = amount: 5 * queryFee, }); assertNotNull(query.result); - expect(query.result.returnType).to.be.equal('ok'); + expect(query.result.returnType).to.equal('ok'); queryObject = await oracle.getQuery(query.decodedResult); - expect(queryObject.decodedQuery).to.be.equal(q); + expect(queryObject.decodedQuery).to.equal(q); }); it('responds to query', async () => { @@ -396,9 +396,9 @@ contract DelegateTest = r, ); assertNotNull(result); - expect(result.returnType).to.be.equal('ok'); + expect(result.returnType).to.equal('ok'); const queryObject2 = await oracle.getQuery(queryObject.id); - expect(queryObject2.decodedResponse).to.be.equal(r); + expect(queryObject2.decodedResponse).to.equal(r); }); }); }); diff --git a/test/integration/node.ts b/test/integration/node.ts index 10ac86d78f..d5ee96b39c 100644 --- a/test/integration/node.ts +++ b/test/integration/node.ts @@ -67,7 +67,7 @@ describe('Node client', () => { const getCount = bindRequestCounter(node); await node.getAccountByPubkey(address).catch(() => {}); - expect(getCount()).to.be.equal(requestCount); + expect(getCount()).to.equal(requestCount); }, Promise.resolve())); it('throws exception if unsupported protocol', async () => { @@ -129,7 +129,7 @@ describe('Node client', () => { expect(example); const actual = await node.getRecentGasPrices(); - expect(actual).to.be.eql( + expect(actual).to.eql( [1, 5, 15, 60].map((minutes, idx) => { const { minGasPrice, utilization } = actual[idx]; return { minGasPrice, minutes, utilization }; @@ -139,7 +139,7 @@ describe('Node client', () => { it('returns time as Date', async () => { const block = await node.getTopHeader(); - expect(block.time).to.be.instanceOf(Date); + expect(block.time).to.be.an.instanceOf(Date); expect(block.time.getFullYear()).to.be.within(2024, 2030); }); @@ -178,10 +178,10 @@ describe('Node client', () => { ], }); const activeNode = await nodes.getNodeInfo(); - expect(activeNode.name).to.be.equal('first'); + expect(activeNode.name).to.equal('first'); nodes.selectNode('second'); const secondNodeInfo = await nodes.getNodeInfo(); - expect(secondNodeInfo.name).to.be.equal('second'); + expect(secondNodeInfo.name).to.equal('second'); }); it('Fail on undefined node', async () => { diff --git a/test/integration/oracle.ts b/test/integration/oracle.ts index d1a5eb961a..fa5ea8ec30 100644 --- a/test/integration/oracle.ts +++ b/test/integration/oracle.ts @@ -26,12 +26,12 @@ describe('Oracle', () => { aeSdk = await getSdk(3); const expectedOracleId = encode(decode(aeSdk.address), Encoding.OracleAddress); oracle = new Oracle(aeSdk.accounts[aeSdk.address], aeSdk.getContext()); - expect(oracle.address).to.be.equal(expectedOracleId); + expect(oracle.address).to.equal(expectedOracleId); oracleClient = new OracleClient(oracle.address, { ...aeSdk.getContext(), onAccount: aeSdk.accounts[aeSdk.addresses()[1]], }); - expect(oracleClient.address).to.be.equal(expectedOracleId); + expect(oracleClient.address).to.equal(expectedOracleId); }); describe('Oracle', () => { @@ -44,14 +44,14 @@ describe('Oracle', () => { const oracleState = await oracle.getState(); const ttl = height + 5000; expect(oracleState.ttl).to.be.within(ttl, ttl + 4); - expect(oracleState.id).to.be.equal(oracle.address); + expect(oracleState.id).to.equal(oracle.address); }); it('extends TTL', async () => { const { ttl: ttlBefore } = await oracle.getState(); await oracle.extendTtl({ oracleTtlType: ORACLE_TTL_TYPES.delta, oracleTtlValue: 7450 }); const { ttl } = await oracle.getState(); - expect(ttl).to.be.equal(ttlBefore + 7450); + expect(ttl).to.equal(ttlBefore + 7450); }); async function pollNQueries( @@ -99,11 +99,9 @@ describe('Oracle', () => { await oracle.respondToQuery(queryId, queryResponse); const query = await aeSdk.api.getOracleQueryByPubkeyAndQueryId(oracle.address, queryId); - expect(decode(query.response as Encoded.OracleResponse).toString()).to.be.equal( - queryResponse, - ); + expect(decode(query.response as Encoded.OracleResponse).toString()).to.equal(queryResponse); const response = await oracleClient.pollForResponse(queryId); - expect(response).to.be.equal(queryResponse); + expect(response).to.equal(queryResponse); }); it('handles query', async () => { @@ -111,7 +109,7 @@ describe('Oracle', () => { JSON.stringify({ ...JSON.parse(queryEntry.decodedQuery), response: true }), ); const response = await oracleClient.query('{"test": 42}'); - expect(response).to.be.equal('{"test":42,"response":true}'); + expect(response).to.equal('{"test":42,"response":true}'); await stop(); }); @@ -142,7 +140,7 @@ describe('Oracle', () => { const stop = oracle.handleQueries(({ decodedQuery }) => `response to ${decodedQuery}`); try { const res = await Promise.all(responsePromises); - expect(res).to.be.eql(['response to foo', 'response to bar']); + expect(res).to.eql(['response to foo', 'response to bar']); } finally { await stop(); } @@ -159,7 +157,7 @@ describe('Oracle', () => { await Promise.all( responsePromises.map(async (promise) => promise.then((r) => res.push(r))), ); - expect(res).to.be.eql(['250', '400', '500']); + expect(res).to.eql(['250', '400', '500']); } finally { await stop(); } @@ -170,7 +168,7 @@ describe('Oracle', () => { it('posts query', async () => { const query = await oracleClient.postQuery('{"city": "Berlin"}'); assertNotNull(query.tx?.query); - expect(query.tx.query).to.be.equal('{"city": "Berlin"}'); + expect(query.tx.query).to.equal('{"city": "Berlin"}'); }); it('polls for response for query without response', async () => { @@ -195,7 +193,7 @@ describe('Oracle', () => { }); const response = await oracleClient.query('{"city": "Berlin"}'); stopPolling(); - expect(response).to.be.equal(queryResponse); + expect(response).to.equal(queryResponse); }); }); @@ -215,13 +213,13 @@ describe('Oracle', () => { it('Post Oracle Query without query fee', async () => { const query = await oracleClient.postQuery('{"city": "Berlin"}'); assertNotNull(query.tx?.queryFee); - expect(query.tx.queryFee).to.be.equal(0n); + expect(query.tx.queryFee).to.equal(0n); }); it('Post Oracle Query with registered query fee', async () => { const query = await oracleWithFeeClient.postQuery('{"city": "Berlin"}'); assertNotNull(query.tx?.queryFee); - expect(query.tx.queryFee).to.be.equal(queryFee); + expect(query.tx.queryFee).to.equal(queryFee); }); it('Post Oracle Query with custom query fee', async () => { @@ -229,7 +227,7 @@ describe('Oracle', () => { queryFee: (queryFee + 2000n).toString(), }); assertNotNull(query.tx?.queryFee); - expect(query.tx.queryFee).to.be.equal(queryFee + 2000n); + expect(query.tx.queryFee).to.equal(queryFee + 2000n); }); }); }); diff --git a/test/integration/paying-for.ts b/test/integration/paying-for.ts index 746973f788..12b70c4535 100644 --- a/test/integration/paying-for.ts +++ b/test/integration/paying-for.ts @@ -79,7 +79,7 @@ describe('Paying for transaction of another account', () => { sourceCode, address, }); - expect((await payingContract.getValue()).decodedResult).to.be.equal(42n); + expect((await payingContract.getValue()).decodedResult).to.equal(42n); }); it('pays for contract call', async () => { @@ -90,6 +90,6 @@ describe('Paying for transaction of another account', () => { }); const { rawTx: contractCallTx } = await contract.setValue(43); await aeSdk.payForTransaction(contractCallTx); - expect((await payingContract.getValue()).decodedResult).to.be.equal(43n); + expect((await payingContract.getValue()).decodedResult).to.equal(43n); }); }); diff --git a/test/integration/rpc.ts b/test/integration/rpc.ts index a88e319459..ae6f61ba9b 100644 --- a/test/integration/rpc.ts +++ b/test/integration/rpc.ts @@ -147,7 +147,7 @@ describe('Aepp<->Wallet', () => { aci: contract._aci, address: contract.$options.address, }); - expect((await contractAepp.getArg(42)).decodedResult).to.be.equal(42n); + expect((await contractAepp.getArg(42)).decodedResult).to.equal(42n); }); it('Fail on not connected', async () => { @@ -214,7 +214,7 @@ describe('Aepp<->Wallet', () => { 'The peer failed to execute your request due to unknown error', ); wallet.onAskAccounts = () => {}; - expect(await aepp.askAddresses()).to.be.eql(wallet.addresses()); + expect(await aepp.askAddresses()).to.eql(wallet.addresses()); }); it('Try to sign and send transaction to wallet without subscription', async () => { @@ -242,9 +242,9 @@ describe('Aepp<->Wallet', () => { let checkPromise; wallet.onSubscription = (id, params, origin) => { checkPromise = Promise.resolve().then(() => { - expect(Buffer.from(id, 'base64').length).to.be.equal(8); - expect(params).to.be.eql({ type: 'subscribe', value: 'connected' }); - expect(origin).to.be.equal('http://origin.test'); + expect(Buffer.from(id, 'base64').length).to.equal(8); + expect(params).to.eql({ type: 'subscribe', value: 'connected' }); + expect(origin).to.equal('http://origin.test'); }); }; await aepp.subscribeAddress(SUBSCRIPTION_TYPES.subscribe, 'connected'); @@ -274,7 +274,7 @@ describe('Aepp<->Wallet', () => { }); it('Get address: subscribed for accounts', async () => { - expect(aepp.address).to.be.equal(account.address); + expect(aepp.address).to.equal(account.address); }); it('Ask for address: exception in onAskAccounts -> wallet deny', async () => { @@ -290,9 +290,9 @@ describe('Aepp<->Wallet', () => { let checkPromise; wallet.onAskAccounts = (id, params, origin) => { checkPromise = Promise.resolve().then(() => { - expect(Buffer.from(id, 'base64').length).to.be.equal(8); - expect(params).to.be.equal(undefined); - expect(origin).to.be.equal('http://origin.test'); + expect(Buffer.from(id, 'base64').length).to.equal(8); + expect(params).to.equal(undefined); + expect(origin).to.equal('http://origin.test'); }); }; const addressees = await aepp.askAddresses(); @@ -327,7 +327,7 @@ describe('Aepp<->Wallet', () => { await expect(aepp.signTransaction(tx)) .to.be.eventually.rejectedWith('Operation rejected by user') .with.property('code', 4); - expect(origin).to.be.equal('http://origin.test'); + expect(origin).to.equal('http://origin.test'); s.restore(); }); @@ -363,7 +363,7 @@ describe('Aepp<->Wallet', () => { encodedTx, } = unpackedTx; const txWithNetwork = getBufferToSign(buildTx(encodedTx), networkId, innerTx); - expect(verify(txWithNetwork, signature, aepp.address)).to.be.equal(true); + expect(verify(txWithNetwork, signature, aepp.address)).to.equal(true); }); }); @@ -422,14 +422,14 @@ describe('Aepp<->Wallet', () => { await expect(aepp.signMessage('test')) .to.be.eventually.rejectedWith('Operation rejected by user') .with.property('code', 4); - expect(origin).to.be.equal('http://origin.test'); + expect(origin).to.equal('http://origin.test'); s.restore(); }); it('works', async () => { const messageSig = await aepp.signMessage('test'); messageSig.should.be.instanceof(Buffer); - expect(verifyMessage('test', messageSig, aepp.address)).to.be.equal(true); + expect(verifyMessage('test', messageSig, aepp.address)).to.equal(true); }); it('fails with unknown error', async () => { @@ -445,7 +445,7 @@ describe('Aepp<->Wallet', () => { it('signs using specific account', async () => { const onAccount = wallet.addresses()[1]; const messageSig = await aepp.signMessage('test', { onAccount }); - expect(verifyMessage('test', messageSig, onAccount)).to.be.equal(true); + expect(verifyMessage('test', messageSig, onAccount)).to.equal(true); }); }); @@ -469,7 +469,7 @@ describe('Aepp<->Wallet', () => { await expect(aepp.signTypedData(recordData, recordAci)) .to.be.eventually.rejectedWith('Operation rejected by user') .with.property('code', 4); - expect(origin).to.be.equal('http://origin.test'); + expect(origin).to.equal('http://origin.test'); s.restore(); }); @@ -477,7 +477,7 @@ describe('Aepp<->Wallet', () => { const messageSig = await aepp.signTypedData(recordData, recordAci); expect(messageSig).to.satisfy((s: string) => s.startsWith('sg_')); const hash = hashTypedData(recordData, recordAci, {}); - expect(verify(hash, decode(messageSig), aepp.address)).to.be.equal(true); + expect(verify(hash, decode(messageSig), aepp.address)).to.equal(true); }); it('fails with unknown error', async () => { @@ -494,7 +494,7 @@ describe('Aepp<->Wallet', () => { const onAccount = wallet.addresses()[1]; const messageSig = await aepp.signTypedData(recordData, recordAci, { onAccount }); const hash = hashTypedData(recordData, recordAci, {}); - expect(verify(hash, decode(messageSig), onAccount)).to.be.equal(true); + expect(verify(hash, decode(messageSig), onAccount)).to.equal(true); }); }); @@ -510,14 +510,14 @@ describe('Aepp<->Wallet', () => { await expect(aepp.sign(rawData)) .to.be.eventually.rejectedWith('Operation rejected by user') .with.property('code', 4); - expect(origin).to.be.equal('http://origin.test'); + expect(origin).to.equal('http://origin.test'); s.restore(); }); it('works', async () => { const signature = await aepp.sign(rawData); - expect(signature).to.be.instanceOf(Buffer); - expect(verify(rawData, signature, aepp.address)).to.be.equal(true); + expect(signature).to.be.an.instanceOf(Buffer); + expect(verify(rawData, signature, aepp.address)).to.equal(true); }); it('fails with unknown error', async () => { @@ -535,7 +535,7 @@ describe('Aepp<->Wallet', () => { it('signs using specific account', async () => { const onAccount = wallet.addresses()[1]; const signature = await aepp.sign(rawData, { onAccount }); - expect(verify(rawData, signature, onAccount)).to.be.equal(true); + expect(verify(rawData, signature, onAccount)).to.equal(true); }); }); @@ -559,7 +559,7 @@ describe('Aepp<->Wallet', () => { await expect(aepp.signDelegation(getDelegation())) .to.be.eventually.rejectedWith('Operation rejected by user') .with.property('code', 4); - expect(origin).to.be.equal('http://origin.test'); + expect(origin).to.equal('http://origin.test'); sandbox.restore(); }); @@ -615,7 +615,7 @@ describe('Aepp<->Wallet', () => { const payload = { nodeUrl: 'http://example.com' }; await aepp.askToSelectNetwork(payload); wallet.onAskToSelectNetwork = handlerReject; - expect(args.slice(1)).to.be.eql([payload, 'http://origin.test']); + expect(args.slice(1)).to.eql([payload, 'http://origin.test']); }); }); @@ -653,8 +653,8 @@ describe('Aepp<->Wallet', () => { }); wallet.selectAccount(connectedAccount); const { connected, current } = await accountsPromise; - expect(current[connectedAccount]).to.be.eql({}); - expect(Object.keys(connected).includes(connectedAccount)).to.be.equal(false); + expect(current[connectedAccount]).to.eql({}); + expect(Object.keys(connected).includes(connectedAccount)).to.equal(false); }); it('Aepp: receive notification for network update', async () => { @@ -663,7 +663,7 @@ describe('Aepp<->Wallet', () => { wallet.addNode('second_node', node, true); }); message.networkId.should.be.equal(networkId); - expect(wallet.selectedNodeName).to.be.equal('second_node'); + expect(wallet.selectedNodeName).to.equal('second_node'); }); }); @@ -831,7 +831,7 @@ describe('Aepp<->Wallet', () => { message.networkId.should.be.equal(networkId); assertNotNull(message.node); message.node.should.be.an('object'); - expect(wallet.selectedNodeName).to.be.equal('second_node'); + expect(wallet.selectedNodeName).to.equal('second_node'); }); }); }); diff --git a/test/integration/transaction.ts b/test/integration/transaction.ts index e288361bae..0dec9e75fc 100644 --- a/test/integration/transaction.ts +++ b/test/integration/transaction.ts @@ -78,7 +78,7 @@ describe('Transaction', () => { denomination: AE_AMOUNT_FORMATS.AE, }); const spendAettos = await aeSdk.buildTx({ ...params, tag: Tag.SpendTx, amount: 1e18 }); - expect(spendAe).to.be.equal(spendAettos); + expect(spendAe).to.equal(spendAettos); }); describe('gas price from node', () => { @@ -105,7 +105,7 @@ describe('Transaction', () => { onNode: nodeReplaceRecentGasPrices(1000000023n), }); const { fee } = unpackTx(spendTx, Tag.SpendTx); - expect(fee).to.be.equal((16660n * 1010000023n).toString()); + expect(fee).to.equal((16660n * 1010000023n).toString()); }); it('uses min gas price if utilization is low', async () => { @@ -117,7 +117,7 @@ describe('Transaction', () => { onNode: nodeReplaceRecentGasPrices(1000000023n, 60), }); const { fee } = unpackTx(spendTx, Tag.SpendTx); - expect(fee).to.be.equal((16660n * 1000000000n).toString()); + expect(fee).to.equal((16660n * 1000000000n).toString()); }); it('calculates fee in contract call based on gas price', async () => { @@ -132,8 +132,8 @@ describe('Transaction', () => { onNode: nodeReplaceRecentGasPrices(1000000023n), }); const { fee, gasPrice } = unpackTx(spendTx, Tag.ContractCallTx); - expect(fee).to.be.equal((182020n * 1010000023n).toString()); - expect(gasPrice).to.be.equal('1010000023'); + expect(fee).to.equal((182020n * 1010000023n).toString()); + expect(gasPrice).to.equal('1010000023'); }); it('warns if gas price too big', async () => { @@ -145,13 +145,13 @@ describe('Transaction', () => { nonce, onNode: nodeReplaceRecentGasPrices(99900000000000n), }); - expect(s.firstCall.args).to.be.eql([ + expect(s.firstCall.args).to.eql([ 'Estimated gas price 100899000000000 exceeds the maximum safe value for unknown reason. ' + 'It will be limited to 100000000000000. To overcome this restriction provide `gasPrice`/`fee` in options.', ]); s.restore(); const { fee } = unpackTx(spendTx, Tag.SpendTx); - expect(fee).to.be.equal((16660n * 100000000000000n).toString()); + expect(fee).to.equal((16660n * 100000000000000n).toString()); }); }); @@ -401,8 +401,8 @@ describe('Transaction', () => { transactions.forEach(([txName, getExpected, getter]) => it(`build of ${txName} transaction`, async () => { const expected = typeof getExpected === 'function' ? await getExpected() : getExpected; - expect(await getter()).to.be.equal(expected); - expect(buildTx(unpackTx(expected))).to.be.equal(expected); + expect(await getter()).to.equal(expected); + expect(buildTx(unpackTx(expected))).to.equal(expected); }), ); }); diff --git a/test/integration/txVerification.ts b/test/integration/txVerification.ts index fbcb8ae24a..a19badc163 100644 --- a/test/integration/txVerification.ts +++ b/test/integration/txVerification.ts @@ -41,7 +41,7 @@ describe('Verify Transaction', () => { }); const signedTx = await aeSdk.signTransaction(spendTx, { onAccount: MemoryAccount.generate() }); const errors = await verifyTransaction(signedTx, node); - expect(errors.map(({ key }) => key)).to.be.eql(['InvalidSignature', 'ExpiredTTL']); + expect(errors.map(({ key }) => key)).to.eql(['InvalidSignature', 'ExpiredTTL']); }); it.skip('returns NonceHigh error', async () => { @@ -53,7 +53,7 @@ describe('Verify Transaction', () => { nonce: 100, }); const errors = await verifyTransaction(spendTx, node); - expect(errors.map(({ key }) => key)).to.be.eql(['NonceHigh']); + expect(errors.map(({ key }) => key)).to.eql(['NonceHigh']); }); it('verifies transactions before broadcasting', async () => { diff --git a/test/integration/typed-data.ts b/test/integration/typed-data.ts index 1cb6dc857d..c4c4a91741 100644 --- a/test/integration/typed-data.ts +++ b/test/integration/typed-data.ts @@ -10,13 +10,13 @@ import { indent } from '../utils'; describe('typed data', () => { describe('hashJson', () => { it('hashes json', () => { - expect(hashJson({ a: 'test', b: 42 }).toString('base64')).to.be.eql( + expect(hashJson({ a: 'test', b: 42 }).toString('base64')).to.eql( 'EE0l7gg3Xv9K4szSHhK2g24mx5ck1MJHHVCLJscZyEA=', ); }); it('gets the same hash if keys ordered differently', () => { - expect(hashJson({ b: 42, a: 'test' })).to.be.eql(hashJson({ a: 'test', b: 42 })); + expect(hashJson({ b: 42, a: 'test' })).to.eql(hashJson({ a: 'test', b: 42 })); }); }); @@ -40,7 +40,7 @@ describe('typed data', () => { describe('hashDomain', () => { it('hashes', async () => { - expect(hashDomain(domain).toString('base64')).to.be.equal( + expect(hashDomain(domain).toString('base64')).to.equal( '9EfEJsyqTDJMZU0m/t4zXxwUj2Md8bJd1txMjeB7F2k=', ); }); @@ -49,12 +49,12 @@ describe('typed data', () => { describe('hashTypedData', () => { it('hashes int', async () => { const hash = hashTypedData(plainData, plainAci, domain); - expect(hash.toString('base64')).to.be.equal('iGXwY/cT39iSJ6xDCVK9E4WLJzSgggWO2HGUBU/8ZrE='); + expect(hash.toString('base64')).to.equal('iGXwY/cT39iSJ6xDCVK9E4WLJzSgggWO2HGUBU/8ZrE='); }); it('hashes record', async () => { const hash = hashTypedData(recordData, recordAci, domain); - expect(hash.toString('base64')).to.be.equal('T8b2qGpS0d3vEN99ile+ZNZG4FujxaRnXTgsH+sZj8Q='); + expect(hash.toString('base64')).to.equal('T8b2qGpS0d3vEN99ile+ZNZG4FujxaRnXTgsH+sZj8Q='); }); }); @@ -110,12 +110,12 @@ describe('typed data', () => { }); it('gets domain', async () => { - expect((await contract.getDomain()).decodedResult).to.be.eql({ ...domain, version: 2n }); + expect((await contract.getDomain()).decodedResult).to.eql({ ...domain, version: 2n }); }); it('calculates domain hash', async () => { const domainHash = Buffer.from((await contract.getDomainHash()).decodedResult); - expect(domainHash).to.be.eql(hashDomain(domain)); + expect(domainHash).to.eql(hashDomain(domain)); }); const recordType = new TypeResolver().resolveType(recordAci, {}); @@ -126,7 +126,7 @@ describe('typed data', () => { recordType, ); const typedDataHash = Buffer.from((await contract.hashTypedData(43)).decodedResult); - expect(typedDataHash).to.be.eql(hashTypedData(data, recordAci, domain)); + expect(typedDataHash).to.eql(hashTypedData(data, recordAci, domain)); }); it('verifies signature', async () => { @@ -137,12 +137,12 @@ describe('typed data', () => { const signature = await aeSdk.signTypedData(data, recordAci, domain); const signatureDecoded = decode(signature); - expect( - (await contract.verify(46, aeSdk.address, signatureDecoded)).decodedResult, - ).to.be.equal(false); - expect( - (await contract.verify(45, aeSdk.address, signatureDecoded)).decodedResult, - ).to.be.equal(true); + expect((await contract.verify(46, aeSdk.address, signatureDecoded)).decodedResult).to.equal( + false, + ); + expect((await contract.verify(45, aeSdk.address, signatureDecoded)).decodedResult).to.equal( + true, + ); }); }); }); diff --git a/test/integration/~execution-cost.ts b/test/integration/~execution-cost.ts index 1bc59825f0..3ae36956e4 100644 --- a/test/integration/~execution-cost.ts +++ b/test/integration/~execution-cost.ts @@ -92,18 +92,18 @@ describe('Execution cost', () => { params.tag === Tag.PayingForTx && [Tag.ContractCreateTx, Tag.ContractCallTx].includes(params.tx.encodedTx.tag) ) { - expect(balanceDiff).to.be.satisfy((b: bigint) => b < 0n); + expect(balanceDiff).to.satisfy((b: bigint) => b < 0n); } else if (params.tag === Tag.ContractCallTx) { // Can't detect AENS.claim in contract call // TODO: remove after solving https://github.com/aeternity/aeternity/issues/4088 if (balanceDiff === 500000000000001n) return; // Can't detect Oracle.respond reward in contract call if (balanceDiff === -501000n) return; - expect(balanceDiff).to.be.equal(0n); + expect(balanceDiff).to.equal(0n); } else if (params.tag === Tag.SpendTx && params.senderId === params.recipientId) { - expect(balanceDiff).to.be.equal(BigInt(-params.amount)); + expect(balanceDiff).to.equal(BigInt(-params.amount)); } else { - expect(balanceDiff).to.be.equal(0n); + expect(balanceDiff).to.equal(0n); } checkedTags.add(unpackTx(tx, Tag.SignedTx).encodedTx.tag); @@ -111,7 +111,7 @@ describe('Execution cost', () => { ); const formatTags = (arr: Tag[]): string[] => arr.sort((a, b) => a - b).map((t) => Tag[t]); - expect(formatTags(Array.from(checkedTags))).to.be.eql( + expect(formatTags(Array.from(checkedTags))).to.eql( formatTags([ Tag.SpendTx, Tag.NamePreclaimTx, diff --git a/test/unit/ae-sdk.ts b/test/unit/ae-sdk.ts index 66863a6a7c..d10eee6c65 100644 --- a/test/unit/ae-sdk.ts +++ b/test/unit/ae-sdk.ts @@ -6,6 +6,6 @@ import { AeSdk } from '../../src'; describe('AeSdk', () => { it('executes methods without node, compiler, accounts', async () => { const aeSdk = new AeSdk({ _expectedMineRate: 1000 }); - expect(await aeSdk._getPollInterval('key-block')).to.be.equal(333); + expect(await aeSdk._getPollInterval('key-block')).to.equal(333); }); }); diff --git a/test/unit/aens.ts b/test/unit/aens.ts index 3da788154d..32458141f5 100644 --- a/test/unit/aens.ts +++ b/test/unit/aens.ts @@ -374,7 +374,7 @@ describe('AENS utils', () => { it('encodes', () => { tests.forEach(({ unicodeAsHex, punycode }) => { const name = Buffer.from(unicodeAsHex, 'hex').toString(); - expect(nameToPunycode(name)).to.be.equal(punycode); + expect(nameToPunycode(name)).to.equal(punycode); }); }); }); @@ -446,37 +446,37 @@ describe('AENS utils', () => { describe('isAuctionName', () => { it('checks non-auction name', () => { - expect(isAuctionName('1234567890123.chain')).to.be.equal(false); + expect(isAuctionName('1234567890123.chain')).to.equal(false); }); it('checks auction name', () => { - expect(isAuctionName('123456789012.chain')).to.be.equal(true); + expect(isAuctionName('123456789012.chain')).to.equal(true); }); it('checks non-auction unicode name', () => { - expect(isAuctionName('æ23456.chain')).to.be.equal(false); + expect(isAuctionName('æ23456.chain')).to.equal(false); }); it('checks auction unicode name', () => { - expect(isAuctionName('æ2345.chain')).to.be.equal(true); + expect(isAuctionName('æ2345.chain')).to.equal(true); }); }); describe('computeAuctionEndBlock', () => { it('computes for longest auction', () => { - expect(computeAuctionEndBlock('123456789012.chain', 1)).to.be.equal(481); + expect(computeAuctionEndBlock('123456789012.chain', 1)).to.equal(481); }); it('computes for shortest auction', () => { - expect(computeAuctionEndBlock('1.chain', 1)).to.be.equal(29761); + expect(computeAuctionEndBlock('1.chain', 1)).to.equal(29761); }); it('computes for longest unicode auction', () => { - expect(computeAuctionEndBlock('æ2345.chain', 1)).to.be.equal(481); + expect(computeAuctionEndBlock('æ2345.chain', 1)).to.equal(481); }); it('computes for shortest unicode auction', () => { - expect(computeAuctionEndBlock('æ.chain', 1)).to.be.equal(14881); + expect(computeAuctionEndBlock('æ.chain', 1)).to.equal(14881); }); }); }); diff --git a/test/unit/amount-formatter.ts b/test/unit/amount-formatter.ts index aba00ab036..09409482b4 100644 --- a/test/unit/amount-formatter.ts +++ b/test/unit/amount-formatter.ts @@ -15,7 +15,7 @@ describe('Amount Formatter', () => { [1, AE_AMOUNT_FORMATS.AETTOS, '1'], ] as const ).forEach(([v, denomination, e]) => { - expect(toAettos(v, { denomination })).to.be.equal(e); + expect(toAettos(v, { denomination })).to.equal(e); }); }); @@ -29,7 +29,7 @@ describe('Amount Formatter', () => { [1, AE_AMOUNT_FORMATS.AE, 1], ] as const ).forEach(([v, denomination, e]) => { - expect(toAe(v, { denomination })).to.be.equal(e.toString(10)); + expect(toAe(v, { denomination })).to.equal(e.toString(10)); }); }); @@ -67,7 +67,7 @@ describe('Amount Formatter', () => { [1, AE_AMOUNT_FORMATS.NANO_AE, AE_AMOUNT_FORMATS.FEMTO_AE, new BigNumber(1000000)], ] as const ).forEach(([v, denomination, targetDenomination, e]) => { - expect(formatAmount(v, { denomination, targetDenomination })).to.be.equal(e.toString(10)); + expect(formatAmount(v, { denomination, targetDenomination })).to.equal(e.toString(10)); }); }); }); diff --git a/test/unit/bytes.ts b/test/unit/bytes.ts index 90f12ddc70..6e1b5e221e 100644 --- a/test/unit/bytes.ts +++ b/test/unit/bytes.ts @@ -7,19 +7,19 @@ import { snakeToPascal, pascalToSnake } from '../../src/utils/string'; describe('Bytes', () => { it('toBytes: converts null to empty array', () => { - expect(toBytes(null)).to.be.eql(Buffer.from([])); + expect(toBytes(null)).to.eql(Buffer.from([])); }); const testCase = 'test_test-testTest'; it('converts snake to pascal case', () => - expect(snakeToPascal(testCase)).to.be.equal('testTest-testTest')); + expect(snakeToPascal(testCase)).to.equal('testTest-testTest')); it('converts pascal to snake case', () => - expect(pascalToSnake(testCase)).to.be.equal('test_test-test_test')); + expect(pascalToSnake(testCase)).to.equal('test_test-test_test')); it('converts BigNumber to Buffer', () => - expect(toBytes(new BigNumber('1000')).readInt16BE()).to.be.equal(1000)); + expect(toBytes(new BigNumber('1000')).readInt16BE()).to.equal(1000)); it('throws error if BigNumber is not integer', () => expect(() => toBytes(new BigNumber('1.5'))).to.throw( diff --git a/test/unit/crypto.ts b/test/unit/crypto.ts index d557edfa3f..b8fb5585cd 100644 --- a/test/unit/crypto.ts +++ b/test/unit/crypto.ts @@ -37,17 +37,17 @@ const expectedHash = 'th_HZMNgTvEiyKeATpauJjjeWwZcyHapKG8bDgy2S1sCUEUQnbwK'; describe('crypto', () => { describe('isAddressValid', () => { it('rejects invalid encoded data', () => { - expect(isAddressValid('test')).to.be.equal(false); - expect(isAddressValid('th_11111111111111111111111111111111273Yts')).to.be.equal(false); - expect( - isAddressValid('ak_11111111111111111111111111111111273Yts', Encoding.TxHash), - ).to.be.equal(false); + expect(isAddressValid('test')).to.equal(false); + expect(isAddressValid('th_11111111111111111111111111111111273Yts')).to.equal(false); + expect(isAddressValid('ak_11111111111111111111111111111111273Yts', Encoding.TxHash)).to.equal( + false, + ); }); it('returns true for a valid address', () => { const maybeValue: string = 'ak_11111111111111111111111111111111273Yts'; const result = isAddressValid(maybeValue); - expect(result).to.be.equal(true); + expect(result).to.equal(true); // @ts-expect-error `result` is not chcked yet let value: Encoded.AccountAddress = maybeValue; if (result) value = maybeValue; @@ -57,7 +57,7 @@ describe('crypto', () => { it('correctly checks against multiple encodings', () => { const maybeValue: string = 'th_HZMNgTvEiyKeATpauJjjeWwZcyHapKG8bDgy2S1sCUEUQnbwK'; const result = isAddressValid(maybeValue, Encoding.Name, Encoding.TxHash); - expect(result).to.be.equal(true); + expect(result).to.equal(true); // @ts-expect-error `result` is not chcked yet let value: Encoded.Name | Encoded.TxHash = maybeValue; if (result) value = maybeValue; @@ -105,7 +105,7 @@ describe('crypto', () => { it('hashing produces 256 bit blake2b byte buffers', () => { const h = hash('foobar'); expect(h).to.be.a('Uint8Array'); - expect(Buffer.from(h).toString('hex')).to.be.equal( + expect(Buffer.from(h).toString('hex')).to.equal( '93a0e84a8cdd4166267dbe1263e937f08087723ac24e7dcc35b3d5941775ef47', ); }); @@ -119,6 +119,6 @@ describe('crypto', () => { }); it('Can produce tx hash', () => { - expect(buildTxHash(decode(txRaw))).to.be.equal(expectedHash); + expect(buildTxHash(decode(txRaw))).to.equal(expectedHash); }); }); diff --git a/test/unit/delegation.ts b/test/unit/delegation.ts index 615e8d6748..ab72d75f28 100644 --- a/test/unit/delegation.ts +++ b/test/unit/delegation.ts @@ -25,7 +25,7 @@ describe('Delegation signatures', () => { it('signs delegation', async () => { const account = new MemoryAccount('sk_2CuofqWZHrABCrM7GY95YSQn8PyFvKQadnvFnpwhjUnDCFAWmf'); - expect(await account.signDelegation(delegation, { networkId: 'ae_test' })).to.be.equal( + expect(await account.signDelegation(delegation, { networkId: 'ae_test' })).to.equal( 'sg_UHnWENCvSvJPjcwR2rW82btPvDoDqPvDnn8TsXkoQSNoMHEeT1D8YkAwJQQNrALTBdqqFou4X4Q2MoqCXzwnQZTDZvH28', ); }); diff --git a/test/unit/entry-packing.ts b/test/unit/entry-packing.ts index a7730ad8aa..12f881b0a8 100644 --- a/test/unit/entry-packing.ts +++ b/test/unit/entry-packing.ts @@ -24,21 +24,21 @@ const poiEncoded = 'pi_yDwBwMDAwMDA5gE8AQ=='; describe('Entry', () => { describe('packEntry', () => { it('packs', () => { - expect(packEntry(account)).to.be.equal(accountEncoded); + expect(packEntry(account)).to.equal(accountEncoded); }); it('packs poi', () => { - expect(packEntry(poi)).to.be.equal(poiEncoded); + expect(packEntry(poi)).to.equal(poiEncoded); }); }); describe('unpackEntry', () => { it('unpacks', () => { - expect(unpackEntry(accountEncoded)).to.be.eql({ ...account, version: 1 }); + expect(unpackEntry(accountEncoded)).to.eql({ ...account, version: 1 }); }); it('unpacks poi', () => { - expect(unpackEntry(poiEncoded)).to.be.eql({ ...poi, version: 1 }); + expect(unpackEntry(poiEncoded)).to.eql({ ...poi, version: 1 }); }); it('fails if payload have incorrect encoding', () => { diff --git a/test/unit/jwt.ts b/test/unit/jwt.ts index 1b40563ca5..d4090288f2 100644 --- a/test/unit/jwt.ts +++ b/test/unit/jwt.ts @@ -23,13 +23,13 @@ describe('JWT', () => { describe('isJwt, ensureJwt', () => { it('works if correct jwt', () => { - expect(isJwt(jwt)).to.be.equal(true); + expect(isJwt(jwt)).to.equal(true); ensureJwt(jwt); }); it('fails if wrong jwt', () => { const j = 'test'; - expect(isJwt(j)).to.be.equal(false); + expect(isJwt(j)).to.equal(false); expect(() => ensureJwt(j)).to.throw( ArgumentError, 'JWT components count should be 3, got 1 instead', @@ -39,23 +39,23 @@ describe('JWT', () => { describe('signJwt', () => { it('signs', async () => { - expect(await signJwt(payload, account)).to.be.equal(jwt); + expect(await signJwt(payload, account)).to.equal(jwt); }); it('signs with address', async () => { - expect(await signJwt({ address: account.address, sub_jwk: undefined }, account)).to.be.equal( + expect(await signJwt({ address: account.address, sub_jwk: undefined }, account)).to.equal( jwtWithAddress, ); }); it('signs shortest', async () => { - expect(await signJwt({ sub_jwk: undefined }, account)).to.be.equal(jwtShortest); + expect(await signJwt({ sub_jwk: undefined }, account)).to.equal(jwtShortest); }); }); describe('unpackJwt', () => { it('unpacks', async () => { - expect(unpackJwt(jwt)).to.be.eql({ + expect(unpackJwt(jwt)).to.eql({ payload: { sub_jwk: { crv: 'Ed25519', @@ -77,19 +77,19 @@ describe('JWT', () => { }); it('unpacks with address', async () => { - expect(unpackJwt(jwtWithAddress)).to.be.eql({ + expect(unpackJwt(jwtWithAddress)).to.eql({ payload: { address: account.address }, signer: undefined, }); - expect(unpackJwt(jwtWithAddress, account.address)).to.be.eql({ + expect(unpackJwt(jwtWithAddress, account.address)).to.eql({ payload: { address: account.address }, signer: account.address, }); }); it('unpacks shortest', async () => { - expect(unpackJwt(jwtShortest)).to.be.eql({ payload: {}, signer: undefined }); - expect(unpackJwt(jwtShortest, account.address)).to.be.eql({ + expect(unpackJwt(jwtShortest)).to.eql({ payload: {}, signer: undefined }); + expect(unpackJwt(jwtShortest, account.address)).to.eql({ payload: {}, signer: account.address, }); @@ -106,17 +106,17 @@ describe('JWT', () => { describe('verifyJwt', () => { it('verifies', () => { - expect(verifyJwt(jwt)).to.be.equal(true); - expect(verifyJwt(jwt, account.address)).to.be.equal(true); - expect(verifyJwt(jwtShortest, account.address)).to.be.equal(true); + expect(verifyJwt(jwt)).to.equal(true); + expect(verifyJwt(jwt, account.address)).to.equal(true); + expect(verifyJwt(jwtShortest, account.address)).to.equal(true); }); it('returns false if address not the same as in "sub_jwk"', () => { - expect(verifyJwt(jwt, MemoryAccount.generate().address)).to.be.equal(false); + expect(verifyJwt(jwt, MemoryAccount.generate().address)).to.equal(false); }); it('returns false if address not provided', () => { - expect(verifyJwt(jwtShortest)).to.be.equal(false); + expect(verifyJwt(jwtShortest)).to.equal(false); }); }); }); diff --git a/test/unit/ledger.ts b/test/unit/ledger.ts index a17a37965a..a7a30338f5 100644 --- a/test/unit/ledger.ts +++ b/test/unit/ledger.ts @@ -43,7 +43,7 @@ async function initTransport(s: string, ignoreRealDevice = false): Promise { if (compareWithRealDevice) { - expect(recordStore.toString().trim()).to.be.equal(expectedRecordStore); + expect(recordStore.toString().trim()).to.equal(expectedRecordStore); } expectedRecordStore = ''; }); @@ -57,7 +57,7 @@ describe('Ledger HW', function () { => e006000000 <= 000004049000`); const factory = new AccountLedgerFactory(transport); - expect((await factory.getAppConfiguration()).version).to.be.equal('0.4.4'); + expect((await factory.getAppConfiguration()).version).to.equal('0.4.4'); }); it('ensures that app version is compatible', async () => { @@ -80,7 +80,7 @@ describe('Ledger HW', function () { => e0020000040000002a <= 35616b5f3248746565756a614a7a75744b65465a69416d59547a636167536f5245725358704246563137397859677154347465616b769000`); const factory = new AccountLedgerFactory(transport); - expect(await factory.getAddress(42)).to.be.equal( + expect(await factory.getAddress(42)).to.equal( 'ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv', ); }); @@ -92,7 +92,7 @@ describe('Ledger HW', function () { => e0020100040000002a <= 35616b5f3248746565756a614a7a75744b65465a69416d59547a636167536f5245725358704246563137397859677154347465616b769000`); const factory = new AccountLedgerFactory(transport); - expect(await factory.getAddress(42, true)).to.be.equal( + expect(await factory.getAddress(42, true)).to.equal( 'ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv', ); }); @@ -117,9 +117,9 @@ describe('Ledger HW', function () { <= 35616b5f3248746565756a614a7a75744b65465a69416d59547a636167536f5245725358704246563137397859677154347465616b769000`); const factory = new AccountLedgerFactory(transport); const account = await factory.initialize(42); - expect(account).to.be.instanceOf(AccountLedger); - expect(account.address).to.be.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); - expect(account.index).to.be.equal(42); + expect(account).to.be.an.instanceOf(AccountLedger); + expect(account.address).to.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); + expect(account.index).to.equal(42); }); class NodeMock extends Node { @@ -159,8 +159,8 @@ describe('Ledger HW', function () { node.addresses.push('ak_DzELMKnSfJcfnCUZ2SbXUSxRmFYtGrWmMuKiCx68YKLH26kwc'); const factory = new AccountLedgerFactory(transport); const accounts = await factory.discover(node); - expect(accounts.length).to.be.equal(node.addresses.length); - expect(accounts.map((a) => a.address)).to.be.eql(node.addresses); + expect(accounts.length).to.equal(node.addresses.length); + expect(accounts.map((a) => a.address)).to.eql(node.addresses); }); it('discovers accounts on unused ledger', async () => { @@ -172,7 +172,7 @@ describe('Ledger HW', function () { const node = new NodeMock(); const factory = new AccountLedgerFactory(transport); const accounts = await factory.discover(node); - expect(accounts.length).to.be.equal(0); + expect(accounts.length).to.equal(0); }); }); @@ -204,7 +204,7 @@ describe('Ledger HW', function () { signatures: [signature], } = unpackTx(signedTransaction, Tag.SignedTx); const hashedTx = Buffer.concat([Buffer.from(networkId), hash(decode(transaction))]); - expect(verify(hashedTx, signature, address)).to.be.equal(true); + expect(verify(hashedTx, signature, address)).to.equal(true); }); it('signs transaction rejected', async () => { @@ -227,8 +227,8 @@ describe('Ledger HW', function () { <= 78397e186058f278835b8e3e866960e4418dc1e9f00b3a2423f57c16021c88720119ebb3373a136112caa1c9ff63870092064659eb2c641dd67767f15c80350c9000`); const account = new AccountLedger(transport, 0, address); const signature = await account.signMessage(message); - expect(signature).to.be.instanceOf(Uint8Array); - expect(verifyMessage(message, signature, address)).to.be.equal(true); + expect(signature).to.be.an.instanceOf(Uint8Array); + expect(verifyMessage(message, signature, address)).to.equal(true); }); it('signs message rejected', async () => { diff --git a/test/unit/memory-account.ts b/test/unit/memory-account.ts index 7a0f330aca..beefaabedc 100644 --- a/test/unit/memory-account.ts +++ b/test/unit/memory-account.ts @@ -15,8 +15,8 @@ describe('MemoryAccount', () => { it('Init with secretKey', async () => { const acc = new MemoryAccount(secretKey); - expect(acc.address).to.be.equal('ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E'); - expect(acc.secretKey).to.be.equal(secretKey); + expect(acc.address).to.equal('ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E'); + expect(acc.secretKey).to.equal(secretKey); }); it('generates', async () => { @@ -28,7 +28,7 @@ describe('MemoryAccount', () => { const data = Buffer.from(new Array(10).fill(0).map((_, idx) => idx)); const account = new MemoryAccount(secretKey); const signature = await account.sign(data); - expect(signature).to.be.eql( + expect(signature).to.eql( Uint8Array.from([ 113, 154, 121, 195, 164, 141, 153, 234, 196, 82, 120, 31, 198, 179, 208, 138, 88, 63, 98, 221, 126, 199, 240, 117, 105, 164, 118, 214, 30, 211, 116, 118, 211, 89, 218, 196, 223, 182, @@ -36,14 +36,14 @@ describe('MemoryAccount', () => { 249, 219, 99, 74, 255, 5, ]), ); - expect(verify(data, signature, account.address)).to.be.equal(true); + expect(verify(data, signature, account.address)).to.equal(true); }); it('Sign message', async () => { const message = 'test'; const account = new MemoryAccount(secretKey); const signature = await account.signMessage(message); - expect(signature).to.be.eql( + expect(signature).to.eql( Uint8Array.from([ 0, 140, 249, 124, 66, 31, 147, 247, 203, 165, 188, 56, 230, 186, 154, 230, 113, 200, 189, 113, 6, 140, 52, 219, 199, 130, 46, 121, 201, 45, 239, 59, 109, 139, 175, 243, 83, 186, 83, @@ -51,14 +51,14 @@ describe('MemoryAccount', () => { 110, 74, 51, 47, 0, ]), ); - expect(verifyMessage(message, signature, account.address)).to.be.equal(true); + expect(verifyMessage(message, signature, account.address)).to.equal(true); }); it('Sign message message with non-ASCII chars', async () => { const message = 'tæst'; const account = new MemoryAccount(secretKey); const signature = await account.signMessage(message); - expect(signature).to.be.eql( + expect(signature).to.eql( Uint8Array.from([ 164, 138, 41, 174, 108, 125, 147, 42, 137, 79, 226, 64, 156, 196, 232, 24, 216, 105, 105, 132, 212, 15, 198, 226, 48, 119, 36, 2, 115, 211, 90, 24, 242, 213, 206, 221, 215, 32, 192, @@ -66,6 +66,6 @@ describe('MemoryAccount', () => { 183, 197, 251, 3, ]), ); - expect(verifyMessage(message, signature, account.address)).to.be.equal(true); + expect(verifyMessage(message, signature, account.address)).to.equal(true); }); }); diff --git a/test/unit/metamask.ts b/test/unit/metamask.ts index d88035bd34..41b79bbe06 100644 --- a/test/unit/metamask.ts +++ b/test/unit/metamask.ts @@ -41,7 +41,7 @@ async function initProvider( assertNotNull(expectedRequest); if (!('request' in expectedRequest)) throw new Error(`Expected request, got ${JSON.stringify(expectedRequest)} instead`); - expect(actualRequest).to.be.eql(expectedRequest.request); + expect(actualRequest).to.eql(expectedRequest.request); const expectedResponse = messageQueue.shift(); assertNotNull(expectedResponse); @@ -58,7 +58,7 @@ async function initProvider( (reject: unknown) => ({ reject }), ); }, expectedRequest.request); - expect(actualResponse).to.be.eql(expectedResponse); + expect(actualResponse).to.eql(expectedResponse); } // eslint-disable-next-line @typescript-eslint/no-throw-literal @@ -130,13 +130,13 @@ describe('Aeternity Snap for MetaMask', function () { }, ]); const factory = new AccountMetamaskFactory(provider); - expect(await factory.installSnap()).to.be.eql(snapDetails); + expect(await factory.installSnap()).to.eql(snapDetails); }); it('gets snap version', async () => { const provider = await initProvider([...versionChecks, ...versionChecks.slice(2, 2)]); const factory = new AccountMetamaskFactory(provider); - expect(await factory.getSnapVersion()).to.be.equal('0.0.9'); + expect(await factory.getSnapVersion()).to.equal('0.0.9'); }); it('ensures that snap version is compatible', async () => { @@ -172,9 +172,9 @@ describe('Aeternity Snap for MetaMask', function () { const factory = new AccountMetamaskFactory(provider); await instructTester('approve'); const account = await factory.initialize(42); - expect(account).to.be.instanceOf(AccountMetamask); - expect(account.address).to.be.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); - expect(account.index).to.be.equal(42); + expect(account).to.be.an.instanceOf(AccountMetamask); + expect(account.address).to.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); + expect(account.index).to.equal(42); }); it('initializes an account rejected', async () => { @@ -242,7 +242,7 @@ describe('Aeternity Snap for MetaMask', function () { signatures: [signature], } = unpackTx(signedTransaction, Tag.SignedTx); const hashedTx = Buffer.concat([Buffer.from(networkId), hash(decode(transaction))]); - expect(verify(hashedTx, signature, address)).to.be.equal(true); + expect(verify(hashedTx, signature, address)).to.equal(true); }); it('signs transaction rejected', async () => { @@ -288,8 +288,8 @@ describe('Aeternity Snap for MetaMask', function () { const account = new AccountMetamask(provider, 0, address); await instructTester('approve'); const signature = await account.signMessage(message); - expect(signature).to.be.instanceOf(Uint8Array); - expect(verifyMessage(message, signature, address)).to.be.equal(true); + expect(signature).to.be.an.instanceOf(Uint8Array); + expect(verifyMessage(message, signature, address)).to.equal(true); }); it('signs message rejected', async () => { diff --git a/test/unit/mnemonic.ts b/test/unit/mnemonic.ts index 5e962089ec..3032485f3c 100644 --- a/test/unit/mnemonic.ts +++ b/test/unit/mnemonic.ts @@ -12,20 +12,20 @@ const wallet = { describe('Account mnemonic factory', () => { it('derives wallet', async () => { const factory = new AccountMnemonicFactory(mnemonic); - expect(await factory.getWallet()).to.be.eql(wallet); + expect(await factory.getWallet()).to.eql(wallet); }); it('initializes an account', async () => { const factory = new AccountMnemonicFactory(mnemonic); const account = await factory.initialize(42); - expect(account).to.be.instanceOf(MemoryAccount); - expect(account.address).to.be.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); + expect(account).to.be.an.instanceOf(MemoryAccount); + expect(account.address).to.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); }); it('initializes an account by wallet', async () => { const factory = new AccountMnemonicFactory(wallet); const account = await factory.initialize(42); - expect(account.address).to.be.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); + expect(account.address).to.equal('ak_2HteeujaJzutKeFZiAmYTzcagSoRErSXpBFV179xYgqT4teakv'); }); class NodeMock extends Node { @@ -56,14 +56,14 @@ describe('Account mnemonic factory', () => { node.addresses.push('ak_DzELMKnSfJcfnCUZ2SbXUSxRmFYtGrWmMuKiCx68YKLH26kwc'); const factory = new AccountMnemonicFactory(mnemonic); const accounts = await factory.discover(node); - expect(accounts.length).to.be.equal(node.addresses.length); - expect(accounts.map((a) => a.address)).to.be.eql(node.addresses); + expect(accounts.length).to.equal(node.addresses.length); + expect(accounts.map((a) => a.address)).to.eql(node.addresses); }); it('discovers accounts on unused mnemonic', async () => { const node = new NodeMock(); const factory = new AccountMnemonicFactory(mnemonic); const accounts = await factory.discover(node); - expect(accounts.length).to.be.equal(0); + expect(accounts.length).to.equal(0); }); }); diff --git a/test/unit/mptree.ts b/test/unit/mptree.ts index e666d9851e..9cb3d98abd 100644 --- a/test/unit/mptree.ts +++ b/test/unit/mptree.ts @@ -45,30 +45,30 @@ describe('Merkle Patricia Tree', () => { it('can deserialize', () => { const tree = deserialize(binary); - expect(tree.isComplete).to.be.equal(true); + expect(tree.isComplete).to.equal(true); }); it('can be converted to object', () => { const tree = deserialize(binary); - expect(tree.toObject()).to.be.eql(map); + expect(tree.toObject()).to.eql(map); }); it('can serialize', () => { const tree = deserialize(binary); - expect(field.serialize(tree)).to.be.eql(binary); + expect(field.serialize(tree)).to.eql(binary); }); it('can retrieve values', () => { const tree = deserialize(binary); Object.entries(map).forEach(([key, value]: [Encoded.AccountAddress, object]) => { - expect(tree.get(key)).to.be.eql(value); + expect(tree.get(key)).to.eql(value); }); }); it('can check is equal', () => { const tree = deserialize(binary); - expect(tree.isEqual(deserialize(binary))).to.be.equal(true); - expect(tree.isEqual(deserialize(binary2))).to.be.equal(false); + expect(tree.isEqual(deserialize(binary))).to.equal(true); + expect(tree.isEqual(deserialize(binary2))).to.equal(false); }); it('throws exception if payload is invalid', () => { diff --git a/test/unit/pretty-numbers.ts b/test/unit/pretty-numbers.ts index 1c57177edd..e575a1a453 100644 --- a/test/unit/pretty-numbers.ts +++ b/test/unit/pretty-numbers.ts @@ -6,14 +6,14 @@ import { prefixedAmount } from '../../src'; const MAGNITUDE = 18; describe('prefixedAmount', () => { it('removes trailing zeros', () => { - expect(prefixedAmount(new BigNumber('1.0000'))).to.be.equal('1'); + expect(prefixedAmount(new BigNumber('1.0000'))).to.equal('1'); }); it('displays fees', () => { - expect(prefixedAmount(new BigNumber(17120).shiftedBy(-MAGNITUDE))).to.be.equal('0.01712 pico'); + expect(prefixedAmount(new BigNumber(17120).shiftedBy(-MAGNITUDE))).to.equal('0.01712 pico'); }); it('displays balance', () => { - expect(prefixedAmount(new BigNumber('89.99999999000924699'))).to.be.equal('90'); + expect(prefixedAmount(new BigNumber('89.99999999000924699'))).to.equal('90'); }); it('generates proper values', () => { @@ -58,6 +58,6 @@ describe('prefixedAmount', () => { '123456789 giga', '1.23456789 exa', '12.3456789 exa', - ].forEach((res, idx) => expect(prefixedAmount(t.shiftedBy(idx))).to.be.equal(res)); + ].forEach((res, idx) => expect(prefixedAmount(t.shiftedBy(idx))).to.equal(res)); }); }); diff --git a/test/unit/tx.ts b/test/unit/tx.ts index 8d17687e01..46201d4faf 100644 --- a/test/unit/tx.ts +++ b/test/unit/tx.ts @@ -35,7 +35,7 @@ describe('Tx', () => { const salt = genSalt(); const hash = await commitmentHash('foobar.chain', salt); expect(hash).to.be.a('string'); - expect(hash).to.be.equal(await commitmentHash('foobar.chain', salt)); + expect(hash).to.equal(await commitmentHash('foobar.chain', salt)); }); it('test from big number to bytes', async () => { @@ -55,7 +55,7 @@ describe('Tx', () => { } data.forEach((n) => { - expect(n.toString(10)).to.be.equal(bnFromBytes(n)); + expect(n.toString(10)).to.equal(bnFromBytes(n)); }); }); @@ -74,15 +74,15 @@ describe('Tx', () => { }); describe('isNameValid', () => { - it('validates domain', () => expect(isNameValid('asdasdasd.unknown')).to.be.equal(false)); - it("don't throws exception", () => expect(isNameValid('asdasdasd.chain')).to.be.equal(true)); + it('validates domain', () => expect(isNameValid('asdasdasd.unknown')).to.equal(false)); + it("don't throws exception", () => expect(isNameValid('asdasdasd.chain')).to.equal(true)); }); const payload = Buffer.from([1, 2, 42]); describe('decode', () => { - it('decodes base64check', () => expect(decode('ba_AQIq9Y55kw==')).to.be.eql(payload)); + it('decodes base64check', () => expect(decode('ba_AQIq9Y55kw==')).to.eql(payload)); - it('decodes base58check', () => expect(decode('nm_3DZUwMat2')).to.be.eql(payload)); + it('decodes base58check', () => expect(decode('nm_3DZUwMat2')).to.eql(payload)); it('throws if invalid checksum', () => expect(() => decode('ak_23aaaaa')).to.throw('Invalid checksum')); @@ -93,17 +93,17 @@ describe('Tx', () => { describe('encode', () => { it('encodes base64check', () => - expect(encode(payload, Encoding.Bytearray)).to.be.equal('ba_AQIq9Y55kw==')); + expect(encode(payload, Encoding.Bytearray)).to.equal('ba_AQIq9Y55kw==')); it('encodes base58check', () => - expect(encode(payload, Encoding.Name)).to.be.equal('nm_3DZUwMat2')); + expect(encode(payload, Encoding.Name)).to.equal('nm_3DZUwMat2')); }); describe('getDefaultPointerKey', () => { it('returns default pointer key for contract', () => expect( getDefaultPointerKey('ct_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR'), - ).to.be.equal('contract_pubkey')); + ).to.equal('contract_pubkey')); it('throws error', () => expect(() => getDefaultPointerKey('ba_AQIq9Y55kw==' as Encoded.Channel)).to.throw( @@ -243,8 +243,8 @@ describe('Tx', () => { }, }, } as const; - expect(unpackEntry(tx, EntryTag.CallsMtree)).to.be.eql(params); - expect(packEntry(params)).to.be.equal(tx); + expect(unpackEntry(tx, EntryTag.CallsMtree)).to.eql(params); + expect(packEntry(params)).to.equal(tx); }); it('unpacks state channel signed tx', () => { @@ -254,9 +254,9 @@ describe('Tx', () => { ); expect(signatures).to.have.lengthOf(2); ensureEqual(encodedTx.tag, Tag.ChannelOffChainTx); - expect(encodedTx.channelId).to.be.satisfy((s: string) => s.startsWith('ch_')); - expect(encodedTx.round).to.be.equal(3); - expect(encodedTx.stateHash).to.be.satisfy((s: string) => s.startsWith('st_')); + expect(encodedTx.channelId).to.satisfy((s: string) => s.startsWith('ch_')); + expect(encodedTx.round).to.equal(3); + expect(encodedTx.stateHash).to.satisfy((s: string) => s.startsWith('st_')); }); it('unpacks state trees tx', () => { @@ -321,7 +321,7 @@ describe('Tx', () => { tag: EntryTag.StateTrees, version: 0, } as const; - expect(unpackEntry(tx, EntryTag.StateTrees)).to.be.eql(params); + expect(unpackEntry(tx, EntryTag.StateTrees)).to.eql(params); }); }); @@ -356,13 +356,13 @@ describe('Tx', () => { callData: 'cb_KxFE1kQfP4oEp9E=', } as const; const tx = buildTx(txParams); - expect(unpackTx(tx, Tag.ContractCreateTx).fee).to.be.equal('78500000000000'); + expect(unpackTx(tx, Tag.ContractCreateTx).fee).to.equal('78500000000000'); }); it('unpack and build ChannelCreateTx into the same value', () => { const tx = 'tx_+IgyAqEBNMD0uYWndDrqF2Q8OIUWZ/gEi45vpwfg+cNOEVi9pL+JBWvHXi1jEAAAoQG5mrb34g29bneQLjNaFcH4OwVP0r9m9x6kYxpxiqN7EYkFa8deLWMQAAAAAQCGECcSfcAAwMCgOK3o2rLTFOY30p/4fMgaz3hG5WWTAcWknsu7ceLFmM0CERW42w=='; - expect(buildTx(unpackTx(tx))).to.be.equal(tx); + expect(buildTx(unpackTx(tx))).to.equal(tx); }); it('checks argument types', () => { diff --git a/test/unit/utils.ts b/test/unit/utils.ts index 7937d0b656..3a70a7c327 100644 --- a/test/unit/utils.ts +++ b/test/unit/utils.ts @@ -9,11 +9,11 @@ describe('Utils', () => { let t = { test: 'foo' }; const wrapped = wrapWithProxy(() => t); expect(wrapped).to.not.be.equal(t); - expect(wrapped.test).to.be.equal('foo'); + expect(wrapped.test).to.equal('foo'); t.test = 'bar'; - expect(wrapped.test).to.be.equal('bar'); + expect(wrapped.test).to.equal('bar'); t = { test: 'baz' }; - expect(wrapped.test).to.be.equal('baz'); + expect(wrapped.test).to.equal('baz'); }); it('throws error if value undefined', () => { @@ -39,7 +39,7 @@ describe('Utils', () => { const entity = new Entity(); const wrapped = wrapWithProxy(() => entity); - expect(wrapped.foo()).to.be.equal(5); + expect(wrapped.foo()).to.equal(5); }); }); @@ -48,11 +48,11 @@ describe('Utils', () => { it('unwraps proxy to value', () => { const wrapped = wrapWithProxy(() => t); - expect(unwrapProxy(wrapped)).to.be.equal(t); + expect(unwrapProxy(wrapped)).to.equal(t); }); it('does nothing if not wrapped', () => { - expect(unwrapProxy(t)).to.be.equal(t); + expect(unwrapProxy(t)).to.equal(t); }); }); }); diff --git a/test/utils.ts b/test/utils.ts index 3d48f8389f..b3c4d3b513 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -21,7 +21,7 @@ export function assertNotNull(value: T): asserts value is NonNullable { } export function ensureEqual(value: any, equalTo: T): asserts value is T { - expect(value).to.be.equal(equalTo); + expect(value).to.equal(equalTo); } type Cls = abstract new (...args: any) => any; @@ -30,7 +30,7 @@ export function ensureInstanceOf( value: any, cls: T, ): asserts value is InstanceType { - expect(value).to.be.instanceOf(cls); + expect(value).to.be.an.instanceOf(cls); } export type ChainTtl =