diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ca938ac1..0d2dc1eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Features, Bug Fixes, API Breaking, Deprecated, Infrastructure, Template Updates - Fix `txn AssetSender` should return zero address by default. - Add unit tests for all transaction types in runtime executeTx. - Add support loadLogic for *.teal program and SCParam. +- Replace arrow functions with normal functions in all unit test which is recommended by `mocha` #### Examples diff --git a/docs/guide/best-practices.md b/docs/guide/best-practices.md index f5819d37c..7b1f0f374 100644 --- a/docs/guide/best-practices.md +++ b/docs/guide/best-practices.md @@ -6,6 +6,7 @@ layout: splash - Use [boilerplate-stateful-smart-contract](https://developer.algorand.org/docs/features/asc1/stateful/#boilerplate-stateful-smart-contract) as a template for new smart-contracts. - Use [zero address](https://developer.algorand.org/docs/features/accounts/#special-accounts) to prevent future updates or deletion of a smart-contract. +- It is highly recommended not to use arrow functions in tests due to the problem of scope of `this` keyword in javascript. Use only regular function expressions. For more details go to [mocha](ttps://mochajs.org/#arrow-functions). ### Entry points diff --git a/docs/guide/testing-teal.md b/docs/guide/testing-teal.md index a8bb2ac1b..1fd938f91 100644 --- a/docs/guide/testing-teal.md +++ b/docs/guide/testing-teal.md @@ -60,16 +60,16 @@ describe("use-case", function() { let variable1; // ... - this.beforeAll(() => { ... }); - this.afterAll(() => { ... }); + this.beforeAll(function() { ... }); + this.afterAll(function() { ... }); - it("test case 1", () => { + it("test case 1", function() { // preparation // execution // checks }); - it("test case 2", () => { ... }); + it("test case 2", function() { ... }); }); ``` diff --git a/docs/tutorials/t-04.md b/docs/tutorials/t-04.md index 19ebae571..c1aea6a99 100644 --- a/docs/tutorials/t-04.md +++ b/docs/tutorials/t-04.md @@ -22,16 +22,16 @@ describe("use-case", function() { let variable1; // ... - this.beforeAll(() => { ... }); - this.afterAll(() => { ... }); + this.beforeAll(function() { ... }); + this.afterAll(function() { ... }); - it("test case 1", () => { + it("test case 1", function() { // preparation // execution // checks }); - it("test case 2", () => { ... }); + it("test case 2", function() { ... }); }); ``` diff --git a/examples/bond/test/bond-token-flow.js b/examples/bond/test/bond-token-flow.js index d39062856..af89c1f7c 100644 --- a/examples/bond/test/bond-token-flow.js +++ b/examples/bond/test/bond-token-flow.js @@ -37,7 +37,7 @@ describe("Bond token Tests", function () { let issuerLsigAddress; let lsig; - this.beforeAll(() => { + this.beforeAll(function () { appStorageConfig = { localInts: 1, localBytes: 1, @@ -61,7 +61,7 @@ describe("Bond token Tests", function () { const maxIssuance = "int:1000000"; const bondCreator = convert.addressToPk(bondTokenCreator.address); - it("Bond token application", () => { + it("Bond token application", function () { /** * Issue initial bond tokens to the issuer * In epoch_0 elon buys 10 bonds diff --git a/examples/bond/test/failing-tests.js b/examples/bond/test/failing-tests.js index 4b5c092ce..5f7daedee 100644 --- a/examples/bond/test/failing-tests.js +++ b/examples/bond/test/failing-tests.js @@ -154,7 +154,7 @@ describe("Bond token failing tests", function () { try { runtime.optInToApp(elon.address, applicationId, {}, {}); // eslint-disable-next-line no-empty - } catch (e) {} // can be already opted-in + } catch (e) { } // can be already opted-in const amount = 10; const algoAmount = amount * 1000; @@ -170,7 +170,7 @@ describe("Bond token failing tests", function () { syncAccounts(); } - it("Random user should not be able to update issuer's address", () => { + it("Random user should not be able to update issuer's address", function () { // update application with correct issuer account address const appArgs = [updateIssuer, convert.addressToPk(issuerLsigAddress)]; // converts algorand address to Uint8Array @@ -186,7 +186,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx([appCallParams]), RUNTIME_ERR1009); }); - it("Issuer should not be able to send asa without calling bond-dapp", () => { + it("Issuer should not be able to send asa without calling bond-dapp", function () { const params = { type: types.TransactionType.TransferAsset, sign: types.SignType.LogicSignature, @@ -201,7 +201,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx([params]), REJECTED_BY_LOGIC); }); - it("Opt-In to issuer lsig with single transaction should fail", () => { + it("Opt-In to issuer lsig with single transaction should fail", function () { const optInTx = { type: types.TransactionType.OptInASA, sign: types.SignType.LogicSignature, @@ -215,7 +215,7 @@ describe("Bond token failing tests", function () { }); // Avoid spamming of asset id's in bond-dapp - it("Opt-In to issuer lsig without store manager signature should fail", () => { + it("Opt-In to issuer lsig without store manager signature should fail", function () { const optInTx = [ { type: types.TransactionType.TransferAlgo, @@ -238,7 +238,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx(optInTx), REJECTED_BY_LOGIC); }); - it("Random user should not be able to update issue price", () => { + it("Random user should not be able to update issue price", function () { const appArgs = ["str:update_issue_price", "int:0"]; const appCallParams = { @@ -253,7 +253,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx([appCallParams]), RUNTIME_ERR1009); }); - it("should not issue shares to address other than issuer's address", () => { + it("should not issue shares to address other than issuer's address", function () { const appArgs = [updateIssuer, convert.addressToPk(issuerLsigAddress)]; const appCallParams = { @@ -274,7 +274,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx(groupTx), RUNTIME_ERR1009); }); - it("User should not be able to buy for less amount than specified", () => { + it("User should not be able to buy for less amount than specified", function () { issue(); // Buy tokens from issuer @@ -287,7 +287,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx(groupTx), RUNTIME_ERR1009); }); - it("Only store manager can create dex", () => { + it("Only store manager can create dex", function () { issue(); buy(); @@ -297,7 +297,7 @@ describe("Bond token failing tests", function () { ); }); - it("Buyer cannot redeem more than they have", () => { + it("Buyer cannot redeem more than they have", function () { issue(); buy(); // manager starts epoch 1 (create dex) @@ -309,7 +309,7 @@ describe("Bond token failing tests", function () { assert.throws(() => redeem(runtime, elon, 1, 20, dexLsig1), RUNTIME_ERR1402); }); - it("Buyer tries to buy bonds without paying fees", () => { + it("Buyer tries to buy bonds without paying fees", function () { issue(); // Buy tokens from issuer runtime.optInToASA(initialBond, elon.address, {}); @@ -332,7 +332,7 @@ describe("Bond token failing tests", function () { assert.throws(() => runtime.executeTx(groupTx), RUNTIME_ERR1506); }); - it("Buyer tries to exchange bonds without paying fees", () => { + it("Buyer tries to exchange bonds without paying fees", function () { issue(); buy(); // manager starts epoch 1 (create dex) diff --git a/examples/crowdfunding/test/crowdfundingTest.js b/examples/crowdfunding/test/crowdfundingTest.js index 0b13a5cff..59b95e07c 100644 --- a/examples/crowdfunding/test/crowdfundingTest.js +++ b/examples/crowdfunding/test/crowdfundingTest.js @@ -85,7 +85,7 @@ describe("Crowdfunding Tests", function () { convert.uint64ToBigEndian(fundCloseDate.getTime()), ]; - it("crowdfunding application", () => { + it("crowdfunding application", function () { /** * This test demonstrates how to create a Crowdfunding Stateful Smart Contract Application * and interact with it. there are following operations that are performed: @@ -309,7 +309,7 @@ describe("Crowdfunding Tests", function () { } }); - it("should be rejected by logic when claiming funds if goal is not met", () => { + it("should be rejected by logic when claiming funds if goal is not met", function () { const applicationId = runtime.deployApp( creator.account, { ...appDefinition, appArgs: creationArgs }, diff --git a/examples/crowdfunding/test/failing-tests.js b/examples/crowdfunding/test/failing-tests.js index 5e5214d08..7c50a9613 100644 --- a/examples/crowdfunding/test/failing-tests.js +++ b/examples/crowdfunding/test/failing-tests.js @@ -30,7 +30,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { const approvalProgram = getProgram(approvalProgramFilename); const clearProgram = getProgram(clearProgramFilename); // Create new runtime and application before each test. - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([master, creator, donor]); // Get begin date to pass in @@ -133,7 +133,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { runtime = new Runtime([master, creator, escrow, donor]); }); - it("should fail donation if donor has insufficient balance", () => { + it("should fail donation if donor has insufficient balance", function () { updateAndOptIn(); appArgs = [convert.stringToBytes("donate")]; const donationAmount = initialDonorBalance + 1000; @@ -160,7 +160,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(txGroup), "RUNTIME_ERR1401"); }); - it("should fail donation if timestamp is after endDate", () => { + it("should fail donation if timestamp is after endDate", function () { updateAndOptIn(); // set timestamp to after of endDate runtime.setRoundAndTimestamp(5, endDate.getSeconds() + 100); @@ -168,7 +168,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(donateTxGroup), rejectMsg); }); - it("should fail donation if timestamp is before of beginDate", () => { + it("should fail donation if timestamp is before of beginDate", function () { updateAndOptIn(); // set timestamp to out of endDate runtime.setRoundAndTimestamp(5, beginDate.getSeconds() - 100); @@ -176,7 +176,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(donateTxGroup), rejectMsg); }); - it("should fail if goal is met, and donor tries to reclaim funds", () => { + it("should fail if goal is met, and donor tries to reclaim funds", function () { updateAndOptIn(); // set donation to greater than goal donateTxGroup[1].amountMicroAlgos = goal + 1000; @@ -209,7 +209,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(txGroup), rejectMsg); }); - it("should fail if goal is not met, but donor tries to reclaim funds before fund close date", () => { + it("should fail if goal is not met, but donor tries to reclaim funds before fund close date", function () { updateAndOptIn(); runtime.executeTx(donateTxGroup); @@ -239,7 +239,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(txGroup), rejectMsg); }); - it("should fail if creator tries to claim funds before fund end date", () => { + it("should fail if creator tries to claim funds before fund end date", function () { updateAndOptIn(); // set donation to greater than goal donateTxGroup[1].amountMicroAlgos = goal + 1000; @@ -268,7 +268,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(txGroup), rejectMsg); }); - it("should fail if a transaction is missing in group transaction while donating", () => { + it("should fail if a transaction is missing in group transaction while donating", function () { updateAndOptIn(); appArgs = [convert.stringToBytes("donate")]; const txGroup = [ @@ -285,7 +285,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx(txGroup), "RUNTIME_ERR1008: Index out of bound"); }); - it("should fail if transaction is signed by wrong lsig", () => { + it("should fail if transaction is signed by wrong lsig", function () { updateAndOptIn(); // set donation to greater than goal donateTxGroup[1].amountMicroAlgos = goal + 1000; @@ -319,7 +319,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { ); }); - it("should fail if escrow address is not updated in app", () => { + it("should fail if escrow address is not updated in app", function () { // opt-in to app runtime.optInToApp(creator.address, applicationId, {}, {}); runtime.optInToApp(donor.address, applicationId, {}, {}); @@ -332,7 +332,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { ); }); - it("should fail transaction if logic signature is not passed", () => { + it("should fail transaction if logic signature is not passed", function () { updateAndOptIn(); // set donation to greater than goal donateTxGroup[1].amountMicroAlgos = goal + 1000; @@ -364,7 +364,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { ); }); - it("should fail to delete app because escrow account balance is not empty", () => { + it("should fail to delete app because escrow account balance is not empty", function () { updateAndOptIn(); runtime.setRoundAndTimestamp(5, fundCloseDate.getTime() + 12); const deleteTx = { @@ -380,7 +380,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { assert.throws(() => runtime.executeTx([deleteTx]), "RUNTIME_ERR1008: Index out of bound"); }); - it("should fail on trying to update application where sender is not creator", () => { + it("should fail on trying to update application where sender is not creator", function () { appArgs = [convert.addressToPk(escrowAddress)]; // converts algorand address to Uint8Array assert.throws( @@ -401,7 +401,7 @@ describe("Crowdfunding Test - Failing Scenarios", function () { ); }); - it("should fail if closing the funds in escrow but closeRemainderTo is not fundReceiver", () => { + it("should fail if closing the funds in escrow but closeRemainderTo is not fundReceiver", function () { updateAndOptIn(); // set donation to greater than goal donateTxGroup[1].amountMicroAlgos = goal + 1000; @@ -434,33 +434,33 @@ describe("Crowdfunding Test - Failing Scenarios", function () { // uncomment when // https://github.com/algorand/js-algorand-sdk/commit/b18e3beab8004d7e53a5370334b8e9f5c7699146#diff-75520b02c557ab3f0b89e5f03029db31af2f0dc79e5215d3e221ed9ea59fe441 // commit is released - /* it('should fail if ReKeyTo is not ZERO_ADDRESS in transaction', () => { - updateAndOptIn(); - // set donation to greater than goal - donateTxGroup[1].amountMicroAlgos = goal + 1000; - runtime.executeTx(donateTxGroup); - runtime.setRoundAndTimestamp(5, endDate.getTime() + 122); - appArgs = [convert.stringToBytes('claim')]; - const txGroup = [ - { - type: types.TransactionType.CallApp, - sign: types.SignType.SecretKey, - fromAccount: creator.account, - appID: applicationId, - payFlags: { totalFee: 1000, ReKeyTo: donor.address }, - appArgs: appArgs - }, - { - type: types.TransactionType.TransferAlgo, - sign: types.SignType.LogicSignature, - fromAccountAddr: escrow.account.addr, - toAccountAddr: creator.address, - amountMicroAlgos: 0, - lsig: lsig, - payFlags: { totalFee: 1000, closeRemainderTo: creator.address, ReKeyTo: donor.address } - } - ]; - - assert.throws(() => runtime.executeTx(txGroup), rejectMsg); + /* it('should fail if ReKeyTo is not ZERO_ADDRESS in transaction', function() { + updateAndOptIn(); + // set donation to greater than goal + donateTxGroup[1].amountMicroAlgos = goal + 1000; + runtime.executeTx(donateTxGroup); + runtime.setRoundAndTimestamp(5, endDate.getTime() + 122); + appArgs = [convert.stringToBytes('claim')]; + const txGroup = [ + { + type: types.TransactionType.CallApp, + sign: types.SignType.SecretKey, + fromAccount: creator.account, + appID: applicationId, + payFlags: { totalFee: 1000, ReKeyTo: donor.address }, + appArgs: appArgs + }, + { + type: types.TransactionType.TransferAlgo, + sign: types.SignType.LogicSignature, + fromAccountAddr: escrow.account.addr, + toAccountAddr: creator.address, + amountMicroAlgos: 0, + lsig: lsig, + payFlags: { totalFee: 1000, closeRemainderTo: creator.address, ReKeyTo: donor.address } + } + ]; + + assert.throws(() => runtime.executeTx(txGroup), rejectMsg); }); */ }); diff --git a/examples/crowdfunding/test/happypaths.js b/examples/crowdfunding/test/happypaths.js index 2809d5d71..df28eabe3 100644 --- a/examples/crowdfunding/test/happypaths.js +++ b/examples/crowdfunding/test/happypaths.js @@ -101,7 +101,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { runtime.fundLsig(master.account, escrowAddress, minBalance); } - it("should create crowdfunding stateful application", () => { + it("should create crowdfunding stateful application", function () { const beginTs = 1n; // fund begin timestamp const endTs = 10n; // fund end timestamp const fundCloseTs = 20n; // fund close timestamp @@ -134,7 +134,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.deepEqual(getGlobal("FundCloseDate"), 20n); }); - it("should setup escrow account and update application with escrow address", () => { + it("should setup escrow account and update application with escrow address", function () { setupAppAndEscrow(); const escrowPk = convert.addressToPk(escrow.address); @@ -158,7 +158,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.deepEqual(getGlobal("Escrow"), escrowPk); }); - it("should opt-in to app successfully after setting up escrow", () => { + it("should opt-in to app successfully after setting up escrow", function () { setupAppAndEscrow(); // update global storage to add escrow address @@ -174,7 +174,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.isDefined(donor.getAppFromLocal(applicationId)); }); - it("should be able to donate funds to escrow before end date", () => { + it("should be able to donate funds to escrow before end date", function () { setupAppAndEscrow(); runtime.setRoundAndTimestamp(2, 5); // StartTs=1, EndTs=10 @@ -217,7 +217,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.equal(donor.balance(), donorBal - BigInt(7e6) - 2000n); // 2000 is also deducted because of tx fee }); - it("Receiver should be able to withdraw funds if Goal is met", () => { + it("Receiver should be able to withdraw funds if Goal is met", function () { setupAppAndEscrow(); // fund end date should be passed runtime.setRoundAndTimestamp(2, 15); // StartTs=1, EndTs=10 @@ -266,7 +266,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.equal(fundReceiver.balance(), fundReceiverBal + escrowFunds - 1000n); // funds transferred to receiver from escrow }); - it("Donor should be able reclaim funds if Goal is not met", () => { + it("Donor should be able reclaim funds if Goal is not met", function () { setupAppAndEscrow(); // fund end date should be passed runtime.setRoundAndTimestamp(2, 15); // StartTs=1, EndTs=10 @@ -319,7 +319,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { assert.equal(donor.balance(), donorBalance + 300000n - 1000n); }); - it("Creator should be able to delete the application after the fund close date (using single tx)", () => { + it("Creator should be able to delete the application after the fund close date (using single tx)", function () { setupAppAndEscrow(); // fund close date should be passed runtime.setRoundAndTimestamp(2, 25); // fundCloseTs=20n @@ -364,7 +364,7 @@ describe("Crowdfunding Tests - Happy Paths", function () { } }); - it("Creator should be able to delete the application after the fund close date (using group tx)", () => { + it("Creator should be able to delete the application after the fund close date (using group tx)", function () { setupAppAndEscrow(); // fund close date should be passed runtime.setRoundAndTimestamp(2, 25); // fundCloseTs=20n diff --git a/examples/dao/test/dao-app-flow.js b/examples/dao/test/dao-app-flow.js index 24a90ff52..dd73ee522 100644 --- a/examples/dao/test/dao-app-flow.js +++ b/examples/dao/test/dao-app-flow.js @@ -239,7 +239,7 @@ describe("DAO test", function () { assert.equal(voterB.getAssetHolding(govTokenID).amount, 1000); } - it("DAO flow test", () => { + it("DAO flow test", function () { /** * Flow: * @@ -553,7 +553,7 @@ describe("DAO test", function () { } }); - it("Should not allow to vote again with newly locked tokens", () => { + it("Should not allow to vote again with newly locked tokens", function () { /** * Flow: * + Setup DAO @@ -698,7 +698,7 @@ describe("DAO test", function () { ); }); - it("Should allow to vote again with newly locked tokens for different proposal", () => { + it("Should allow to vote again with newly locked tokens for different proposal", function () { /** * Flow: * + Setup DAO @@ -830,7 +830,7 @@ describe("DAO test", function () { assert.isUndefined(proposalBLsigAcc.getLocalState(appID, "no")); // we didn't vote for "no" }); - it("Should allow to close proposal if it is passsed execution", () => { + it("Should allow to close proposal if it is passsed execution", function () { /** * Flow: * + Setup DAO diff --git a/examples/dao/test/failing-path.js b/examples/dao/test/failing-path.js index 887a36dca..296aa281b 100644 --- a/examples/dao/test/failing-path.js +++ b/examples/dao/test/failing-path.js @@ -50,7 +50,7 @@ describe("DAO - Failing Paths", function () { describe("SetUp", function () { this.beforeAll(setUpCtx); - it("should reject optin_gov_token in DAO if asa ID or fees is incorrect", () => { + it("should reject optin_gov_token in DAO if asa ID or fees is incorrect", function () { const optInToGovASAParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -82,7 +82,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("Should fail when deploy dao app because gov token doesn't exist", () => { + it("Should fail when deploy dao app because gov token doesn't exist", function () { ctx.govTokenID = 100000; // token id doesn't exist assert.throws( () => ctx.deployDAOApp(ctx.creator, "dao-app-approval.py", "dao-app-clear.py"), @@ -95,7 +95,7 @@ describe("DAO - Failing Paths", function () { this.beforeAll(setUpCtx); let proposalParams, addProposalTx; - this.beforeEach(() => { + this.beforeEach(function () { proposalParams = [ "str:add_proposal", "str:my-custom-proposal", // name @@ -122,11 +122,11 @@ describe("DAO - Failing Paths", function () { addProposalTx[1].amount = deposit; }); - it("should fail if proposalLsig not opted-in to DAO App", () => { + it("should fail if proposalLsig not opted-in to DAO App", function () { assert.throws(() => ctx.executeTx(addProposalTx), APP_NOT_FOUND); }); - it("should fail if votingEnd < votingStart", () => { + it("should fail if votingEnd < votingStart", function () { ctx.optInToDAOApp(ctx.proposalLsig.address()); // opt-in ctx.syncAccounts(); @@ -137,7 +137,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(addProposalTx), INTEGER_UNDERFLOW_ERR); }); - it('should fail if "min_duration <= votingEnd - votingStart <= max_duration" is not satisfied', () => { + it('should fail if "min_duration <= votingEnd - votingStart <= max_duration" is not satisfied', function () { // increase votingEnd (voting duration set as 9min, but allowed is 5min) proposalParams[6] = `int:${votingEnd + 10 * 60}`; addProposalTx[0].appArgs = proposalParams; @@ -145,7 +145,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); }); - it("should fail if executeBefore <= votingEnd", () => { + it("should fail if executeBefore <= votingEnd", function () { // set executeBefore < votingEnd proposalParams[7] = `int:${votingEnd - 30}`; addProposalTx[0].appArgs = proposalParams; @@ -157,7 +157,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); }); - it("should fail if proposal type is not between [1-3]", () => { + it("should fail if proposal type is not between [1-3]", function () { proposalParams[8] = "int:4"; addProposalTx[0].appArgs = proposalParams; assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); @@ -167,11 +167,11 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); }); - it("should fail if gov tokens deposit transaction is not present", () => { + it("should fail if gov tokens deposit transaction is not present", function () { assert.throws(() => ctx.executeTx({ ...addProposalTx[0] }), INDEX_OUT_OF_BOUND_ERR); }); - it("should fail if gov tokens deposit is not equal to DAO.deposit", () => { + it("should fail if gov tokens deposit is not equal to DAO.deposit", function () { addProposalTx[1].amount = deposit - 1; assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); @@ -179,12 +179,12 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); }); - it("should fail if deposit lsig address is different", () => { + it("should fail if deposit lsig address is different", function () { addProposalTx[1].toAccountAddr = ctx.proposer.address; assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); }); - it("should fail if votingStart <= now", () => { + it("should fail if votingStart <= now", function () { ctx.runtime.setRoundAndTimestamp(1, votingStart + 10); // now > votingStart assert.throws(() => ctx.executeTx(addProposalTx), RUNTIME_ERR1009); @@ -194,7 +194,7 @@ describe("DAO - Failing Paths", function () { }); describe("Deposit Vote Token", function () { - this.beforeAll(() => { + this.beforeAll(function () { ctx.addProposal(); }); @@ -203,11 +203,11 @@ describe("DAO - Failing Paths", function () { ctx.executeTx(depositVoteTx); }; - it("should fail if voterAccount is not optedIn to DAO App", () => { + it("should fail if voterAccount is not optedIn to DAO App", function () { assert.throws(() => _depositVoteToken(ctx.voterA.account, 6), APP_NOT_FOUND); }); - it("should fail if gov tokens deposit transaction is not present", () => { + it("should fail if gov tokens deposit transaction is not present", function () { ctx.optInToDAOApp(ctx.voterA.address); ctx.optInToDAOApp(ctx.voterB.address); ctx.syncAccounts(); @@ -221,7 +221,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx({ ...txParams[0] }), INDEX_OUT_OF_BOUND_ERR); }); - it("should fail if receiver is not depositAcc", () => { + it("should fail if receiver is not depositAcc", function () { const txP = mkDepositVoteTokenTx(ctx.daoAppID, ctx.govTokenID, ctx.voterA.account, 6); assert.throws( () => @@ -236,7 +236,7 @@ describe("DAO - Failing Paths", function () { describe("Vote", function () { let registerVoteParam; - this.beforeEach(() => { + this.beforeEach(function () { registerVoteParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -254,7 +254,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if proposalLsig address is not passed", () => { + it("should fail if proposalLsig address is not passed", function () { assert.throws( () => ctx.executeTx({ @@ -265,7 +265,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if no gov tokens are deposited", () => { + it("should fail if no gov tokens are deposited", function () { // voterB hasn't deposited gov tokens yet assert.throws( () => ctx.executeTx({ ...registerVoteParam, fromAccount: ctx.voterB.account }), @@ -273,7 +273,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if a user votes again for the same proposal (double voting)", () => { + it("should fail if a user votes again for the same proposal (double voting)", function () { // user deposits gov tokens for voting (OK) ctx.depositVoteToken(ctx.voterA, 6); @@ -290,7 +290,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if latest_timestamp is < votingStart (i.e voting is not open)", () => { + it("should fail if latest_timestamp is < votingStart (i.e voting is not open)", function () { // set now < votingStart ctx.runtime.setRoundAndTimestamp(10, votingStart - 30); @@ -303,7 +303,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if latest_timestamp is > votingEnd (i.e voting is not open)", () => { + it("should fail if latest_timestamp is > votingEnd (i.e voting is not open)", function () { // set now > votingEnd ctx.runtime.setRoundAndTimestamp(10, votingEnd + 30); @@ -316,7 +316,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should fail if latest_timestamp is > executeBefore (i.e voting is not open)", () => { + it("should fail if latest_timestamp is > executeBefore (i.e voting is not open)", function () { // set now > executeBefore ctx.runtime.setRoundAndTimestamp(10, executeBefore + 30); @@ -347,7 +347,7 @@ describe("DAO - Failing Paths", function () { this.beforeEach(resetCtx); let executeProposalTx; - this.beforeEach(() => { + this.beforeEach(function () { executeProposalTx = [ { type: types.TransactionType.CallApp, @@ -374,25 +374,25 @@ describe("DAO - Failing Paths", function () { ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); }); - it("should reject execute if proposal is expired", () => { + it("should reject execute if proposal is expired", function () { // set current time as > executeBefore ctx.runtime.setRoundAndTimestamp(10, executeBefore + 30); assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("execution should fail if now < votingStart (before voting started)", () => { + it("execution should fail if now < votingStart (before voting started)", function () { // set current time as > executeBefore ctx.runtime.setRoundAndTimestamp(10, votingStart - 30); assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("should reject execute if voting is still in progress", () => { + it("should reject execute if voting is still in progress", function () { // set current time when "voting is active" ctx.runtime.setRoundAndTimestamp(10, votingStart + 30); assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("should reject execution if proposal.yes < min_support", () => { + it("should reject execution if proposal.yes < min_support", function () { // register votes by A (< min_support) ctx.depositVoteToken(ctx.voterA, minSupport - 1); ctx.vote(ctx.voterA, Vote.YES, ctx.proposalLsigAcc); @@ -400,7 +400,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("should reject execution if proposal.yes > min_support, but vote.no > vote.yes", () => { + it("should reject execution if proposal.yes > min_support, but vote.no > vote.yes", function () { // register 2 more votes by A (> min_support) ctx.depositVoteToken(ctx.voterA, minSupport + 1); ctx.vote(ctx.voterA, Vote.YES, ctx.proposalLsigAcc); @@ -412,7 +412,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("should reject execution if proposal already executed", () => { + it("should reject execution if proposal already executed", function () { // register yes votes ctx.depositVoteToken(ctx.voterA, minSupport + 1); ctx.vote(ctx.voterA, Vote.YES, ctx.proposalLsigAcc); @@ -423,7 +423,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(executeProposalTx), RUNTIME_ERR1009); }); - it("should reject execution if 2nd transaction not included", () => { + it("should reject execution if 2nd transaction not included", function () { // register yes votes ctx.depositVoteToken(ctx.voterA, minSupport + 1); ctx.vote(ctx.voterA, Vote.YES, ctx.proposalLsigAcc); @@ -431,7 +431,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx({ ...executeProposalTx[0] }), INDEX_OUT_OF_BOUND_ERR); }); - it("should reject execution if 2nd transaction is not per proposal instructions", () => { + it("should reject execution if 2nd transaction is not per proposal instructions", function () { // register yes votes ctx.depositVoteToken(ctx.voterA, minSupport + 1); ctx.vote(ctx.voterA, Vote.YES, ctx.proposalLsigAcc); @@ -470,16 +470,16 @@ describe("DAO - Failing Paths", function () { ); }); - it("Should reject if fee paid by daoFundLsig", () => { + it("Should reject if fee paid by daoFundLsig", function () { executeProposalTx[1].payFlags.totalFee = 3000; - assert.throw(() => { + assert.throw(function () { ctx.executeTx(executeProposalTx); }, RUNTIME_ERR1009); }); }); describe("Withdraw Vote Deposit", function () { - this.beforeAll(() => { + this.beforeAll(function () { // set up context setUpCtx(); @@ -505,7 +505,7 @@ describe("DAO - Failing Paths", function () { }); let withdrawVoteDepositTx; - this.beforeEach(() => { + this.beforeEach(function () { withdrawVoteDepositTx = mkWithdrawVoteDepositTx( ctx.daoAppID, ctx.govTokenID, @@ -517,7 +517,7 @@ describe("DAO - Failing Paths", function () { ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); }); - it("should reject withdrawal if voting is active", () => { + it("should reject withdrawal if voting is active", function () { // set current time between [votingStart, votingEnd] ctx.runtime.setRoundAndTimestamp( 10, @@ -527,14 +527,14 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(withdrawVoteDepositTx), RUNTIME_ERR1009); }); - it("should reject withdrawal if total fees is not paid by sender", () => { + it("should reject withdrawal if total fees is not paid by sender", function () { assert.throws( () => ctx.executeTx({ ...withdrawVoteDepositTx, payFlags: { totalFee: 1000 } }), RUNTIME_ERR1406 ); }); - it("should reject withdrawal if groupsize not valid", () => { + it("should reject withdrawal if groupsize not valid", function () { assert.throws( () => ctx.executeTx([ @@ -548,7 +548,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should reject withdrawal trying to withdraw more than deposited", () => { + it("should reject withdrawal trying to withdraw more than deposited", function () { const origDeposit = ctx.voterA.getLocalState(ctx.daoAppID, "deposit"); assert.throws( () => @@ -560,7 +560,7 @@ describe("DAO - Failing Paths", function () { ); }); - it("should allow partial withdrawals", () => { + it("should allow partial withdrawals", function () { const origDeposit = ctx.voterA.getLocalState(ctx.daoAppID, "deposit"); // we use voterB for withdrawal here withdrawVoteDepositTx = mkWithdrawVoteDepositTx( @@ -583,7 +583,7 @@ describe("DAO - Failing Paths", function () { }); }); - it("should reject on overflow in partial withdrawals", () => { + it("should reject on overflow in partial withdrawals", function () { const origDeposit = ctx.voterA.getLocalState(ctx.daoAppID, "deposit"); // withdraw 1 gov token @@ -605,7 +605,7 @@ describe("DAO - Failing Paths", function () { }); describe("Clear Vote Record", function () { - this.beforeAll(() => { + this.beforeAll(function () { // set up context setUpCtx(); @@ -624,7 +624,7 @@ describe("DAO - Failing Paths", function () { }); let clearVoteRecordTx; - this.beforeEach(() => { + this.beforeEach(function () { clearVoteRecordTx = mkClearVoteRecordTx( ctx.daoAppID, ctx.voterA.account, @@ -632,14 +632,14 @@ describe("DAO - Failing Paths", function () { ); }); - it("should reject clear voting record if proposal is active(passed but not executed)", () => { + it("should reject clear voting record if proposal is active(passed but not executed)", function () { // set current time after voting over ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); assert.throws(() => ctx.executeTx(clearVoteRecordTx), RUNTIME_ERR1009); }); - it("should reject clear voting record if propsal is active(still in voting)", () => { + it("should reject clear voting record if propsal is active(still in voting)", function () { // set current time between [votingStart, votingEnd] ctx.runtime.setRoundAndTimestamp( 10, @@ -651,7 +651,7 @@ describe("DAO - Failing Paths", function () { assert.throws(() => ctx.executeTx(clearVoteRecordTx), RUNTIME_ERR1009); }); - it("should reject tx if groupSize !== 1", () => { + it("should reject tx if groupSize !== 1", function () { assert.throws( () => ctx.executeTx([ @@ -664,7 +664,7 @@ describe("DAO - Failing Paths", function () { }); describe("Close Proposal", function () { - this.beforeAll(() => { + this.beforeAll(function () { // set up context setUpCtx(); @@ -679,15 +679,15 @@ describe("DAO - Failing Paths", function () { }); let closeProposalTx; - this.beforeEach(() => { + this.beforeEach(function () { closeProposalTx = mkCloseProposalTx(ctx.daoAppID, ctx.govTokenID, ctx.proposalLsig); }); - it("should reject close_proposal if proposal is not recorded in lsig", () => { + it("should reject close_proposal if proposal is not recorded in lsig", function () { assert.throws(() => ctx.executeTx(closeProposalTx), RUNTIME_ERR1009); }); - it("should reject close_proposal if group size is invalid", () => { + it("should reject close_proposal if group size is invalid", function () { assert.throws( () => ctx.executeTx([ @@ -698,14 +698,14 @@ describe("DAO - Failing Paths", function () { ); }); - it("should reject close_proposal if fees not enough", () => { + it("should reject close_proposal if fees not enough", function () { assert.throws( () => ctx.executeTx([{ ...closeProposalTx, payFlags: { totalFee: 1000 } }]), RUNTIME_ERR1009 ); }); - it("should reject close_proposal if voting is active", () => { + it("should reject close_proposal if voting is active", function () { // set current time between [votingStart, votingEnd] ctx.runtime.setRoundAndTimestamp( 10, diff --git a/examples/dao/test/happy-path.js b/examples/dao/test/happy-path.js index 0e9e4446e..5be8e7886 100644 --- a/examples/dao/test/happy-path.js +++ b/examples/dao/test/happy-path.js @@ -73,7 +73,7 @@ describe("DAO - Happy Paths", function () { describe("Add proposal", function () { let proposalParams, addProposalTx; - this.beforeEach(() => { + this.beforeEach(function () { setUpCtx(); proposalParams = [ @@ -104,7 +104,7 @@ describe("DAO - Happy Paths", function () { ctx.optInToDAOApp(ctx.proposalLsig.address()); // opt-in }); - it("should save proposal config in proposalLsig for ALGO transfer (type == 1)", () => { + it("should save proposal config in proposalLsig for ALGO transfer (type == 1)", function () { ctx.executeTx(addProposalTx); ctx.syncAccounts(); @@ -153,7 +153,7 @@ describe("DAO - Happy Paths", function () { assert.deepEqual(ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "amount"), BigInt(2e6)); }); - it("should save proposal config in proposalLsig for ASA transfer (type == 2)", () => { + it("should save proposal config in proposalLsig for ASA transfer (type == 2)", function () { addProposalTx[0].appArgs = [ ...proposalParams.splice(0, 8), `int:${ProposalType.ASA_TRANSFER}`, // type @@ -185,7 +185,7 @@ describe("DAO - Happy Paths", function () { assert.deepEqual(ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "amount"), 10n); }); - it("should save proposal config in proposalLsig for message (type == 3)", () => { + it("should save proposal config in proposalLsig for message (type == 3)", function () { addProposalTx[0].appArgs = [ ...proposalParams.splice(0, 8), `int:${ProposalType.MESSAGE}`, // type @@ -202,7 +202,7 @@ describe("DAO - Happy Paths", function () { }); describe("Deposit Vote Token", function () { - this.beforeAll(() => { + this.beforeAll(function () { setUpCtx(); ctx.optInToDAOApp(ctx.proposalLsig.address()); // opt-in ctx.addProposal(); @@ -224,7 +224,7 @@ describe("DAO - Happy Paths", function () { ctx.syncAccounts(); }; - it("should accept token deposit", () => { + it("should accept token deposit", function () { const beforeBal = ctx.depositAcc.getAssetHolding(ctx.govTokenID).amount; _depositVoteToken(ctx.voterA.account, 6); @@ -236,7 +236,7 @@ describe("DAO - Happy Paths", function () { assert.deepEqual(ctx.depositAcc.getAssetHolding(ctx.govTokenID).amount, beforeBal + 6n); }); - it("should accept multiple token deposit by same & different accounts", () => { + it("should accept multiple token deposit by same & different accounts", function () { const beforeBal = ctx.depositAcc.getAssetHolding(ctx.govTokenID).amount; const initialADeposit = ctx.voterA.getLocalState(ctx.daoAppID, "deposit"); @@ -271,7 +271,7 @@ describe("DAO - Happy Paths", function () { ); }); - it('should allow token deposit by any "from" account', () => { + it('should allow token deposit by any "from" account', function () { const beforeBal = ctx.depositAcc.getAssetHolding(ctx.govTokenID).amount; const initialADeposit = ctx.voterA.getLocalState(ctx.daoAppID, "deposit"); @@ -296,7 +296,7 @@ describe("DAO - Happy Paths", function () { describe("Vote", function () { let registerVoteParam; - this.beforeEach(() => { + this.beforeEach(function () { registerVoteParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -328,7 +328,7 @@ describe("DAO - Happy Paths", function () { ); }); - it("should allow voterA to register deposited tokens as votes", () => { + it("should allow voterA to register deposited tokens as votes", function () { ctx.executeTx(registerVoteParam); ctx.syncAccounts(); @@ -344,7 +344,7 @@ describe("DAO - Happy Paths", function () { assert.equal(ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "yes"), 6n); }); - it("should allow voterB to register gov tokens as votes after voterA", () => { + it("should allow voterB to register gov tokens as votes after voterA", function () { const yesVotes = ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "yes"); const key = new Uint8Array([ ...parsing.stringToBytes("p_"), @@ -373,7 +373,7 @@ describe("DAO - Happy Paths", function () { assert.equal(ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "yes"), yesVotes + 6n + 4n); }); - it("should allow voting if already set proposal_id is different", () => { + it("should allow voting if already set proposal_id is different", function () { // vote by A ctx.executeTx(registerVoteParam); ctx.syncAccounts(); @@ -392,7 +392,7 @@ describe("DAO - Happy Paths", function () { describe("Execute", function () { let executeProposalTx; - this.beforeEach(() => { + this.beforeEach(function () { ctx.syncAccounts(); executeProposalTx = [ { @@ -442,7 +442,7 @@ describe("DAO - Happy Paths", function () { ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); }); - it("should execute proposal for type == 1 (ALGO TRANSFER)", () => { + it("should execute proposal for type == 1 (ALGO TRANSFER)", function () { const beforeProposerBal = ctx.proposer.balance(); ctx.executeTx(executeProposalTx); ctx.syncAccounts(); @@ -454,7 +454,7 @@ describe("DAO - Happy Paths", function () { assert.equal(ctx.proposer.balance(), beforeProposerBal + BigInt(2e6) - 2000n); }); - it("should execute proposal for type == 2 (ASA TRANSFER)", () => { + it("should execute proposal for type == 2 (ASA TRANSFER)", function () { const config = { type: BigInt(ProposalType.ASA_TRANSFER), from: parsing.addressToPk(ctx.daoFundLsig.address()), @@ -492,7 +492,7 @@ describe("DAO - Happy Paths", function () { ); }); - it("should execute proposal for type == 3 (MESSAGE)", () => { + it("should execute proposal for type == 3 (MESSAGE)", function () { const config = { type: BigInt(ProposalType.MESSAGE), msg: parsing.stringToBytes("my-message"), @@ -514,7 +514,7 @@ describe("DAO - Happy Paths", function () { assert.equal(ctx.proposalLsigAcc.getLocalState(ctx.daoAppID, "executed"), 1n); }); - it("should allow anyone to execute proposal", () => { + it("should allow anyone to execute proposal", function () { executeProposalTx[0].fromAccount = ctx.voterA.account; assert.doesNotThrow(() => ctx.executeTx(executeProposalTx)); @@ -529,7 +529,7 @@ describe("DAO - Happy Paths", function () { this.beforeAll(resetCtx); let withdrawVoteDepositTx; - this.beforeEach(() => { + this.beforeEach(function () { withdrawVoteDepositTx = mkWithdrawVoteDepositTx( ctx.daoAppID, ctx.govTokenID, @@ -538,7 +538,7 @@ describe("DAO - Happy Paths", function () { ); }); - it("should allow withdrawal after voting is over", () => { + it("should allow withdrawal after voting is over", function () { // set current time after voting over ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); ctx.syncAccounts(); @@ -581,7 +581,7 @@ describe("DAO - Happy Paths", function () { describe("Clear Vote Record", function () { this.beforeAll(resetCtx); - it("should clear voting record if proposal is not active", () => { + it("should clear voting record if proposal is not active", function () { // set current time after voting over ctx.runtime.setRoundAndTimestamp(10, votingEnd + 10); @@ -619,7 +619,7 @@ describe("DAO - Happy Paths", function () { }); describe("Close Proposal", function () { - this.beforeAll(() => { + this.beforeAll(function () { // set up context setUpCtx(); @@ -632,7 +632,7 @@ describe("DAO - Happy Paths", function () { ctx.addProposal(); }); - it("should close proposal if proposal is recorded & voting is not active", () => { + it("should close proposal if proposal is recorded & voting is not active", function () { // set current time after executeBefore ctx.runtime.setRoundAndTimestamp(10, executeBefore + 10); diff --git a/examples/inner-tx-create-assets/test/groupTxn.js b/examples/inner-tx-create-assets/test/groupTxn.js index 401a8cbf7..f4b64b92d 100644 --- a/examples/inner-tx-create-assets/test/groupTxn.js +++ b/examples/inner-tx-create-assets/test/groupTxn.js @@ -6,7 +6,7 @@ describe("Group txn", function () { let runtime; let creator; let proxyAppInfo; - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [creator] = runtime.defaultAccounts(); proxyAppInfo = runtime.deployApp( @@ -26,7 +26,7 @@ describe("Group txn", function () { ); }); - it("Should create new app and asset from group id", () => { + it("Should create new app and asset from group id", function () { // first tx in group: deploy new app // the same code is used for coordinator contract const createAppTxnParam = { diff --git a/examples/inner-tx-create-assets/test/innerTxn.js b/examples/inner-tx-create-assets/test/innerTxn.js index 51cbfdf57..5822ec3c7 100644 --- a/examples/inner-tx-create-assets/test/innerTxn.js +++ b/examples/inner-tx-create-assets/test/innerTxn.js @@ -6,7 +6,7 @@ describe("Group txn", function () { let runtime; let creator; let proxyAppInfo; - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [creator] = runtime.defaultAccounts(); proxyAppInfo = runtime.deployApp( @@ -36,7 +36,7 @@ describe("Group txn", function () { runtime.executeTx([paymentTxnParam]); }); - it("Should create new app and asset from inner txn", () => { + it("Should create new app and asset from inner txn", function () { // create asset and log new asset id const masterTxnParam = { type: types.TransactionType.CallApp, diff --git a/examples/permissioned-token-freezing/test/asset-txfer-test.js b/examples/permissioned-token-freezing/test/asset-txfer-test.js index 98748bb54..9dff087f2 100644 --- a/examples/permissioned-token-freezing/test/asset-txfer-test.js +++ b/examples/permissioned-token-freezing/test/asset-txfer-test.js @@ -91,7 +91,7 @@ describe("Test for transferring asset using custom logic", function () { } } - it("should transfer 1000 Assets from Alice to Bob according to custom logic", () => { + it("should transfer 1000 Assets from Alice to Bob according to custom logic", function () { /** * This test demonstrates how to transfer assets from account A to B using custom logic * based on a smart contract. Asset is actually transferred by the clawback address (an escrow @@ -230,7 +230,7 @@ describe("Test for transferring asset using custom logic", function () { assert.equal(afterBobAssets, prevBobAssets + 1000n); // Bob received 1000 GLD }); - it("should fail on set level if sender is not creator", () => { + it("should fail on set level if sender is not creator", function () { // opt in to app runtime.optInToApp(alice.address, applicationId, {}, {}); runtime.optInToApp(bob.address, applicationId, {}, {}); @@ -263,7 +263,7 @@ describe("Test for transferring asset using custom logic", function () { } }); - it("should reject transaction if minimum level is not set correctly", () => { + it("should reject transaction if minimum level is not set correctly", function () { assetId = runtime.deployASA("gold", { creator: { ...alice.account, name: "alice" }, }).assetIndex; diff --git a/examples/permissioned-token/test/failing-paths.js b/examples/permissioned-token/test/failing-paths.js index 3f9faff21..84601f87c 100644 --- a/examples/permissioned-token/test/failing-paths.js +++ b/examples/permissioned-token/test/failing-paths.js @@ -26,14 +26,14 @@ describe("Permissioned Token Tests - Failing Paths", function () { describe("Token Issuance", function () { this.beforeAll(setUpCtx); - it("should not issue token if receiver is not opted in", () => { + it("should not issue token if receiver is not opted in", function () { assert.throws( () => ctx.issue(asaReserve.account, elon, 20), `RUNTIME_ERR1404: Account ${elon.address} doesn't hold asset index ${ctx.assetIndex}` ); }); - it("should not issue if token is killed", () => { + it("should not issue if token is killed", function () { // Opt-in to ASA by receiver ctx.optInToASA(elon.address); @@ -41,13 +41,13 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.issue(asaReserve.account, elon, 20), RUNTIME_ERR1009); }); - it("should reject issuance tx if sender is not token reserve", () => { + it("should reject issuance tx if sender is not token reserve", function () { // Opt-in to ASA by receiver ctx.optInToASA(elon.address); assert.throws(() => ctx.issue(bob.account, elon, 20), RUNTIME_ERR1009); }); - it("should reject issuance tx if trying to send asset using secret key instead of clawback", () => { + it("should reject issuance tx if trying to send asset using secret key instead of clawback", function () { // Opt-in to ASA by receiver ctx.optInToASA(elon.address); @@ -74,7 +74,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { describe("Kill Token", function () { this.beforeAll(setUpCtx); - it("should reject tx to kill token if sender is not token manager", () => { + it("should reject tx to kill token if sender is not token manager", function () { // verify bob is not token manager assert.notEqual(asaManager.address, bob.address); // fails: bob trying to kill token @@ -86,7 +86,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let permManagerAddr, permManager, whitelistParams; - this.beforeEach(() => { + this.beforeEach(function () { permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -103,7 +103,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { }; }); - it("should reject account whitelist if the account doesn't opt-in to permissions app", () => { + it("should reject account whitelist if the account doesn't opt-in to permissions app", function () { // verify account not opted in assert.isUndefined(ctx.elon.getAppFromLocal(ctx.permissionsappID)); @@ -114,7 +114,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("should not whitelist account if sender is not current permissions manager", () => { + it("should not whitelist account if sender is not current permissions manager", function () { // opt-in to permissions by elon ctx.optInToPermissionsSSC(elon.address); ctx.syncAccounts(); @@ -136,7 +136,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { }); describe("Opt Out", function () { - it("should reject tx if user not opted-in", () => { + it("should reject tx if user not opted-in", function () { const asaCreator = ctx.getAccount(asaDef.creator); assert.throws( () => ctx.optOut(asaCreator.address, elon.account), @@ -148,7 +148,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { describe("Change Permissions Manager", function () { this.beforeAll(setUpCtx); - it("should fail if sender is not current permissions manager", () => { + it("should fail if sender is not current permissions manager", function () { const permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -177,7 +177,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let permManagerAddr, permManager, forceTransferGroup; - this.beforeEach(() => { + this.beforeEach(function () { permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -230,7 +230,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ]; }); - it("Should fail on force transfer if transaction group is not valid", () => { + it("Should fail on force transfer if transaction group is not valid", function () { const forceTxGroup = [...forceTransferGroup]; // fails as permissions is not called @@ -255,14 +255,14 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("should reject transfer if transaction group is valid but controller.sender is not equal to asset.sender", () => { + it("should reject transfer if transaction group is valid but controller.sender is not equal to asset.sender", function () { const forceTxGroup = [...forceTransferGroup]; forceTxGroup[0].fromAccount = elon.account; assert.throws(() => ctx.runtime.executeTx(forceTxGroup), RUNTIME_ERR1009); }); - it("Should reject force transfer if accounts are not whitelisted", () => { + it("Should reject force transfer if accounts are not whitelisted", function () { // Issue some tokens to sender ctx.issue(asaReserve.account, bob, 150); ctx.syncAccounts(); @@ -287,7 +287,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ctx.forceTransfer(asaManager.account, bob, elon, 20); }); - it("Should reject transfer if sender is not token manager", () => { + it("Should reject transfer if sender is not token manager", function () { // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, elon.address); ctx.whitelist(permManager.account, bob.address); @@ -302,7 +302,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.forceTransfer(bob.account, bob, elon, 20), RUNTIME_ERR1009); }); - it("Should reject force transfer if accounts are whitelisted but receiver balance becomes > 100", () => { + it("Should reject force transfer if accounts are whitelisted but receiver balance becomes > 100", function () { // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, elon.address); ctx.whitelist(permManager.account, bob.address); @@ -319,7 +319,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("Should reject force transfer if token is killed", () => { + it("Should reject force transfer if token is killed", function () { // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, elon.address); ctx.whitelist(permManager.account, bob.address); @@ -342,7 +342,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let permManagerAddr, permManager, tokenTransferGroup; - this.beforeEach(() => { + this.beforeEach(function () { permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -394,7 +394,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ]; }); - it("Should fail if transaction group is not valid", () => { + it("Should fail if transaction group is not valid", function () { const txGroup = [...tokenTransferGroup]; // fails as permissions is not called @@ -419,14 +419,14 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("should reject transfer if transaction group is valid but controller.sender is not equal to asset.sender", () => { + it("should reject transfer if transaction group is valid but controller.sender is not equal to asset.sender", function () { const txGroup = [...tokenTransferGroup]; txGroup[0].fromAccount = elon.account; assert.throws(() => ctx.runtime.executeTx(txGroup), RUNTIME_ERR1009); }); - it("should reject transfer if sender trying to transfer token using secret key instead of clawback", () => { + it("should reject transfer if sender trying to transfer token using secret key instead of clawback", function () { const assetTransferParams = { type: types.TransactionType.TransferAsset, sign: types.SignType.SecretKey, @@ -444,7 +444,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("Should reject transfer if accounts are not whitelisted", () => { + it("Should reject transfer if accounts are not whitelisted", function () { // Issue some tokens to sender ctx.issue(asaReserve.account, bob, 150); ctx.syncAccounts(); @@ -463,7 +463,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ctx.transfer(bob, elon, 20); }); - it("Should reject force transfer if accounts are whitelisted but receiver balance becomes > 100", () => { + it("Should reject force transfer if accounts are whitelisted but receiver balance becomes > 100", function () { // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, elon.address); ctx.whitelist(permManager.account, bob.address); @@ -477,7 +477,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.transfer(bob, elon, 105), RUNTIME_ERR1009); }); - it("should reject transfer if rules are followed, but token is killed", () => { + it("should reject transfer if rules are followed, but token is killed", function () { // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, elon.address); ctx.whitelist(permManager.account, bob.address); @@ -497,7 +497,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let updateReserveParams; - this.beforeEach(() => { + this.beforeEach(function () { const oldReserveAssetHolding = ctx.getAssetHolding(asaReserve.address); const newReserveAddr = elon.address; ctx.optInToASA(newReserveAddr); @@ -548,7 +548,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ]; }); - it("Should fail if transaction group is not valid", () => { + it("Should fail if transaction group is not valid", function () { const txGroup = [...updateReserveParams]; // fails as paying fees of clawback-lsig is skipped @@ -564,7 +564,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("should reject update if controller.sender is not asset manager", () => { + it("should reject update if controller.sender is not asset manager", function () { const txGroup = [...updateReserveParams]; txGroup[0].fromAccount = bob.account; @@ -573,7 +573,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.runtime.executeTx(txGroup), RUNTIME_ERR1009); }); - it("should reject update if sender of asset config tx is not asset manager", () => { + it("should reject update if sender of asset config tx is not asset manager", function () { const txGroup = [...updateReserveParams]; txGroup[3].fromAccount = bob.account; @@ -590,7 +590,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let permManagerAddr, permManager, ceaseTxGroup; - this.beforeEach(() => { + this.beforeEach(function () { permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -630,7 +630,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { ]; }); - it("Should fail if transaction group is invalid", () => { + it("Should fail if transaction group is invalid", function () { const txGroup = [...ceaseTxGroup]; // fails because paying fees of clawback-lsig is skipped @@ -640,7 +640,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.runtime.executeTx([txGroup[1], txGroup[2]]), REJECTED_BY_LOGIC); }); - it("should reject cease if call to controller is not signed by asset manager", () => { + it("should reject cease if call to controller is not signed by asset manager", function () { const txGroup = [...ceaseTxGroup]; txGroup[0].fromAccount = bob.account; @@ -649,7 +649,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.runtime.executeTx(txGroup), RUNTIME_ERR1009); }); - it("Should fail if trying to cease more tokens than issued", () => { + it("Should fail if trying to cease more tokens than issued", function () { const txGroup = [...ceaseTxGroup]; // Opt-In to permissions SSC & Whitelist ctx.whitelist(permManager.account, bob.address); @@ -669,21 +669,21 @@ describe("Permissioned Token Tests - Failing Paths", function () { ); }); - it("Should fail token index is not valid", () => { + it("Should fail token index is not valid", function () { const txGroup = [...ceaseTxGroup]; txGroup[0].foreignAssets = [99]; assert.throws(() => ctx.runtime.executeTx(txGroup), RUNTIME_ERR1009); }); - it("Should fail if sufficient fees is not covered in fee payment tx", () => { + it("Should fail if sufficient fees is not covered in fee payment tx", function () { const txGroup = [...ceaseTxGroup]; txGroup[2].amountMicroAlgos = txGroup[1].payFlags.totalFee - 100; assert.throws(() => ctx.runtime.executeTx(txGroup), REJECTED_BY_LOGIC); }); - it("should reject cease if token is killed", () => { + it("should reject cease if token is killed", function () { const txGroup = [...ceaseTxGroup]; ctx.whitelist(permManager.account, bob.address); ctx.issue(asaReserve.account, bob, 200); @@ -699,7 +699,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { this.beforeAll(setUpCtx); let setPermissionsParams; - this.beforeEach(() => { + this.beforeEach(function () { const appArgs = ["str:set_permission", `int:${ctx.permissionsappID}`]; setPermissionsParams = { type: types.TransactionType.CallApp, @@ -713,7 +713,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { }); // note: in current version controller.manager == asa.manager - it("should reject if sender of controller is not asa.manager", () => { + it("should reject if sender of controller is not asa.manager", function () { // verify first elon is not asset manager assert.notEqual(asaManager.address, ctx.elon.address); @@ -721,7 +721,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { assert.throws(() => ctx.runtime.executeTx([setPermissionsParams]), RUNTIME_ERR1009); }); - it("should reject if application args are incorrect", () => { + it("should reject if application args are incorrect", function () { setPermissionsParams.appArgs = ["str:set_Permission", `int:${ctx.permissionsappID}`]; assert.throws(() => ctx.runtime.executeTx([setPermissionsParams]), RUNTIME_ERR1009); }); @@ -730,7 +730,7 @@ describe("Permissioned Token Tests - Failing Paths", function () { * Important test: here we deploy a new asset(with same manager as the original one), * but since token index will be different, tx is rejected. Means that we cannot bypass * the contract even if manager (OR other asset params) are same as the original. */ - it("should reject if asset index is incorrect even if manager is same", () => { + it("should reject if asset index is incorrect even if manager is same", function () { // deploy new asset with same manager(alice) as original one const newAssetId = ctx.runtime.deployASA("tesla", { creator: { ...ctx.alice.account, name: "alice" }, diff --git a/examples/permissioned-token/test/happy-paths.js b/examples/permissioned-token/test/happy-paths.js index dfd2ebb9e..19262fe0c 100644 --- a/examples/permissioned-token/test/happy-paths.js +++ b/examples/permissioned-token/test/happy-paths.js @@ -22,7 +22,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { this.beforeAll(setUpCtx); - it("should issue token if sender is token reserve", () => { + it("should issue token if sender is token reserve", function () { // Can issue after opting-in ctx.optInToASA(elon.address); @@ -35,7 +35,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.getAssetHolding(elon.address).amount, prevElonAssetHolding.amount + 20n); }); - it("should kill token if sender is token manager", () => { + it("should kill token if sender is token manager", function () { assert.equal(ctx.runtime.getGlobalState(ctx.controllerappID, "killed"), 0n); // token not killed // kill token @@ -50,7 +50,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { ); }); - it("should whitelist account if sender is permissions manager", () => { + it("should whitelist account if sender is permissions manager", function () { // opt-in to permissions app by elon ctx.optInToPermissionsSSC(elon.address); ctx.syncAccounts(); @@ -65,7 +65,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.elon.getLocalState(ctx.permissionsappID, "whitelisted"), 1n); }); - it("should opt-out of token successfully (using closeRemainderTo)", () => { + it("should opt-out of token successfully (using closeRemainderTo)", function () { setUpCtx(); // Opt-In @@ -89,7 +89,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { ); }); - it("should change Permissions SSC Manager if sender is current_permissions_manager", () => { + it("should change Permissions SSC Manager if sender is current_permissions_manager", function () { // throws error as elon is not permissions manager assert.throws( () => ctx.whitelist(elon.account, bob.address), @@ -127,7 +127,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.bob.getLocalState(ctx.permissionsappID, "whitelisted"), 1n); }); - it("should force transfer tokens between non reserve accounts successfully if sender is token manager", () => { + it("should force transfer tokens between non reserve accounts successfully if sender is token manager", function () { const permManagerAddr = encodeAddress( ctx.runtime.getGlobalState(ctx.permissionsappID, "manager") ); @@ -153,7 +153,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.getAssetHolding(elon.address).amount, initialElonBalance + 20n); }); - it("should force transfer tokens without permission checks if receiver is asset reserve", () => { + it("should force transfer tokens without permission checks if receiver is asset reserve", function () { // Opt-In to ASA ctx.optInToASA(bob.address); ctx.optInToASA(elon.address); @@ -202,7 +202,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.getAssetHolding(asaReserve.address).amount, initialReserveBalance + 20n); }); - it("should transfer tokens between non reserve accounts successfully", () => { + it("should transfer tokens between non reserve accounts successfully", function () { ctx.syncAccounts(); const amount = 20n; @@ -234,7 +234,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { assert.equal(ctx.getAssetHolding(elon.address).amount, initialElonBalance + amount); }); - it("should update asset reserve account to another address if sender is asset manager", () => { + it("should update asset reserve account to another address if sender is asset manager", function () { const oldReserveAssetHolding = ctx.getAssetHolding(asaReserve.address); const newReserveAddr = elon.address; assert.notEqual(asaReserve.address, newReserveAddr); // verify old reserve is not elon.addr @@ -299,7 +299,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { ); }); - it("should cease tokens from bob", () => { + it("should cease tokens from bob", function () { setUpCtx(); // Opt-In to ASA ctx.optInToASA(bob.address); @@ -353,7 +353,7 @@ describe("Permissioned Token Tests - Happy Paths", function () { ); }); - it("should set new permissions appID in controller", () => { + it("should set new permissions appID in controller", function () { // perm_app_id from controller's global state const currentPermAppID = ctx.runtime.getGlobalState(ctx.controllerappID, "perm_app"); const newPermAppID = 99; // some random value for test diff --git a/examples/unique-nft-asa/test/test.js b/examples/unique-nft-asa/test/test.js index 8690af8c6..15d24d11a 100644 --- a/examples/unique-nft-asa/test/test.js +++ b/examples/unique-nft-asa/test/test.js @@ -106,8 +106,8 @@ describe("Unique NFT ASA tests", function () { statelessLsigAcc = runtime.getAccount(statelessLsig.address()); } - describe("Happy paths", () => { - it("should create NFT by C_p", () => { + describe("Happy paths", function () { + it("should create NFT by C_p", function () { const beforeCreatorBal = creator.balance(); runtime.executeTx(createNftTxGroup); @@ -132,13 +132,13 @@ describe("Unique NFT ASA tests", function () { assert.deepEqual(assetInfo.assetDef.decimals, 0); }); - it("should allow creation of NFT, if payment is not done by creator", () => { + it("should allow creation of NFT, if payment is not done by creator", function () { // payment of 1 ALGO by bob createNftTxGroup[0].fromAccount = bob.account; assert.doesNotThrow(() => runtime.executeTx(createNftTxGroup)); }); - it("should transfer NFT from C_p => Creator", () => { + it("should transfer NFT from C_p => Creator", function () { runtime.executeTx(createNftTxGroup); syncAccounts(); @@ -166,9 +166,9 @@ describe("Unique NFT ASA tests", function () { }); }); - describe("failing paths", () => { - describe("Create NFT", () => { - it("should reject creation if deploying same NFT again (with same C_p)", () => { + describe("failing paths", function () { + describe("Create NFT", function () { + it("should reject creation if deploying same NFT again (with same C_p)", function () { runtime.executeTx(createNftTxGroup); assert.throws( @@ -177,7 +177,7 @@ describe("Unique NFT ASA tests", function () { ); }); - it("should reject creation if payment amount is not 1 ALGO", () => { + it("should reject creation if payment amount is not 1 ALGO", function () { createNftTxGroup[0].amountMicroAlgos = 0.9e6; // 0.9 ALGO assert.throws(() => runtime.executeTx(createNftTxGroup), REJECTED_BY_LOGIC); @@ -185,14 +185,14 @@ describe("Unique NFT ASA tests", function () { assert.throws(() => runtime.executeTx(createNftTxGroup), REJECTED_BY_LOGIC); }); - it("should reject creation if prime(p) is not correct", () => { + it("should reject creation if prime(p) is not correct", function () { // stateless_lsig is made of p=3 (hardcoded), but in appArgs we pass p=7 createNftTxGroup[1].appArgs = [`int:${7}`]; assert.throws(() => runtime.executeTx(createNftTxGroup), REJECTED_BY_LOGIC); }); - it("should reject creation if txGroup is invalid", () => { + it("should reject creation if txGroup is invalid", function () { // ALGO payment missing assert.throws( () => runtime.executeTx([{ ...createNftTxGroup[1] }, { ...createNftTxGroup[2] }]), @@ -213,8 +213,8 @@ describe("Unique NFT ASA tests", function () { }); }); - describe("Transfer NFT", () => { - const createNFT = () => { + describe("Transfer NFT", function () { + const createNFT = function () { runtime.executeTx(createNftTxGroup); const assetIndex = runtime.getAssetInfoFromName("nft-asa").assetIndex; transferNftTxGroup[1].assetID = assetIndex; @@ -222,7 +222,7 @@ describe("Unique NFT ASA tests", function () { syncAccounts(); }; - it("should reject transfer if creator not opted in to NFT(ASA)", () => { + it("should reject transfer if creator not opted in to NFT(ASA)", function () { runtime.executeTx(createNftTxGroup); assert.throws( @@ -231,7 +231,7 @@ describe("Unique NFT ASA tests", function () { ); }); - it("should reject transfer if trying to transfer ASA with amount > 1", () => { + it("should reject transfer if trying to transfer ASA with amount > 1", function () { createNFT(); transferNftTxGroup[1].amount = 2; @@ -241,7 +241,7 @@ describe("Unique NFT ASA tests", function () { ); }); - it("should reject transfer if trying to transfer NFT to account other than creator", () => { + it("should reject transfer if trying to transfer NFT to account other than creator", function () { createNFT(); // trying to transfer created NFT to bob @@ -249,7 +249,7 @@ describe("Unique NFT ASA tests", function () { assert.throws(() => runtime.executeTx(transferNftTxGroup), ENCOUNTERRED_ERR_OPCODE); }); - it("should reject transfer if txGroup is invalid", () => { + it("should reject transfer if txGroup is invalid", function () { createNFT(); // transfer missing diff --git a/packages/algob/sample-project/js/test/sample-test.js b/packages/algob/sample-project/js/test/sample-test.js index 744a0cf35..fb2dd3c41 100644 --- a/packages/algob/sample-project/js/test/sample-test.js +++ b/packages/algob/sample-project/js/test/sample-test.js @@ -29,7 +29,7 @@ describe("Sample Test", function () { fundReceiver = runtime.getAccount(fundReceiver.address); } - it("Should not fail because txn fees is equal to or greater than 10000 microAlgos", () => { + it("Should not fail because txn fees is equal to or greater than 10000 microAlgos", function () { const validTxFee = 10000; assert.equal(fundReceiver.balance(), minBalance); assert.equal(master.balance(), masterBalance); @@ -50,7 +50,7 @@ describe("Sample Test", function () { assert.equal(master.balance(), masterBalance - amount - BigInt(validTxFee)); }); - it("Should fail because txn fees is less than 10000 microAlgos", () => { + it("Should fail because txn fees is less than 10000 microAlgos", function () { const invalidTxFee = 1000; const initialFundRecBalance = fundReceiver.balance(); const initialMasterBalance = master.balance(); diff --git a/packages/algob/sample-project/ts/test/sample-test.ts b/packages/algob/sample-project/ts/test/sample-test.ts index f25e6ef65..6edb9fe14 100644 --- a/packages/algob/sample-project/ts/test/sample-test.ts +++ b/packages/algob/sample-project/ts/test/sample-test.ts @@ -29,7 +29,7 @@ describe("Sample Test", function () { fundReceiver = runtime.getAccount(fundReceiver.address); } - it("Should not fail because txn fees is equal to or greater than 10000 microAlgos", () => { + it("Should not fail because txn fees is equal to or greater than 10000 microAlgos", function () { const validTxFee = 10000; assert.equal(fundReceiver.balance(), minBalance); assert.equal(master.balance(), masterBalance); @@ -50,7 +50,7 @@ describe("Sample Test", function () { assert.equal(master.balance(), masterBalance - amount - BigInt(validTxFee)); }); - it("Should fail because txn fees is less than 10000 microAlgos", () => { + it("Should fail because txn fees is less than 10000 microAlgos", function () { const invalidTxFee = 1000; const initialFundRecBalance = fundReceiver.balance(); const initialMasterBalance = master.balance(); diff --git a/packages/algob/test/builtin-tasks/clean.ts b/packages/algob/test/builtin-tasks/clean.ts index e70763edc..3bb0ecaba 100644 --- a/packages/algob/test/builtin-tasks/clean.ts +++ b/packages/algob/test/builtin-tasks/clean.ts @@ -14,7 +14,7 @@ function assertCleanBehavior(): void { }); } -describe("Clean task", () => { +describe("Clean task", function () { useFixtureProject("default-config-project"); useEnvironment(); @@ -23,7 +23,7 @@ describe("Clean task", () => { }); describe("When cache and artifact are empty dirs", function () { - beforeEach(() => { + beforeEach(function () { fs.mkdirSync("./cache"); fs.mkdirSync("./artifacts"); }); @@ -32,7 +32,7 @@ describe("Clean task", () => { }); describe("When cache and artifact dirs aren't empty", function () { - beforeEach(() => { + beforeEach(function () { fs.mkdirSync("./cache"); fs.mkdirSync("./artifacts"); fs.writeFileSync("./cache/a", ""); diff --git a/packages/algob/test/builtin-tasks/compile.ts b/packages/algob/test/builtin-tasks/compile.ts index bfa97eefa..80bb74fe2 100644 --- a/packages/algob/test/builtin-tasks/compile.ts +++ b/packages/algob/test/builtin-tasks/compile.ts @@ -55,7 +55,7 @@ class CompileOpMock extends CompileOp { } } -describe("Compile task", () => { +describe("Compile task", function () { useFixtureProjectCopy("config-project"); const fakeAlgod: Algodv2 = {} as Algodv2; // eslint-disable-line @typescript-eslint/consistent-type-assertions const op = new CompileOpMock(fakeAlgod); @@ -83,7 +83,7 @@ describe("Compile task", () => { } }); - it("on first run it should compile all .teal sources", async () => { + it("on first run it should compile all .teal sources", async function () { await op.resetAndCompile(false); assert.equal(op.timestamp, 4); @@ -103,7 +103,7 @@ describe("Compile task", () => { assert.deepEqual(op.writtenFiles, writtenFiles); }); - it("shouldn't recompile when files didn't change", async () => { + it("shouldn't recompile when files didn't change", async function () { await op.resetAndCompile(false); assert.equal(op.timestamp, 4); @@ -111,7 +111,7 @@ describe("Compile task", () => { assert.lengthOf(op.writtenFiles, 0); }); - it("should recompile only changed files", async () => { + it("should recompile only changed files", async function () { const content = "// comment"; fs.writeFileSync(path.join(ASSETS_DIR, f2), content); await op.resetAndCompile(false); @@ -121,7 +121,7 @@ describe("Compile task", () => { assert.deepEqual(op.writtenFiles, [path.join(cacheDir, f2 + ".yaml")]); }); - it("should recompile all files when --force is used", async () => { + it("should recompile all files when --force is used", async function () { await op.resetAndCompile(true); assert.equal(op.timestamp, 9); @@ -129,14 +129,14 @@ describe("Compile task", () => { assert.lengthOf(op.writtenFiles, 4); }); - it("should return TEAL code", async () => { + it("should return TEAL code", async function () { const pyOp = new PyCompileOp(); const content = fs.readFileSync(path.join(ASSETS_DIR, f4), "utf8"); const res = pyOp.compilePyTeal(f3PY) + "\n"; // eslint-disable-line @typescript-eslint/restrict-plus-operands assert.deepEqual(content.toString(), res); }); - it("should return correct ASCCache from CompileOp", async () => { + it("should return correct ASCCache from CompileOp", async function () { const result = await op.ensureCompiled(f3PY, "", true, scTmplParam); const expected = fs.readFileSync(path.join(ASSETS_DIR, "gold-asa-py-check.yaml"), "utf8"); assert.isDefined(result.scParams); @@ -144,7 +144,7 @@ describe("Compile task", () => { }); }); -describe("Support External Parameters in PyTEAL program", () => { +describe("Support External Parameters in PyTEAL program", function () { useFixtureProjectCopy("support-external-parameters"); const fakeAlgod: Algodv2 = {} as Algodv2; // eslint-disable-line @typescript-eslint/consistent-type-assertions const op = new CompileOpMock(fakeAlgod); @@ -160,7 +160,7 @@ describe("Support External Parameters in PyTEAL program", () => { ASSET_AMOUNT: 1000n, }; - it("PyTEAL code test", async () => { + it("PyTEAL code test", async function () { // On first run, should compile pyTEAL code let result = await op.ensureCompiled(stateless); statelessHash = result.srcHash; @@ -210,7 +210,7 @@ describe("Support External Parameters in PyTEAL program", () => { }); }); -describe("Support TMPL Placeholder Parameters in PyTEAL program", () => { +describe("Support TMPL Placeholder Parameters in PyTEAL program", function () { useFixtureProjectCopy("support-tmpl-parameters"); const fakeAlgod: Algodv2 = {} as Algodv2; // eslint-disable-line @typescript-eslint/consistent-type-assertions const op = new CompileOpMock(fakeAlgod); @@ -218,7 +218,7 @@ describe("Support TMPL Placeholder Parameters in PyTEAL program", () => { const stateless = "stateless.py"; const stateful = "stateful.py"; - it("Should replace TMPL_ placeholders in TEAL file", async () => { + it("Should replace TMPL_ placeholders in TEAL file", async function () { const scTmplParam = { TMPL_SENDER: "KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY", TMPL_AMOUNT: 1000n, @@ -230,7 +230,7 @@ describe("Support TMPL Placeholder Parameters in PyTEAL program", () => { assert.equal(result.tealCode, expected); }); - it("PyTEAL TMPL + External parameters test", async () => { + it("PyTEAL TMPL + External parameters test", async function () { const scTmplParam = { ARG_SENDER: "KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY", TMPL_AMOUNT: 100n, diff --git a/packages/algob/test/builtin-tasks/gen-accounts.ts b/packages/algob/test/builtin-tasks/gen-accounts.ts index 5388dfc9a..0126fef6d 100644 --- a/packages/algob/test/builtin-tasks/gen-accounts.ts +++ b/packages/algob/test/builtin-tasks/gen-accounts.ts @@ -8,10 +8,10 @@ import { ASSETS_DIR } from "../../src/internal/core/project-structure"; import { mkEnv } from "../helpers/params"; import { useFixtureProjectCopy } from "../helpers/project"; -describe("Gen-accounts task", () => { +describe("Gen-accounts task", function () { useFixtureProjectCopy("default-config-project"); - it("genAccounts should generate n accounts", () => { + it("genAccounts should generate n accounts", function () { const n = 4; const as = genAccounts(n); assert.lengthOf(as, n); @@ -22,20 +22,20 @@ describe("Gen-accounts task", () => { } }); - describe("accounts_generated.yaml flow", () => { - it("Should fail when n is negative or 0", async () => { + describe("accounts_generated.yaml flow", function () { + it("Should fail when n is negative or 0", async function () { try { await mkAccounts({ n: 0 }, mkEnv()); assert.fail("should fail when n==0"); - } catch {} // eslint-disable-line no-empty + } catch { } // eslint-disable-line no-empty try { await mkAccounts({ n: -1 }, mkEnv()); assert.fail("should fail when n==0"); - } catch {} // eslint-disable-line no-empty + } catch { } // eslint-disable-line no-empty }); - it("Should ensure test preconditions", () => { + it("Should ensure test preconditions", function () { assert.isFalse( fs.existsSync(ASSETS_DIR), "assets directory shouldn't be created when task params are invalid" @@ -45,7 +45,7 @@ describe("Gen-accounts task", () => { let accounts: Account[] = []; const filename = getFilename(); - it("should create a directory and a file", async () => { + it("should create a directory and a file", async function () { const n = 2; await mkAccounts({ n }, mkEnv()); @@ -54,7 +54,7 @@ describe("Gen-accounts task", () => { assert.lengthOf(accounts, n); }); - it("should overwrite the accounts file only with --force flag", async () => { + it("should overwrite the accounts file only with --force flag", async function () { const n = 1; await mkAccounts({ n }, mkEnv()); diff --git a/packages/algob/test/builtin-tasks/sign-lsig.ts b/packages/algob/test/builtin-tasks/sign-lsig.ts index e35b604db..5a4cc8c12 100644 --- a/packages/algob/test/builtin-tasks/sign-lsig.ts +++ b/packages/algob/test/builtin-tasks/sign-lsig.ts @@ -20,7 +20,7 @@ export const netCfg: HttpNetworkConfig = { token: "some-fake-token", }; -describe("Sign-lsig task", () => { +describe("Sign-lsig task", function () { useFixtureProject("config-project"); const outFile = "lsig_out.blsig"; diff --git a/packages/algob/test/builtin-tasks/sign-multisig.ts b/packages/algob/test/builtin-tasks/sign-multisig.ts index a7a5f9098..90cfb22c9 100644 --- a/packages/algob/test/builtin-tasks/sign-multisig.ts +++ b/packages/algob/test/builtin-tasks/sign-multisig.ts @@ -31,7 +31,7 @@ const [aliceAddr, johnAddr, bobAddr] = [ "2ILRL5YU3FZ4JDQZQVXEZUYKEWF7IEIGRRCPCMI36VKSGDMAS6FHSBXZDQ", ]; -describe("Sign-Multisig task", () => { +describe("Sign-Multisig task", function () { useFixtureProject("config-project"); const inputFile = "multisig-signed.txn"; // present in config-project/assets diff --git a/packages/algob/test/builtin-tasks/test.ts b/packages/algob/test/builtin-tasks/test.ts index d8d5e3b97..0f3caf179 100644 --- a/packages/algob/test/builtin-tasks/test.ts +++ b/packages/algob/test/builtin-tasks/test.ts @@ -12,7 +12,7 @@ describe("Test task", function () { // should be 'fixture-projects/typescript-project/tsconfig.json' const expectedTsConfigPath = path.join(process.cwd(), "tsconfig.json"); - await this.env.run(TASK_TEST).then(() => { + await this.env.run(TASK_TEST).then(function () { assert.deepEqual(process.env.TS_NODE_PROJECT, expectedTsConfigPath); }); }); diff --git a/packages/algob/test/helpers/environment.test.ts b/packages/algob/test/helpers/environment.test.ts index c68dfd9ad..043bb3bee 100644 --- a/packages/algob/test/helpers/environment.test.ts +++ b/packages/algob/test/helpers/environment.test.ts @@ -4,7 +4,7 @@ import { resetBuilderContext } from "../../src/internal/reset"; import { defaultNetCfg, useEnvironment } from "./environment"; import { useFixtureProject } from "./project"; -describe("Builder lib", () => { +describe("Builder lib", function () { useFixtureProject("config-project"); useEnvironment(); diff --git a/packages/algob/test/internal/cli/arguments-parser.ts b/packages/algob/test/internal/cli/arguments-parser.ts index 6312eca89..6ba69aa1a 100644 --- a/packages/algob/test/internal/cli/arguments-parser.ts +++ b/packages/algob/test/internal/cli/arguments-parser.ts @@ -33,13 +33,13 @@ function parseAndExpectBuilderError( ); } -describe("ArgumentsParser", () => { +describe("ArgumentsParser", function () { let argumentsParser: ArgumentsParser; let envArgs: RuntimeArgs; let taskDefinition: TaskDefinition; let overridenTaskDefinition: OverriddenTaskDefinition; - beforeEach(() => { + beforeEach(function () { argumentsParser = new ArgumentsParser(); envArgs = { network: "test", @@ -61,12 +61,12 @@ describe("ArgumentsParser", () => { .addOptionalParam("overriddenOptParam", "added opt param"); }); - it("should transform a param name into CLA", () => { + it("should transform a param name into CLA", function () { assert.equal(ArgumentsParser.paramNameToCLA("showStackTraces"), "--show-stack-traces"); assert.equal(ArgumentsParser.paramNameToCLA("version"), "--version"); }); - it("Should throw if a param name CLA isn't all lowercase", () => { + it("Should throw if a param name CLA isn't all lowercase", function () { expectBuilderError( () => ArgumentsParser.cLAToParamName("--showStackTraces"), ERRORS.ARGUMENTS.PARAM_NAME_INVALID_CASING @@ -83,18 +83,18 @@ describe("ArgumentsParser", () => { ); }); - it("should transform CLA into a param name", () => { + it("should transform CLA into a param name", function () { assert.equal(ArgumentsParser.cLAToParamName("--run"), "run"); assert.equal(ArgumentsParser.cLAToParamName("--show-stack-traces"), "showStackTraces"); }); - it("should detect param name format", () => { + it("should detect param name format", function () { assert.isTrue(argumentsParser._hasCLAParamNameFormat("--run")); assert.isFalse(argumentsParser._hasCLAParamNameFormat("run")); }); - it("should detect parameter names", () => { + it("should detect parameter names", function () { assert.isTrue( argumentsParser._isCLAParamName("--show-stack-traces", ALGOB_PARAM_DEFINITIONS) ); @@ -102,8 +102,8 @@ describe("ArgumentsParser", () => { assert.isFalse(argumentsParser._isCLAParamName("--sarasa", ALGOB_PARAM_DEFINITIONS)); }); - describe("algob arguments", () => { - it("should parse algob arguments with task", () => { + describe("algob arguments", function () { + it("should parse algob arguments with task", function () { const rawCLAs: string[] = [ "--show-stack-traces", "--network", @@ -125,7 +125,7 @@ describe("ArgumentsParser", () => { assert.equal("--task-param", unparsedCLAs[0]); }); - it("should parse algob arguments after taskname", () => { + it("should parse algob arguments after taskname", function () { const rawCLAs: string[] = [ "compile", "--task-param", @@ -147,7 +147,7 @@ describe("ArgumentsParser", () => { assert.equal("--task-param", unparsedCLAs[0]); }); - it("should fail trying to parse task arguments before taskname", () => { + it("should fail trying to parse task arguments before taskname", function () { const rawCLAs: string[] = [ "--task-param", "compile", @@ -163,7 +163,7 @@ describe("ArgumentsParser", () => { ); }); - it("should parse a algob argument", () => { + it("should parse a algob argument", function () { const rawCLAs: string[] = ["--show-stack-traces", "--network", "local", "compile"]; const runtimeArgs: TaskArguments = {}; @@ -179,7 +179,7 @@ describe("ArgumentsParser", () => { assert.equal(runtimeArgs.network, "local"); }); - it("should fail trying to parse algob with invalid argument", () => { + it("should fail trying to parse algob with invalid argument", function () { const rawCLAs: string[] = [ "--show-stack-traces", "--network", @@ -194,7 +194,7 @@ describe("ArgumentsParser", () => { ); }); - it("should fail trying to parse a repeated argument", () => { + it("should fail trying to parse a repeated argument", function () { const rawCLAs: string[] = [ "--show-stack-traces", "--network", @@ -211,7 +211,7 @@ describe("ArgumentsParser", () => { ); }); - it("should only add non-present arguments", () => { + it("should only add non-present arguments", function () { const runtimeArgs = argumentsParser._addBuilderDefaultArguments( ALGOB_PARAM_DEFINITIONS, envArgs, @@ -223,7 +223,7 @@ describe("ArgumentsParser", () => { assert.isTrue(runtimeArgs.showStackTraces); }); - it("should not change network unless specified by user", () => { + it("should not change network unless specified by user", function () { const rawCLAs: string[] = ["--show-stack-traces", "compile", "--task-param"]; const { runtimeArgs, taskName, unparsedCLAs } = argumentsParser.parseRuntimeArgs( @@ -240,8 +240,8 @@ describe("ArgumentsParser", () => { }); }); - describe("tasks arguments", () => { - it("should parse tasks arguments", () => { + describe("tasks arguments", function () { + it("should parse tasks arguments", function () { const rawCLAs: string[] = ["--param", "testing", "--bleep", "1337"]; const { paramArguments, rawPositionalArguments } = argumentsParser._parseTaskParamArguments(taskDefinition, rawCLAs); @@ -249,7 +249,7 @@ describe("ArgumentsParser", () => { assert.equal(rawPositionalArguments.length, 0); }); - it("should parse overridden tasks arguments", () => { + it("should parse overridden tasks arguments", function () { const rawCLAs: string[] = [ "--str-param", "testing", @@ -270,7 +270,7 @@ describe("ArgumentsParser", () => { assert.equal(rawPositionalArguments.length, 0); }); - it("should parse task with variadic arguments", () => { + it("should parse task with variadic arguments", function () { taskDefinition.addVariadicPositionalParam("variadic", "a variadic params", [], int); const rawPositionalArguments = ["16", "02"]; @@ -281,7 +281,7 @@ describe("ArgumentsParser", () => { assert.deepEqual(positionalArguments.variadic, [16, 2]); }); - it("should parse task with default variadic arguments", () => { + it("should parse task with default variadic arguments", function () { taskDefinition.addVariadicPositionalParam("variadic", "a variadic params", [1729], int); const rawPositionalArguments: string[] = []; @@ -294,8 +294,8 @@ describe("ArgumentsParser", () => { assert.deepEqual(positionalArguments.variadic, [1729]); }); - it("should fail when passing invalid parameter", () => { - expectBuilderError(() => { + it("should fail when passing invalid parameter", function () { + expectBuilderError(function () { argumentsParser.parseTaskArguments(taskDefinition, [ "--invalid-parameter", "not_valid", @@ -303,10 +303,10 @@ describe("ArgumentsParser", () => { }, ERRORS.ARGUMENTS.UNRECOGNIZED_PARAM_NAME); }); - it("should fail to parse task without non optional variadic arguments", () => { + it("should fail to parse task without non optional variadic arguments", function () { taskDefinition.addVariadicPositionalParam("variadic", "a variadic params"); - expectBuilderError(() => { + expectBuilderError(function () { argumentsParser.parseTaskArguments(taskDefinition, [ "--param", "testing", @@ -316,22 +316,22 @@ describe("ArgumentsParser", () => { }, ERRORS.ARGUMENTS.MISSING_POSITIONAL_ARG); }); - it("should fail to parse task without non optional argument", () => { + it("should fail to parse task without non optional argument", function () { const definition = new SimpleTaskDefinition("compile", true); definition.addParam("param", "just a param"); definition.addParam("bleep", "useless param", 1602, int, true); - expectBuilderError(() => { + expectBuilderError(function () { argumentsParser.parseTaskArguments(definition, []); }, ERRORS.ARGUMENTS.MISSING_TASK_ARGUMENT); }); - it("should fail when passing unneeded arguments", () => { - expectBuilderError(() => { + it("should fail when passing unneeded arguments", function () { + expectBuilderError(function () { argumentsParser.parseTaskArguments(taskDefinition, ["more", "arguments"]); }, ERRORS.ARGUMENTS.UNRECOGNIZED_POSITIONAL_ARG); }); - it("should parse task with positional arguments", () => { + it("should parse task with positional arguments", function () { const rawCLAs: string[] = ["--param", "testing", "--bleep", "1337", "foobar"]; taskDefinition.addPositionalParam("positional", "a posititon param"); @@ -343,7 +343,7 @@ describe("ArgumentsParser", () => { }); }); - it("Should throw the right error if the last CLA is a non-flag --param", () => { + it("Should throw the right error if the last CLA is a non-flag --param", function () { const rawCLAs: string[] = ["--b"]; taskDefinition = new SimpleTaskDefinition("t", false) diff --git a/packages/algob/test/internal/cli/project-creation.ts b/packages/algob/test/internal/cli/project-creation.ts index cf6e0e9c5..36391e915 100644 --- a/packages/algob/test/internal/cli/project-creation.ts +++ b/packages/algob/test/internal/cli/project-creation.ts @@ -6,10 +6,10 @@ import { createProject } from "../../../src/internal/cli/project-creation"; import { expectBuilderErrorAsync } from "../../helpers/errors"; import { useFixtureProject } from "../../helpers/project"; -describe("Init project", () => { +describe("Init project", function () { useFixtureProject("init-task"); - afterEach(() => { + afterEach(function () { const paths = fs.readdirSync("./"); for (const path of paths) { if (path !== "README.md") { @@ -33,37 +33,37 @@ describe("Init project", () => { assert.equal(withInfrastructure, fs.existsSync(`./${location}/infrastructure`)); } - it("should init npm project in an empty folder(javascript) with infrastructure folder", async () => { + it("should init npm project in an empty folder(javascript) with infrastructure folder", async function () { const location = "test-project"; await createProject(location, false, true, true); checkPaths(location, false, true, true); }); - it("should init npm project in an empty folder(javascript) without infrastructure folder", async () => { + it("should init npm project in an empty folder(javascript) without infrastructure folder", async function () { const location = "test-project"; await createProject(location, false, false, true); checkPaths(location, false, false, true); }); - it("should init npm project in a empty folder(typescript) with infrastructure folder", async () => { + it("should init npm project in a empty folder(typescript) with infrastructure folder", async function () { const location = "test-project"; await createProject(location, true, true, true); checkPaths(location, true, true, true); }); - it("should init npm project in a empty folder(typescript) without infrastructure folder", async () => { + it("should init npm project in a empty folder(typescript) without infrastructure folder", async function () { const location = "test-project"; await createProject(location, true, false, true); checkPaths(location, true, false, true); }); - it("should init yarn project in a empty folder(typescript) without infrastructure folder", async () => { + it("should init yarn project in a empty folder(typescript) without infrastructure folder", async function () { const location = "test-project"; await createProject(location, true, false, false); checkPaths(location, true, false, true); }); - it("should not create an npm project if folder already exist", async () => { + it("should not create an npm project if folder already exist", async function () { await createProject("location", false, false, true); await expectBuilderErrorAsync( @@ -72,13 +72,13 @@ describe("Init project", () => { ); }); - it("should init npm project in an empty folder(typescript) with `.`", async () => { + it("should init npm project in an empty folder(typescript) with `.`", async function () { const location = "."; await createProject(location, true, false, true); checkPaths(location, true, false, true); }); - it("should not init npm project if it already exists with `.`", async () => { + it("should not init npm project if it already exists with `.`", async function () { await createProject(".", false, false, true); await expectBuilderErrorAsync( diff --git a/packages/algob/test/internal/context.ts b/packages/algob/test/internal/context.ts index 4e1d98e87..752adceac 100644 --- a/packages/algob/test/internal/context.ts +++ b/packages/algob/test/internal/context.ts @@ -8,7 +8,7 @@ import { expectBuilderError } from "../helpers/errors"; import { useFixtureProject } from "../helpers/project"; describe("Builder context", function () { - describe("no context", () => { + describe("no context", function () { it("context is not defined", async function () { assert.isFalse(BuilderContext.isCreated()); }); diff --git a/packages/algob/test/internal/core/config/config-resolution.ts b/packages/algob/test/internal/core/config/config-resolution.ts index 9e68e7ddc..d76bd2298 100644 --- a/packages/algob/test/internal/core/config/config-resolution.ts +++ b/packages/algob/test/internal/core/config/config-resolution.ts @@ -11,20 +11,20 @@ import { assertAccountsEqual } from "../../../helpers/assert-methods"; import { useFixtureProject } from "../../../helpers/project"; import { account1 } from "../../../mocks/account"; -describe("Config resolution", () => { - beforeEach(() => { +describe("Config resolution", function () { + beforeEach(function () { BuilderContext.createBuilderContext(); }); - afterEach(() => { + afterEach(function () { resetBuilderContext(); }); - describe("Default config merging", () => { - describe("With default config", () => { + describe("Default config merging", function () { + describe("With default config", function () { useFixtureProject("default-config-project"); - it("should return the default config", async () => { + it("should return the default config", async function () { const config = await loadConfigAndTasks(); assert.containsAllKeys(config.networks, [ALGOB_CHAIN_NAME]); @@ -34,16 +34,16 @@ describe("Config resolution", () => { }); }); - describe("With custom config", () => { + describe("With custom config", function () { useFixtureProject("config-project"); - it("should return the config merged ", async () => { + it("should return the config merged ", async function () { const config = await loadConfigAndTasks(); assert.containsAllKeys(config.networks, ["localhost", "custom"]); }); - it("should return the config merged ", async () => { + it("should return the config merged ", async function () { const config = await loadConfigAndTasks(); assert.containsAllKeys(config.networks, ["localhost", "custom"]); const ncfg = config.networks.localhost as HttpNetworkConfig; @@ -52,22 +52,22 @@ describe("Config resolution", () => { assertAccountsEqual(config.networks.localhost.accounts, [account1]); }); - it("should keep any unknown field", async () => { + it("should keep any unknown field", async function () { const config = (await loadConfigAndTasks()) as any; assert.deepEqual(config.unknown, { asd: 123 }); }); }); }); - describe("Paths resolution", () => { + describe("Paths resolution", function () { const cfg: UserPaths = {}; - it("Should return absolute paths", () => { + it("Should return absolute paths", function () { const paths = resolveProjectPaths(__filename, cfg); const pathVals: string[] = Object.values(paths); pathVals.forEach((p) => assert.isTrue(path.isAbsolute(p))); }); - it("Should use absolute paths 'as is'", () => { + it("Should use absolute paths 'as is'", function () { const paths = resolveProjectPaths(__filename, { root: "/root", sources: "/c", @@ -83,7 +83,7 @@ describe("Config resolution", () => { assert.equal(paths.tests, "/t"); }); - it("Should resolve the root relative to the configFile", () => { + it("Should resolve the root relative to the configFile", function () { const paths = resolveProjectPaths(__filename, { root: "blah", }); @@ -91,7 +91,7 @@ describe("Config resolution", () => { assert.equal(paths.root, path.join(__dirname, "blah")); }); - it("Should resolve the rest relative to the root", () => { + it("Should resolve the rest relative to the root", function () { const paths = resolveProjectPaths(__filename, { root: "blah", sources: "c", @@ -108,7 +108,7 @@ describe("Config resolution", () => { assert.equal(paths.tests, path.join(root, "t")); }); - it("Should have the right default values", () => { + it("Should have the right default values", function () { const paths = resolveProjectPaths(__filename); assert.equal(paths.root, __dirname); assert.equal(paths.sources, path.join(__dirname, "contracts")); diff --git a/packages/algob/test/internal/core/errors.ts b/packages/algob/test/internal/core/errors.ts index 4a9bd5105..37cd13ab7 100644 --- a/packages/algob/test/internal/core/errors.ts +++ b/packages/algob/test/internal/core/errors.ts @@ -11,13 +11,13 @@ const mockErrorDescriptor: ErrorDescriptor = { description: "This is a mock error", }; -describe("BuilderError", () => { - describe("Type guard", () => { - it("Should return true for BuilderErrors", () => { +describe("BuilderError", function () { + describe("Type guard", function () { + it("Should return true for BuilderErrors", function () { assert.isTrue(BuilderError.isBuilderError(new BuilderError(mockErrorDescriptor))); }); - it("Should return false for everything else", () => { + it("Should return false for everything else", function () { assert.isFalse(BuilderError.isBuilderError(new Error())); assert.isFalse(BuilderError.isBuilderError(new BuilderPluginError("asd", "asd"))); assert.isFalse(BuilderError.isBuilderError(undefined)); @@ -28,13 +28,13 @@ describe("BuilderError", () => { }); }); - describe("Without parent error", () => { - it("should have the right error number", () => { + describe("Without parent error", function () { + it("should have the right error number", function () { const error = new BuilderError(mockErrorDescriptor); assert.equal(error.number, mockErrorDescriptor.number); }); - it("should format the error code to 4 digits", () => { + it("should format the error code to 4 digits", function () { const error = new BuilderError(mockErrorDescriptor); assert.equal(error.message.substr(0, 10), "ABLDR123: "); @@ -49,12 +49,12 @@ describe("BuilderError", () => { ); }); - it("should have the right error message", () => { + it("should have the right error message", function () { const error = new BuilderError(mockErrorDescriptor); assert.equal(error.message, `ABLDR123: ${mockErrorDescriptor.message}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions }); - it("should format the error message with the template params", () => { + it("should format the error message with the template params", function () { const error = new BuilderError( { number: 12, @@ -67,24 +67,24 @@ describe("BuilderError", () => { assert.equal(error.message, "ABLDR12: a b 123"); }); - it("shouldn't have a parent", () => { + it("shouldn't have a parent", function () { assert.isUndefined(new BuilderError(mockErrorDescriptor).parent); }); - it("Should work with instanceof", () => { + it("Should work with instanceof", function () { const error = new BuilderError(mockErrorDescriptor); assert.instanceOf(error, BuilderError); }); }); - describe("With parent error", () => { - it("should have the right parent error", () => { + describe("With parent error", function () { + it("should have the right parent error", function () { const parent = new Error(); const error = new BuilderError(mockErrorDescriptor, {}, parent); assert.equal(error.parent, parent); }); - it("should format the error message with the template params", () => { + it("should format the error message with the template params", function () { const error = new BuilderError( { number: 12, @@ -98,7 +98,7 @@ describe("BuilderError", () => { assert.equal(error.message, "ABLDR12: a b 123"); }); - it("Should work with instanceof", () => { + it("Should work with instanceof", function () { const parent = new Error(); const error = new BuilderError(mockErrorDescriptor, {}, parent); assert.instanceOf(error, BuilderError); @@ -106,19 +106,19 @@ describe("BuilderError", () => { }); }); -describe("Error ranges", () => { +describe("Error ranges", function () { function inRange(n: number, min: number, max: number): boolean { return n >= min && n <= max; } - it("Should have max > min", () => { + it("Should have max > min", function () { for (const errorGroup of unsafeObjectKeys(ERROR_RANGES)) { const range = ERROR_RANGES[errorGroup]; assert.isBelow(range.min, range.max, `Range of ${errorGroup} is invalid`); } }); - it("Shouldn't overlap ranges", () => { + it("Shouldn't overlap ranges", function () { for (const errorGroup of unsafeObjectKeys(ERROR_RANGES)) { const range = ERROR_RANGES[errorGroup]; @@ -143,8 +143,8 @@ describe("Error ranges", () => { }); }); -describe("Error descriptors", () => { - it("Should have all errors inside their ranges", () => { +describe("Error descriptors", function () { + it("Should have all errors inside their ranges", function () { for (const errorGroup of unsafeObjectKeys(ERRORS)) { const range = ERROR_RANGES[errorGroup]; @@ -165,7 +165,7 @@ describe("Error descriptors", () => { } }); - it("Shouldn't repeat error numbers", () => { + it("Shouldn't repeat error numbers", function () { for (const errorGroup of unsafeObjectKeys(ERRORS)) { for (const [name, errorDescriptor] of Object.entries( ERRORS[errorGroup] @@ -186,15 +186,15 @@ describe("Error descriptors", () => { }); }); -describe("BuilderPluginError", () => { - describe("Type guard", () => { - it("Should return true for BuilderPluginError", () => { +describe("BuilderPluginError", function () { + describe("Type guard", function () { + it("Should return true for BuilderPluginError", function () { assert.isTrue( BuilderPluginError.isBuilderPluginError(new BuilderPluginError("asd", "asd")) ); }); - it("Should return false for everything else", () => { + it("Should return false for everything else", function () { assert.isFalse(BuilderPluginError.isBuilderPluginError(new Error())); assert.isFalse( BuilderPluginError.isBuilderPluginError( @@ -209,9 +209,9 @@ describe("BuilderPluginError", () => { }); }); - describe("constructors", () => { - describe("automatic plugin name", () => { - it("Should accept a parent error", () => { + describe("constructors", function () { + describe("automatic plugin name", function () { + it("Should accept a parent error", function () { const message = "m"; const parent = new Error(); @@ -221,7 +221,7 @@ describe("BuilderPluginError", () => { assert.equal(error.parent, parent); }); - it("Should work without a parent error", () => { + it("Should work without a parent error", function () { const message = "m2"; const error = new BuilderPluginError(message); @@ -230,7 +230,7 @@ describe("BuilderPluginError", () => { assert.isUndefined(error.parent); }); - it("Should autodetect the plugin name", () => { + it("Should autodetect the plugin name", function () { const message = "m"; const parent = new Error(); @@ -240,7 +240,7 @@ describe("BuilderPluginError", () => { assert.equal(error.pluginName, "mocha"); }); - it("Should work with instanceof", () => { + it("Should work with instanceof", function () { const message = "m"; const parent = new Error(); @@ -250,8 +250,8 @@ describe("BuilderPluginError", () => { }); }); - describe("explicit plugin name", () => { - it("Should accept a parent error", () => { + describe("explicit plugin name", function () { + it("Should accept a parent error", function () { const plugin = "p"; const message = "m"; const parent = new Error(); @@ -263,7 +263,7 @@ describe("BuilderPluginError", () => { assert.equal(error.parent, parent); }); - it("Should work without a parent error", () => { + it("Should work without a parent error", function () { const plugin = "p2"; const message = "m2"; @@ -274,7 +274,7 @@ describe("BuilderPluginError", () => { assert.isUndefined(error.parent); }); - it("Should work with instanceof", () => { + it("Should work with instanceof", function () { const plugin = "p"; const message = "m"; const parent = new Error(); @@ -287,9 +287,9 @@ describe("BuilderPluginError", () => { }); }); -// describe("applyErrorMessageTemplate", () => { -// describe("Variable names", () => { -// it("Should reject invalid variable names", () => { +// describe("applyErrorMessageTemplate", function() { +// describe("Variable names", function() { +// it("Should reject invalid variable names", function() { // expectBuilderError( // () => applyErrorMessageTemplate("", { "1": 1 }), // ERRORS.INTERNAL.TEMPLATE_INVALID_VARIABLE_NAME @@ -307,8 +307,8 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("Values", () => { -// it("shouldn't contain valid variable tags", () => { +// describe("Values", function() { +// it("shouldn't contain valid variable tags", function() { // expectBuilderError( // () => applyErrorMessageTemplate("%asd%", { asd: "%as%" }), // ERRORS.INTERNAL.TEMPLATE_VALUE_CONTAINS_VARIABLE_TAG @@ -328,7 +328,7 @@ describe("BuilderPluginError", () => { // ); // }); // -// it("Shouldn't contain the %% tag", () => { +// it("Shouldn't contain the %% tag", function() { // expectBuilderError( // () => applyErrorMessageTemplate("%asd%", { asd: "%%" }), // ERRORS.INTERNAL.TEMPLATE_VALUE_CONTAINS_VARIABLE_TAG @@ -336,9 +336,9 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("Replacements", () => { -// describe("String values", () => { -// it("Should replace variable tags for the values", () => { +// describe("Replacements", function() { +// describe("String values", function() { +// it("Should replace variable tags for the values", function() { // assert.equal( // applyErrorMessageTemplate("asd %asd% 123 %asd%", { asd: "r" }), // "asd r 123 r" @@ -362,22 +362,22 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("Non-string values", () => { -// it("Should replace undefined values for undefined", () => { +// describe("Non-string values", function() { +// it("Should replace undefined values for undefined", function() { // assert.equal( // applyErrorMessageTemplate("asd %asd% 123 %asd%", { asd: undefined }), // "asd undefined 123 undefined" // ); // }); // -// it("Should replace null values for null", () => { +// it("Should replace null values for null", function() { // assert.equal( // applyErrorMessageTemplate("asd %asd% 123 %asd%", { asd: null }), // "asd null 123 null" // ); // }); // -// it("Should use their toString methods", () => { +// it("Should use their toString methods", function() { // const toR = { toString: () => "r" }; // const toB = { toString: () => "b" }; // const toEmpty = { toString: () => "" }; @@ -414,8 +414,8 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("%% sign", () => { -// it("Should be replaced with %", () => { +// describe("%% sign", function() { +// it("Should be replaced with %", function() { // assert.equal(applyErrorMessageTemplate("asd%%asd", {}), "asd%asd"); // }); // assert.equal( @@ -425,8 +425,8 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("Missing variable tag", () => { -// it("Should fail if a viable tag is missing and its value is not", () => { +// describe("Missing variable tag", function() { +// it("Should fail if a viable tag is missing and its value is not", function() { // expectBuilderError( // () => applyErrorMessageTemplate("", { asd: "123" }), // ERRORS.INTERNAL.TEMPLATE_VARIABLE_TAG_MISSING @@ -434,8 +434,8 @@ describe("BuilderPluginError", () => { // }); // }); // -// describe("Missing variable", () => { -// it("Should work, leaving the variable tag", () => { +// describe("Missing variable", function() { +// it("Should work, leaving the variable tag", function() { // assert.equal( // applyErrorMessageTemplate("%asd% %fgh%", { asd: "123" }), // "123 %fgh%" diff --git a/packages/algob/test/internal/core/params/argument-types.ts b/packages/algob/test/internal/core/params/argument-types.ts index 147c760a1..13f754cba 100644 --- a/packages/algob/test/internal/core/params/argument-types.ts +++ b/packages/algob/test/internal/core/params/argument-types.ts @@ -8,8 +8,8 @@ import * as path from "path"; import * as types from "../../../../src/internal/core/params/argument-types"; import { expectBuilderError } from "../../../helpers/errors"; -describe("argumentTypes", () => { - it("should set the right name to all the argument types", () => { +describe("argumentTypes", function () { + it("should set the right name to all the argument types", function () { for (const typeName of Object.keys(types)) { const argumentTypesMap: { [name: string]: types.ArgumentType; @@ -18,8 +18,8 @@ describe("argumentTypes", () => { } }); - describe("string type", () => { - it("should work with valid values", () => { + describe("string type", function () { + it("should work with valid values", function () { assert.equal(types.string.parse("arg", "asd"), "asd"); assert.equal(types.string.parse("arg", "asd1"), "asd1"); assert.equal(types.string.parse("arg", "asd 123"), "asd 123"); @@ -28,13 +28,13 @@ describe("argumentTypes", () => { }); }); - describe("boolean type", () => { - it("should work with valid values", () => { + describe("boolean type", function () { + it("should work with valid values", function () { assert.equal(types.boolean.parse("arg", "true"), true); assert.equal(types.boolean.parse("arg", "false"), false); }); - it("should throw the right error on invalid values", () => { + it("should throw the right error on invalid values", function () { expectBuilderError( () => types.boolean.parse("arg", "asd1"), ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE @@ -62,15 +62,15 @@ describe("argumentTypes", () => { }); }); - describe("int type", () => { - it("should work with decimal values", () => { + describe("int type", function () { + it("should work with decimal values", function () { assert.equal(types.int.parse("arg", "0"), 0); assert.equal(types.int.parse("arg", "1"), 1); assert.equal(types.int.parse("arg", "1123"), 1123); assert.equal(types.int.parse("arg", "05678"), 5678); }); - it("should work with hex values", () => { + it("should work with hex values", function () { assert.equal(types.int.parse("arg", "0x0"), 0); assert.equal(types.int.parse("arg", "0x1"), 1); assert.equal(types.int.parse("arg", "0xA"), 0xa); @@ -78,7 +78,7 @@ describe("argumentTypes", () => { assert.equal(types.int.parse("arg", "0x0a"), 0x0a); }); - it("should work with decimal scientific notation", () => { + it("should work with decimal scientific notation", function () { assert.equal(types.int.parse("arg", "1e0"), 1); assert.equal(types.int.parse("arg", "1e123"), 1e123); assert.equal(types.int.parse("arg", "12e0"), 12); @@ -86,7 +86,7 @@ describe("argumentTypes", () => { assert.equal(types.int.parse("arg", "0e12"), 0); }); - it("should fail with incorrect values", () => { + it("should fail with incorrect values", function () { expectBuilderError( () => types.int.parse("arg", ""), ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE @@ -126,22 +126,22 @@ describe("argumentTypes", () => { }); }); - describe("float type", () => { - it("should work with integer decimal values", () => { + describe("float type", function () { + it("should work with integer decimal values", function () { assert.equal(types.float.parse("arg", "0"), 0); assert.equal(types.float.parse("arg", "1"), 1); assert.equal(types.float.parse("arg", "1123"), 1123); assert.equal(types.float.parse("arg", "05678"), 5678); }); - it("should work with non-integer decimal values", () => { + it("should work with non-integer decimal values", function () { assert.equal(types.float.parse("arg", "0.1"), 0.1); assert.equal(types.float.parse("arg", "123.123"), 123.123); assert.equal(types.float.parse("arg", ".123"), 0.123); assert.equal(types.float.parse("arg", "0."), 0); }); - it("should work with integer hex values", () => { + it("should work with integer hex values", function () { assert.equal(types.float.parse("arg", "0x0"), 0); assert.equal(types.float.parse("arg", "0x1"), 1); assert.equal(types.float.parse("arg", "0xA"), 0xa); @@ -149,7 +149,7 @@ describe("argumentTypes", () => { assert.equal(types.float.parse("arg", "0x0a"), 0x0a); }); - it("should work with decimal scientific notation", () => { + it("should work with decimal scientific notation", function () { assert.equal(types.float.parse("arg", "1e0"), 1); assert.equal(types.float.parse("arg", "1e123"), 1e123); assert.equal(types.float.parse("arg", "12e0"), 12); @@ -160,7 +160,7 @@ describe("argumentTypes", () => { assert.equal(types.float.parse("arg", "1.0123e123"), 1.0123e123); }); - it("should fail with incorrect values", () => { + it("should fail with incorrect values", function () { expectBuilderError( () => types.float.parse("arg", ""), ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE @@ -208,25 +208,25 @@ describe("argumentTypes", () => { }); }); - describe("Input file type", () => { - it("Should return the file path if the file exists and is readable", () => { + describe("Input file type", function () { + it("Should return the file path if the file exists and is readable", function () { const output = types.inputFile.parse("A file", __filename); assert.equal(output, __filename); }); - it("Should work with a relative path", () => { + it("Should work with a relative path", function () { const relative = path.relative(process.cwd(), __filename); const output = types.inputFile.parse("A file", relative); assert.equal(output, relative); }); - it("Should work with an absolute path", async () => { + it("Should work with an absolute path", async function () { const absolute = await fsExtra.realpath(__filename); const output = types.inputFile.parse("A file", absolute); assert.equal(output, absolute); }); - it("Should throw if the file doesnt exist", () => { + it("Should throw if the file doesnt exist", function () { expectBuilderError( () => types.inputFile.parse("A file", "NON_EXISTENT_FILE"), ERRORS.ARGUMENTS.INVALID_INPUT_FILE @@ -265,7 +265,7 @@ describe("argumentTypes", () => { fsExtra.unlinkSync("A"); }); - it("Should throw if a directory is given", () => { + it("Should throw if a directory is given", function () { expectBuilderError( () => types.inputFile.parse("A file", __dirname), ERRORS.ARGUMENTS.INVALID_INPUT_FILE @@ -273,8 +273,8 @@ describe("argumentTypes", () => { }); }); - describe("JSON type", () => { - it("Should fail if the argument isn't JSON", () => { + describe("JSON type", function () { + it("Should fail if the argument isn't JSON", function () { expectBuilderError( () => types.json.parse("j", "a"), ERRORS.ARGUMENTS.INVALID_JSON_ARGUMENT @@ -291,23 +291,23 @@ describe("argumentTypes", () => { ); }); - it("Should parse an object successfully", () => { + it("Should parse an object successfully", function () { assert.deepEqual(types.json.parse("j", '{"a":1}'), { a: 1 }); }); - it("Should parse a number", () => { + it("Should parse a number", function () { assert.deepEqual(types.json.parse("j", "123"), 123); }); - it("Should parse a list", () => { + it("Should parse a list", function () { assert.deepEqual(types.json.parse("j", "[1,2]"), [1, 2]); }); - it("Should parse a string", () => { + it("Should parse a string", function () { assert.deepEqual(types.json.parse("j", '"a"'), "a"); }); - it("Should accept anything except undefined as valid", () => { + it("Should accept anything except undefined as valid", function () { const validate = types.json.validate; if (validate === undefined) { assert.fail("types.json.validate must exist"); diff --git a/packages/algob/test/internal/core/params/env-variables.ts b/packages/algob/test/internal/core/params/env-variables.ts index c53588536..f50d25d21 100644 --- a/packages/algob/test/internal/core/params/env-variables.ts +++ b/packages/algob/test/internal/core/params/env-variables.ts @@ -11,8 +11,8 @@ import { expectBuilderError } from "../../../helpers/errors"; // This is testing an internal function, which may seem weird, but its behaviour // is 100% user facing. -describe("paramNameToEnvVariable", () => { - it("should convert camelCase to UPPER_CASE and prepend BUILDER_", () => { +describe("paramNameToEnvVariable", function () { + it("should convert camelCase to UPPER_CASE and prepend BUILDER_", function () { assert.equal(paramNameToEnvVariable("a"), "BUILDER_A"); assert.equal(paramNameToEnvVariable("B"), "BUILDER_B"); assert.equal(paramNameToEnvVariable("AC"), "BUILDER_A_C"); @@ -22,8 +22,8 @@ describe("paramNameToEnvVariable", () => { }); }); -describe("Env vars arguments parsing", () => { - it("Should use the default values if arguments are not defined", () => { +describe("Env vars arguments parsing", function () { + it("Should use the default values if arguments are not defined", function () { const args = getEnvRuntimeArgs(ALGOB_PARAM_DEFINITIONS, { IRRELEVANT_ENV_VAR: "123", }); @@ -33,7 +33,7 @@ describe("Env vars arguments parsing", () => { assert.equal(args.version, ALGOB_PARAM_DEFINITIONS.version.defaultValue); }); - it("Should accept values", () => { + it("Should accept values", function () { const args = getEnvRuntimeArgs(ALGOB_PARAM_DEFINITIONS, { IRRELEVANT_ENV_VAR: "123", BUILDER_NETWORK: "asd", @@ -50,7 +50,7 @@ describe("Env vars arguments parsing", () => { assert.equal(args.help, true); }); - it("should throw if an invalid value is passed", () => { + it("should throw if an invalid value is passed", function () { expectBuilderError( () => getEnvRuntimeArgs(ALGOB_PARAM_DEFINITIONS, { @@ -61,8 +61,8 @@ describe("Env vars arguments parsing", () => { }); }); -describe("getEnvVariablesMap", () => { - it("Should return the right map", () => { +describe("getEnvVariablesMap", function () { + it("Should return the right map", function () { assert.deepEqual( getEnvVariablesMap({ network: "asd", diff --git a/packages/algob/test/internal/core/project-structure.ts b/packages/algob/test/internal/core/project-structure.ts index ae13624fb..50ef37dda 100644 --- a/packages/algob/test/internal/core/project-structure.ts +++ b/packages/algob/test/internal/core/project-structure.ts @@ -9,36 +9,36 @@ import { } from "../../../src/internal/core/project-structure"; import { useFixtureProject } from "../../helpers/project"; -describe("project structure", () => { - describe("isCwdInsideProject", () => { - it("should return false if cwd is not inside a project", () => { +describe("project structure", function () { + describe("isCwdInsideProject", function () { + it("should return false if cwd is not inside a project", function () { assert.isFalse(isCwdInsideProject()); }); - describe("Inside a project", () => { + describe("Inside a project", function () { useFixtureProject("default-config-project"); - it("should return true if cwd is the project's", () => { + it("should return true if cwd is the project's", function () { assert.isTrue(isCwdInsideProject()); }); - it("should return true if cwd is deeper inside the project", () => { + it("should return true if cwd is deeper inside the project", function () { process.chdir("contracts"); assert.isTrue(isCwdInsideProject()); }); }); }); - describe("getUserConfigPath", () => { - it("should be undefined if not inside a project", () => { + describe("getUserConfigPath", function () { + it("should be undefined if not inside a project", function () { assert.isUndefined(getUserConfigPath()); }); - describe("Inside a project", () => { + describe("Inside a project", function () { useFixtureProject("default-config-project"); let configPath: string; - before("get root path", async () => { + before("get root path", async function () { // TODO: This is no longer needed once PR #71 gets merged const pathToFixtureRoot = await fsExtra.realpath( path.join(__dirname, "..", "..", "fixture-projects", "default-config-project") @@ -47,11 +47,11 @@ describe("project structure", () => { configPath = await fsExtra.realpath(path.join(pathToFixtureRoot, JS_CONFIG_FILENAME)); }); - it("should work from the project root", () => { + it("should work from the project root", function () { assert.equal(getUserConfigPath(), configPath); }); - it("should work from deeper inside the project", () => { + it("should work from deeper inside the project", function () { process.chdir("contracts"); assert.equal(getUserConfigPath(), configPath); }); diff --git a/packages/algob/test/internal/core/runtime-environment.ts b/packages/algob/test/internal/core/runtime-environment.ts index 319ea59fe..a35ca449a 100644 --- a/packages/algob/test/internal/core/runtime-environment.ts +++ b/packages/algob/test/internal/core/runtime-environment.ts @@ -18,7 +18,7 @@ import { import { expectBuilderError, expectBuilderErrorAsync } from "../../helpers/errors"; import { useFixtureProject } from "../../helpers/project"; -describe("Environment", () => { +describe("Environment", function () { const config: ResolvedConfig = { networks: { localNet: { @@ -48,7 +48,7 @@ describe("Environment", () => { let env: RuntimeEnv; let dsl: TasksDSL; - beforeEach(() => { + beforeEach(function () { const ctx = BuilderContext.createBuilderContext(); dsl = ctx.tasksDSL; dsl.task("example", async (_ret) => { @@ -95,20 +95,20 @@ describe("Environment", () => { afterEach(() => resetBuilderContext()); - describe("Environment", () => { - it("should create an environment", () => { + describe("Environment", function () { + it("should create an environment", function () { assert.deepEqual(env.config, config); assert.isDefined(env.tasks); assert.isDefined(env.network); }); - it("should run a task correctly", async () => { + it("should run a task correctly", async function () { const ret = await env.run("example"); assert.equal(ret, 27); }); - describe("run task arguments validation", () => { - it("should throw on missing required argument", async () => { + describe("run task arguments validation", function () { + it("should throw on missing required argument", async function () { const taskName = "complexExampleTask"; const requiredParamName = "positionalRequiredStringParam"; const task = env.tasks[taskName]; @@ -124,12 +124,12 @@ describe("Environment", () => { assert.isDefined(taskResult); // same task throws with required param missing - await expectBuilderErrorAsync(async () => { + await expectBuilderErrorAsync(async function () { await env.run("complexExampleTask", {}); }, ERRORS.ARGUMENTS.MISSING_TASK_ARGUMENT); }); - it("should use default value on missing optional argument with default param", async () => { + it("should use default value on missing optional argument with default param", async function () { const taskName = "complexExampleTask"; const optParamName = "posOptJsonParamWithDefault"; const task = env.tasks[taskName]; @@ -178,7 +178,7 @@ describe("Environment", () => { ); }); - it("should validate argument type matches the param type", async () => { + it("should validate argument type matches the param type", async function () { const taskName = "taskWithMultipleTypesParams"; const typesValidationTestCases = { @@ -215,7 +215,7 @@ describe("Environment", () => { taskNameToRun: string, taskArguments: any ): Promise => { - await expectBuilderErrorAsync(async () => { + await expectBuilderErrorAsync(async function () { await env.run(taskNameToRun, taskArguments); console.error( `should have thrown task run: '${taskNameToRun}' with arguments: `, @@ -238,20 +238,20 @@ describe("Environment", () => { }); }); - it("should fail trying to run a non existent task", () => { + it("should fail trying to run a non existent task", function () { env.run("invalid").catch((err) => { assert.equal(err.number, ERRORS.ARGUMENTS.UNRECOGNIZED_TASK.number); }); }); - it("should clean global state after task execution", async () => { + it("should clean global state after task execution", async function () { assert.equal(await env.run("example"), 27); const globalAsAny = global as any; assert.isUndefined(globalAsAny.runSuper); assert.isUndefined(globalAsAny.env); }); - it("should run overridden task correctly", async () => { + it("should run overridden task correctly", async function () { dsl.task("example", "description", async (_ret) => { return 28; }); @@ -260,7 +260,7 @@ describe("Environment", () => { assert.equal(await localEnv.run("example"), 28); }); - it("Should preserve the injected env after running a sub-task", async () => { + it("Should preserve the injected env after running a sub-task", async function () { dsl.task( "with-subtask", "description", @@ -282,14 +282,14 @@ describe("Environment", () => { await env.run("with-subtask"); }); - it("Should define the network field correctly", () => { + it("Should define the network field correctly", function () { assert.isDefined(env.network); assert.equal(env.network.name, "localNet"); assert.equal(env.network.config, config.networks.localNet); }); - it("Should throw if the chosen network doesn't exist", () => { - expectBuilderError(() => { + it("Should throw if the chosen network doesn't exist", function () { + expectBuilderError(function () { const ctx = BuilderContext.getBuilderContext(); env = new Environment( config, @@ -302,10 +302,10 @@ describe("Environment", () => { }); }); - describe("Plugin system", () => { + describe("Plugin system", function () { useFixtureProject("plugin-project"); - it("environment should contain plugin extensions", async () => { + it("environment should contain plugin extensions", async function () { require(path.join(process.cwd(), "plugins", "example")); const ctx = BuilderContext.getBuilderContext(); env = new Environment(config, args, tasks, ctx.extendersManager.getExtenders(), true); diff --git a/packages/algob/test/internal/core/tasks/dsl.ts b/packages/algob/test/internal/core/tasks/dsl.ts index 7f9cea77c..35daa653c 100644 --- a/packages/algob/test/internal/core/tasks/dsl.ts +++ b/packages/algob/test/internal/core/tasks/dsl.ts @@ -4,14 +4,14 @@ import { assert } from "chai"; import { TasksDSL } from "../../../../src/internal/core/tasks/dsl"; import { expectBuilderErrorAsync } from "../../../helpers/errors"; -describe("TasksDSL", () => { +describe("TasksDSL", function () { let dsl: TasksDSL; - beforeEach(() => { + beforeEach(function () { dsl = new TasksDSL(); }); const action = Promise.resolve; // empty promise - it("should add a task", () => { + it("should add a task", function () { const taskName = "compile"; const description = "compiler task description"; @@ -23,18 +23,18 @@ describe("TasksDSL", () => { assert.isFalse(task.isInternal); }); - it("should add an internal task", () => { + it("should add an internal task", function () { const task = dsl.internalTask("compile", "compiler task description", action); assert.isTrue(task.isInternal); }); - it("should add a task without description", () => { + it("should add a task without description", function () { const task = dsl.task("compile", action); assert.isUndefined(task.description); assert.equal(task.action, action); }); - it("should add a task with default action", async () => { + it("should add a task with default action", async function () { const task = dsl.task("compile", "a description"); assert.isDefined(task.description); assert.isDefined(task.action); @@ -48,7 +48,7 @@ describe("TasksDSL", () => { ); }); - it("should override task", () => { + it("should override task", function () { const builtin = dsl.task("compile", "built-in", action); let tasks = dsl.getTaskDefinitions(); assert.equal(tasks.compile, builtin); @@ -58,7 +58,7 @@ describe("TasksDSL", () => { assert.equal(tasks.compile, custom); }); - it("should return added tasks", () => { + it("should return added tasks", function () { const task = dsl.task("compile", "built-in"); const tasks = dsl.getTaskDefinitions(); assert.deepEqual(tasks, { compile: task }); diff --git a/packages/algob/test/internal/core/tasks/task-definitions.ts b/packages/algob/test/internal/core/tasks/task-definitions.ts index 9019348b9..7a092180c 100644 --- a/packages/algob/test/internal/core/tasks/task-definitions.ts +++ b/packages/algob/test/internal/core/tasks/task-definitions.ts @@ -40,32 +40,32 @@ function assertParamDefinition( const runSuperNop: any = () => Promise.resolve(); runSuperNop.isDefined = false; -describe("SimpleTaskDefinition", () => { - describe("construction", () => { +describe("SimpleTaskDefinition", function () { + describe("construction", function () { let taskDefinition: SimpleTaskDefinition; - before("init taskDefinition", () => { + before("init taskDefinition", function () { taskDefinition = new SimpleTaskDefinition("name", true); }); - it("gets the right name", () => { + it("gets the right name", function () { assert.equal(taskDefinition.name, "name"); }); - it("gets the right isInternal flag", () => { + it("gets the right isInternal flag", function () { assert.isTrue(taskDefinition.isInternal); }); - it("starts without any param defined", () => { + it("starts without any param defined", function () { assert.deepEqual(taskDefinition.paramDefinitions, {}); assert.isEmpty(taskDefinition.positionalParamDefinitions); }); - it("starts without any description", () => { + it("starts without any description", function () { assert.isUndefined(taskDefinition.description); }); - it("starts with an action that throws", async () => { + it("starts with an action that throws", async function () { await expectBuilderErrorAsync( async () => await taskDefinition.action({}, {} as any, runSuperNop), ERRORS.TASK_DEFINITIONS.ACTION_NOT_SET @@ -73,8 +73,8 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("setDescription", () => { - it("Should change the description", () => { + describe("setDescription", function () { + it("Should change the description", function () { const taskDefinition = new SimpleTaskDefinition("name"); assert.isUndefined(taskDefinition.description); @@ -86,8 +86,8 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("setAction", () => { - it("Should change the action", async () => { + describe("setAction", function () { + it("Should change the action", async function () { const taskDefinition = new SimpleTaskDefinition("name"); taskDefinition.setAction(async () => 1); @@ -101,62 +101,62 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("param definition rules", () => { + describe("param definition rules", function () { let taskDefinition: SimpleTaskDefinition; - beforeEach("init taskDefinition", () => { + beforeEach("init taskDefinition", function () { taskDefinition = new SimpleTaskDefinition("name", true); }); - describe("param name repetitions", () => { - beforeEach("set param with name 'name'", () => { + describe("param name repetitions", function () { + beforeEach("set param with name 'name'", function () { taskDefinition.addParam("name", "a description", "asd"); }); - it("should throw if addParam repeats a param name", () => { + it("should throw if addParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addParam("name", "another desc") ); }); - it("should throw if addOptionalParam repeats a param name", () => { + it("should throw if addOptionalParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addOptionalParam("name", "another desc") ); }); - it("should throw if addFlag repeats a param name", () => { + it("should throw if addFlag repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addFlag("name", "another desc") ); }); - it("should throw if addPositionalParam repeats a param name", () => { + it("should throw if addPositionalParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addPositionalParam("name", "another desc") ); }); - it("should throw if addOptionalPositionalParam repeats a param name", () => { + it("should throw if addOptionalPositionalParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addOptionalPositionalParam("name", "another desc") ); }); - it("should throw if addVariadicPositionalParam repeats a param name", () => { + it("should throw if addVariadicPositionalParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addVariadicPositionalParam("name", "another desc") ); }); - it("should throw if addOptionalVariadicPositionalParam repeats a param name", () => { + it("should throw if addOptionalVariadicPositionalParam repeats a param name", function () { expectThrowParamAlreadyDefinedError(() => taskDefinition.addOptionalVariadicPositionalParam("name", "another desc") ); }); }); - describe("param name clashes with Builder's ones", () => { + describe("param name clashes with Builder's ones", function () { function testClashWith(name: string): void { expectBuilderError( () => taskDefinition.addParam(name), @@ -188,7 +188,7 @@ describe("SimpleTaskDefinition", () => { ); } - it("Should throw if a param clashes", () => { + it("Should throw if a param clashes", function () { // This is constructed to force a type error here if a Builder arg is // added and not tested. const algobArgs: RuntimeArgs = { @@ -203,57 +203,57 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("positional param rules", () => { - describe("no mandatory positional param after an optional one", () => { - beforeEach("add optional positional", () => { + describe("positional param rules", function () { + describe("no mandatory positional param after an optional one", function () { + beforeEach("add optional positional", function () { taskDefinition.addOptionalPositionalParam("asd"); }); - it("throws when trying to add a new positional param", () => { + it("throws when trying to add a new positional param", function () { expectBuilderError( () => taskDefinition.addPositionalParam("asd2"), ERRORS.TASK_DEFINITIONS.MANDATORY_PARAM_AFTER_OPTIONAL ); }); - it("throws when trying to add a new variadic positional param", () => { + it("throws when trying to add a new variadic positional param", function () { expectBuilderError( () => taskDefinition.addVariadicPositionalParam("asd2"), ERRORS.TASK_DEFINITIONS.MANDATORY_PARAM_AFTER_OPTIONAL ); }); - describe("should still accept non-positional ones", () => { - it("should accept a common param", () => { + describe("should still accept non-positional ones", function () { + it("should accept a common param", function () { taskDefinition.addParam("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); - it("should accept an optional param", () => { + it("should accept an optional param", function () { taskDefinition.addOptionalParam("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); - it("should accept a flag", () => { + it("should accept a flag", function () { taskDefinition.addFlag("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); }); }); - describe("accepts multiple optional params", () => { - beforeEach("add optional positional", () => { + describe("accepts multiple optional params", function () { + beforeEach("add optional positional", function () { taskDefinition.addOptionalPositionalParam("asd"); }); - it("should accept an optional positional param", () => { + it("should accept an optional positional param", function () { taskDefinition.addOptionalPositionalParam("asd2"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.name, "asd2"); assert.isTrue(last.isOptional); }); - it("should accept an optional variadic positional param", () => { + it("should accept an optional variadic positional param", function () { taskDefinition.addOptionalVariadicPositionalParam("asd2"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.name, "asd2"); @@ -262,33 +262,33 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("no positional params after a variadic positional param", () => { - beforeEach("add variadic param", () => { + describe("no positional params after a variadic positional param", function () { + beforeEach("add variadic param", function () { taskDefinition.addVariadicPositionalParam("asd"); }); - it("should throw on adding a positional param", () => { + it("should throw on adding a positional param", function () { expectBuilderError( () => taskDefinition.addPositionalParam("p"), ERRORS.TASK_DEFINITIONS.PARAM_AFTER_VARIADIC ); }); - it("should throw on adding an optional positional param", () => { + it("should throw on adding an optional positional param", function () { expectBuilderError( () => taskDefinition.addOptionalPositionalParam("p"), ERRORS.TASK_DEFINITIONS.PARAM_AFTER_VARIADIC ); }); - it("should throw on adding another variadic param", () => { + it("should throw on adding another variadic param", function () { expectBuilderError( () => taskDefinition.addVariadicPositionalParam("p"), ERRORS.TASK_DEFINITIONS.PARAM_AFTER_VARIADIC ); }); - it("should throw on adding an optional variadic param", () => { + it("should throw on adding an optional variadic param", function () { expectBuilderError( () => taskDefinition.addOptionalVariadicPositionalParam("p"), ERRORS.TASK_DEFINITIONS.PARAM_AFTER_VARIADIC @@ -296,18 +296,18 @@ describe("SimpleTaskDefinition", () => { }); // eslint-disable-next-line sonarjs/no-identical-functions - describe("should still accept non-positional ones", () => { - it("should accept a common param", () => { + describe("should still accept non-positional ones", function () { + it("should accept a common param", function () { taskDefinition.addParam("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); - it("should accept an optional param", () => { + it("should accept an optional param", function () { taskDefinition.addOptionalParam("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); - it("should accept a flag", () => { + it("should accept a flag", function () { taskDefinition.addFlag("p"); assert.notEqual(taskDefinition.paramDefinitions.p, undefined); }); @@ -316,14 +316,14 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("Setting params", () => { + describe("Setting params", function () { let taskDefinition: SimpleTaskDefinition; - beforeEach("init taskDefinition", () => { + beforeEach("init taskDefinition", function () { taskDefinition = new SimpleTaskDefinition("name", true); }); - describe("addParam", () => { + describe("addParam", function () { it("Should fail if the param name isn't camelCase", function () { expectBuilderError( () => taskDefinition.addParam("A"), @@ -366,7 +366,7 @@ describe("SimpleTaskDefinition", () => { ); }); - it("should add the param correctly", () => { + it("should add the param correctly", function () { taskDefinition.addParam("p", "desc", 123, types.int, true); assertParamDefinition(taskDefinition.paramDefinitions.p, { name: "p", @@ -379,7 +379,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should set isOptional if a default value is provided", () => { + it("should set isOptional if a default value is provided", function () { taskDefinition.addParam("p", "desc", 123, types.int); assertParamDefinition(taskDefinition.paramDefinitions.p, { defaultValue: 123, @@ -387,7 +387,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should accept an optional parm with undefined as default vlaue", () => { + it("should accept an optional parm with undefined as default vlaue", function () { taskDefinition.addParam("p", "desc", undefined, types.int, true); assertParamDefinition(taskDefinition.paramDefinitions.p, { defaultValue: undefined, @@ -395,19 +395,19 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addParam("p"); assert.equal(taskDefinition.paramDefinitions.p.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE ); }); - it("should throw if a default value is set to a mandatory param", () => { + it("should throw if a default value is set to a mandatory param", function () { expectBuilderError( () => taskDefinition.addParam("p", "desc", 123, types.int, false), ERRORS.TASK_DEFINITIONS.DEFAULT_IN_MANDATORY_PARAM @@ -415,8 +415,8 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addOptionalParam", () => { - it("should set the param correctly", () => { + describe("addOptionalParam", function () { + it("should set the param correctly", function () { taskDefinition.addOptionalParam("p", "desc", 123, types.int); assertParamDefinition(taskDefinition.paramDefinitions.p, { name: "p", @@ -429,7 +429,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should work with undefined as default value", () => { + it("should work with undefined as default value", function () { taskDefinition.addOptionalParam("p", "desc", undefined); assertParamDefinition(taskDefinition.paramDefinitions.p, { defaultValue: undefined, @@ -437,12 +437,12 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addOptionalParam("p"); assert.equal(taskDefinition.paramDefinitions.p.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addOptionalParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE @@ -450,8 +450,8 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addFlag", () => { - it("should set an optional boolean param", () => { + describe("addFlag", function () { + it("should set an optional boolean param", function () { taskDefinition.addFlag("f", "d"); assertParamDefinition(taskDefinition.paramDefinitions.f, { @@ -466,13 +466,13 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addPositionalParam", () => { - it("shouldn't add the param definition to paramDefinitions", () => { + describe("addPositionalParam", function () { + it("shouldn't add the param definition to paramDefinitions", function () { taskDefinition.addPositionalParam("p", "desc"); assert.isUndefined(taskDefinition.paramDefinitions.p); }); - it("should add the param definition to positionalParamDefinitions", () => { + it("should add the param definition to positionalParamDefinitions", function () { taskDefinition.addPositionalParam("p", "desc", 123, types.int, true); assertParamDefinition(getLastPositionalParam(taskDefinition), { name: "p", @@ -485,7 +485,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should work with undefined as default value", () => { + it("should work with undefined as default value", function () { taskDefinition.addPositionalParam("p", "desc", undefined, types.int, true); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -494,27 +494,27 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addPositionalParam("p", "desc"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addPositionalParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE ); }); - it("should throw if a default value is set to a mandatory param", () => { + it("should throw if a default value is set to a mandatory param", function () { expectBuilderError( () => taskDefinition.addPositionalParam("p", "desc", 123, types.int, false), ERRORS.TASK_DEFINITIONS.DEFAULT_IN_MANDATORY_PARAM ); }); - it("should set isOptional if default value is provided", () => { + it("should set isOptional if default value is provided", function () { taskDefinition.addPositionalParam("p", "desc", "A"); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -524,13 +524,13 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addOptionalPositionalParam", () => { - it("shouldn't add the param definition to paramDefinitions", () => { + describe("addOptionalPositionalParam", function () { + it("shouldn't add the param definition to paramDefinitions", function () { taskDefinition.addOptionalPositionalParam("p", "desc"); assert.isUndefined(taskDefinition.paramDefinitions.p); }); - it("should add the param definition to positionalParamDefinitions", () => { + it("should add the param definition to positionalParamDefinitions", function () { taskDefinition.addOptionalPositionalParam("p", "desc", 123, types.int); assertParamDefinition(getLastPositionalParam(taskDefinition), { name: "p", @@ -543,7 +543,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should work with undefined as default value", () => { + it("should work with undefined as default value", function () { taskDefinition.addOptionalPositionalParam("p", "desc", undefined, types.int); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -552,13 +552,13 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addOptionalPositionalParam("p", "desc"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addOptionalPositionalParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE @@ -566,13 +566,13 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addVariadicPositionalParam", () => { - it("shouldn't add the param definition to paramDefinitions", () => { + describe("addVariadicPositionalParam", function () { + it("shouldn't add the param definition to paramDefinitions", function () { taskDefinition.addVariadicPositionalParam("p", "desc"); assert.isUndefined(taskDefinition.paramDefinitions.p); }); - it("should add the param definition to positionalParamDefinitions", () => { + it("should add the param definition to positionalParamDefinitions", function () { taskDefinition.addVariadicPositionalParam("p", "desc", [123], types.int, true); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -586,7 +586,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should convert the default value into an array if necessary", () => { + it("should convert the default value into an array if necessary", function () { taskDefinition.addVariadicPositionalParam("p", "desc", 123, types.int, true); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -595,7 +595,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should work with undefined as default value", () => { + it("should work with undefined as default value", function () { taskDefinition.addVariadicPositionalParam("p", "desc", undefined, types.int, true); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -605,13 +605,13 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addVariadicPositionalParam("p", "desc"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addVariadicPositionalParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE @@ -623,7 +623,7 @@ describe("SimpleTaskDefinition", () => { ); }); - it("should throw if a default value is set to a mandatory param", () => { + it("should throw if a default value is set to a mandatory param", function () { expectBuilderError( () => taskDefinition.addVariadicPositionalParam("p", "desc", 123, types.int, false), ERRORS.TASK_DEFINITIONS.DEFAULT_IN_MANDATORY_PARAM @@ -635,7 +635,7 @@ describe("SimpleTaskDefinition", () => { ); }); - it("should set isOptional if default value is provided", () => { + it("should set isOptional if default value is provided", function () { taskDefinition.addVariadicPositionalParam("p", "desc", "A"); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -646,13 +646,13 @@ describe("SimpleTaskDefinition", () => { }); }); - describe("addOptionalVariadicPositionalParam", () => { - it("shouldn't add the param definition to paramDefinitions", () => { + describe("addOptionalVariadicPositionalParam", function () { + it("shouldn't add the param definition to paramDefinitions", function () { taskDefinition.addOptionalVariadicPositionalParam("p", "desc"); assert.isUndefined(taskDefinition.paramDefinitions.p); }); - it("should add the param definition to positionalParamDefinitions", () => { + it("should add the param definition to positionalParamDefinitions", function () { taskDefinition.addOptionalVariadicPositionalParam("p", "desc", [123], types.int); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -666,7 +666,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should convert the default value into an array if necessary", () => { + it("should convert the default value into an array if necessary", function () { taskDefinition.addOptionalVariadicPositionalParam("p", "desc", 123, types.int); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -675,7 +675,7 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should work with undefined as default value", () => { + it("should work with undefined as default value", function () { taskDefinition.addOptionalVariadicPositionalParam("p", "desc", undefined, types.int); assertParamDefinition(getLastPositionalParam(taskDefinition), { @@ -685,13 +685,13 @@ describe("SimpleTaskDefinition", () => { }); }); - it("should use types.string as if non type is given", () => { + it("should use types.string as if non type is given", function () { taskDefinition.addOptionalVariadicPositionalParam("p", "desc"); const last = getLastPositionalParam(taskDefinition); assert.equal(last.type, types.string); }); - it("should throw if a non-string default value is given but its type isn't set", () => { + it("should throw if a non-string default value is given but its type isn't set", function () { expectBuilderError( () => taskDefinition.addOptionalVariadicPositionalParam("p", "desc", 123), ERRORS.TASK_DEFINITIONS.DEFAULT_VALUE_WRONG_TYPE @@ -706,11 +706,11 @@ describe("SimpleTaskDefinition", () => { }); }); -describe("OverriddenTaskDefinition", () => { +describe("OverriddenTaskDefinition", function () { let parentTask: SimpleTaskDefinition; let overriddenTask: OverriddenTaskDefinition; - beforeEach("init tasks", () => { + beforeEach("init tasks", function () { parentTask = new SimpleTaskDefinition("t") .addParam("p", "desc") .addFlag("f") @@ -719,48 +719,48 @@ describe("OverriddenTaskDefinition", () => { overriddenTask = new OverriddenTaskDefinition(parentTask, true); }); - describe("construction", () => { - it("should have the right name", () => { + describe("construction", function () { + it("should have the right name", function () { assert.equal(overriddenTask.name, "t"); }); - it("should set isInternal", () => { + it("should set isInternal", function () { assert.isTrue(overriddenTask.isInternal); }); - it("should set the parent task", () => { + it("should set the parent task", function () { assert.equal(overriddenTask.parentTaskDefinition, parentTask); }); }); - describe("inherited properties", () => { - it("should return the parent's name", () => { + describe("inherited properties", function () { + it("should return the parent's name", function () { assert.equal(overriddenTask.name, parentTask.name); }); - it("should return the parent's action", () => { + it("should return the parent's action", function () { assert.equal(overriddenTask.action, parentTask.action); }); - it("should return the parent's description", () => { + it("should return the parent's description", function () { assert.equal( overriddenTask.description, parentTask.description === undefined ? "" : parentTask.description ); }); - it("should return the parent's param definitions", () => { + it("should return the parent's param definitions", function () { assert.equal(overriddenTask.paramDefinitions, parentTask.paramDefinitions); }); - it("should return the parent's positional param definitions", () => { + it("should return the parent's positional param definitions", function () { assert.equal( overriddenTask.positionalParamDefinitions, parentTask.positionalParamDefinitions ); }); - it("should work with more than one level of chaining", () => { + it("should work with more than one level of chaining", function () { const overriddenAgain = new OverriddenTaskDefinition(overriddenTask, false); assert.equal(overriddenAgain.isInternal, false); assert.equal(overriddenAgain.name, parentTask.name); @@ -776,7 +776,7 @@ describe("OverriddenTaskDefinition", () => { ); }); - it("should return overridden actions", () => { + it("should return overridden actions", function () { assert.equal(overriddenTask.action, parentTask.action); const action2 = async (): Promise => 1; @@ -799,7 +799,7 @@ describe("OverriddenTaskDefinition", () => { assert.equal(overriddenAgain.action, action4); }); - it("should return overridden descriptions", () => { + it("should return overridden descriptions", function () { assert.equal( overriddenTask.description, parentTask.description === undefined ? "" : parentTask.description @@ -820,8 +820,8 @@ describe("OverriddenTaskDefinition", () => { }); }); - describe("Param definitions can be added only in compatible cases", () => { - it("should add a flag param if addFlag is called", () => { + describe("Param definitions can be added only in compatible cases", function () { + it("should add a flag param if addFlag is called", function () { overriddenTask.addFlag("flagParam", "flag in overriden task"); assertParamDefinition(overriddenTask.paramDefinitions.flagParam, { name: "flagParam", @@ -834,7 +834,7 @@ describe("OverriddenTaskDefinition", () => { }); }); - it("should throw if adding a param of same name that was already defined in parent task", () => { + it("should throw if adding a param of same name that was already defined in parent task", function () { const definedParamName = "f"; // a param definition in an overridenTask is present in the parentTask ref as well assert.isDefined(overriddenTask.paramDefinitions[definedParamName]); @@ -860,14 +860,14 @@ describe("OverriddenTaskDefinition", () => { ); }); - it("should throw if addParam is called with isOptional = false", () => { + it("should throw if addParam is called with isOptional = false", function () { expectBuilderError( () => overriddenTask.addParam("p"), ERRORS.TASK_DEFINITIONS.OVERRIDE_NO_MANDATORY_PARAMS ); }); - it("should add an optional param if addParam is called with isOptional = true", () => { + it("should add an optional param if addParam is called with isOptional = true", function () { const optParamName = "optParam"; assert.isUndefined(overriddenTask.paramDefinitions[optParamName], ""); @@ -876,35 +876,35 @@ describe("OverriddenTaskDefinition", () => { assert.isDefined(overriddenTask.paramDefinitions[optParamName]); }); - it("should add an optional param if addOptionalParam is called", () => { + it("should add an optional param if addOptionalParam is called", function () { const optParamName = "optParam"; assert.isUndefined(overriddenTask.paramDefinitions[optParamName], ""); overriddenTask.addOptionalParam(optParamName); assert.isDefined(overriddenTask.paramDefinitions[optParamName]); }); - it("should throw if addPositionalParam is called", () => { + it("should throw if addPositionalParam is called", function () { expectBuilderError( () => overriddenTask.addPositionalParam("p"), ERRORS.TASK_DEFINITIONS.OVERRIDE_NO_POSITIONAL_PARAMS ); }); - it("should throw if addOptionalPositionalParam is called", () => { + it("should throw if addOptionalPositionalParam is called", function () { expectBuilderError( () => overriddenTask.addOptionalPositionalParam("p"), ERRORS.TASK_DEFINITIONS.OVERRIDE_NO_POSITIONAL_PARAMS ); }); - it("should throw if addVariadicPositionalParam is called", () => { + it("should throw if addVariadicPositionalParam is called", function () { expectBuilderError( () => overriddenTask.addVariadicPositionalParam("p"), ERRORS.TASK_DEFINITIONS.OVERRIDE_NO_VARIADIC_PARAMS ); }); - it("should throw if addOptionalVariadicPositionalParam is called", () => { + it("should throw if addOptionalVariadicPositionalParam is called", function () { expectBuilderError( () => overriddenTask.addOptionalVariadicPositionalParam("p"), ERRORS.TASK_DEFINITIONS.OVERRIDE_NO_VARIADIC_PARAMS diff --git a/packages/algob/test/internal/deployer.ts b/packages/algob/test/internal/deployer.ts index acac04d29..7701a77b5 100644 --- a/packages/algob/test/internal/deployer.ts +++ b/packages/algob/test/internal/deployer.ts @@ -30,7 +30,7 @@ function mkASA(): wtypes.ASADef { }; } -describe("DeployerDeployMode", () => { +describe("DeployerDeployMode", function () { useFixtureProject("config-project"); let deployerCfg: DeployerConfig, env; const mp = new Map(); @@ -43,7 +43,7 @@ describe("DeployerDeployMode", () => { deployerCfg.cpData = new CheckpointRepoImpl(); }); - it("Should ensure metadata existence for network", async () => { + it("Should ensure metadata existence for network", async function () { const cpData = new CheckpointRepoImpl().putMetadata("network 123", "k", "v"); assert.deepEqual(cleanupMutableData(cpData.precedingCP["network 123"], 12345), { timestamp: 12345, @@ -54,14 +54,14 @@ describe("DeployerDeployMode", () => { }); }); - it("Should hold metadata of a network", async () => { + it("Should hold metadata of a network", async function () { const deployer = new DeployerDeployMode(deployerCfg); deployer.addCheckpointKV("existent", "existent value"); assert.isUndefined(deployer.getCheckpointKV("nonexistent")); assert.equal(deployer.getCheckpointKV("existent"), "existent value"); }); - it("Should set given data into checkpoint with timestamp", async () => { + it("Should set given data into checkpoint with timestamp", async function () { const deployer = new DeployerDeployMode(deployerCfg); deployer.addCheckpointKV("key 1", "val 1"); deployer.addCheckpointKV("key 2", "val 2"); @@ -78,7 +78,7 @@ describe("DeployerDeployMode", () => { }); }); - it("Should append freshly loaded checkpoint values", async () => { + it("Should append freshly loaded checkpoint values", async function () { const cp1: Checkpoints = { network1: { timestamp: 1, @@ -118,7 +118,7 @@ describe("DeployerDeployMode", () => { }); }); - it("Should save info to checkpoint after asset deployment", async () => { + it("Should save info to checkpoint after asset deployment", async function () { const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, new AlgoOperatorDryRunImpl()); deployerCfg.asaDefs = { MY_ASA: mkASA() }; @@ -158,7 +158,7 @@ describe("DeployerDeployMode", () => { }); }); - it("Should save info to checkpoint after SSC deployment", async () => { + it("Should save info to checkpoint after SSC deployment", async function () { const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, new AlgoOperatorDryRunImpl()); const deployer = new DeployerDeployMode(deployerCfg); @@ -260,7 +260,7 @@ describe("DeployerDeployMode", () => { }); }); - it("Should save info by app name to checkpoint after App deployment if app name is passed", async () => { + it("Should save info by app name to checkpoint after App deployment if app name is passed", async function () { const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, new AlgoOperatorDryRunImpl()); const deployer = new DeployerDeployMode(deployerCfg); @@ -361,7 +361,7 @@ describe("DeployerDeployMode", () => { }); }); - it("Should save overriden asaDef to checkpoint after asset deployment if custom ASA params are passed", async () => { + it("Should save overriden asaDef to checkpoint after asset deployment if custom ASA params are passed", async function () { const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, new AlgoOperatorDryRunImpl()); const accounts = genAccounts(4); @@ -434,7 +434,7 @@ describe("DeployerDeployMode", () => { assert.deepEqual(newDeployer.asa.get("MY_ASA")?.assetDef, expectedASADef); }); - it("Should load delegated logic signature", async () => { + it("Should load delegated logic signature", async function () { const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, new AlgoOperatorDryRunImpl()); deployerCfg.asaDefs = { MY_ASA: mkASA() }; @@ -466,7 +466,7 @@ describe("DeployerDeployMode", () => { assert.deepEqual(logicSig, result); }); - it("Should use getCheckpointKV and isDefined from CheckpointData", async () => { + it("Should use getCheckpointKV and isDefined from CheckpointData", async function () { const networkName = "network1"; const env = mkEnv(networkName); const cpData = new CheckpointRepoImpl() @@ -503,14 +503,14 @@ describe("DeployerDeployMode", () => { assert.equal(deployer.getCheckpointKV("k"), "v"); }); - it("Should ignore same metadata of the same network", async () => { + it("Should ignore same metadata of the same network", async function () { const deployer = new DeployerDeployMode(deployerCfg); deployer.addCheckpointKV("existent", "existent value"); deployer.addCheckpointKV("existent", "existent value"); assert.equal(deployer.getCheckpointKV("existent"), "existent value"); }); - it("Should crash when same metadata key is set second time & different value", async () => { + it("Should crash when same metadata key is set second time & different value", async function () { const deployer = new DeployerDeployMode(deployerCfg); deployer.addCheckpointKV("metadata_key", "orig_value"); expectBuilderError( @@ -520,7 +520,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should crash when same ASA name is tried to deploy to second time", async () => { + it("Should crash when same ASA name is tried to deploy to second time", async function () { deployerCfg.asaDefs = { ASA_key: mkASA() }; const deployer = new DeployerDeployMode(deployerCfg); await deployer.deployASA("ASA_key", { creator: deployer.accounts[0] }); @@ -531,7 +531,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should crash when ASA for given name doesn't exist", async () => { + it("Should crash when ASA for given name doesn't exist", async function () { const deployer = new DeployerDeployMode(deployerCfg); await expectBuilderErrorAsync( async () => await deployer.deployASA("ASA_key", { creator: deployer.accounts[0] }), @@ -540,7 +540,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should not crash when same ASC Contract Mode name is tried to fund second time", async () => { + it("Should not crash when same ASC Contract Mode name is tried to fund second time", async function () { const deployer = new DeployerDeployMode(deployerCfg); await deployer.fundLsigByFile( "Lsig", @@ -549,7 +549,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should crash on fundLsig if lsig is not present in checkpoint", async () => { + it("Should crash on fundLsig if lsig is not present in checkpoint", async function () { const deployer = new DeployerDeployMode(deployerCfg); await expectBuilderErrorAsync( async () => @@ -563,7 +563,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should not crash on fundLsig if lsig is present in checkpoint", async () => { + it("Should not crash on fundLsig if lsig is present in checkpoint", async function () { const networkName = "network1"; const env = mkEnv(networkName); const cpData = new CheckpointRepoImpl() @@ -584,7 +584,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should crash if lsig/app name is already present in checkpoint", async () => { + it("Should crash if lsig/app name is already present in checkpoint", async function () { const networkName = "network1"; const env = mkEnv(networkName); const cpData = new CheckpointRepoImpl() @@ -620,12 +620,12 @@ describe("DeployerDeployMode", () => { ); }); - it("Should return empty ASA map on no CP", async () => { + it("Should return empty ASA map on no CP", async function () { const deployer = new DeployerDeployMode(deployerCfg); assert.deepEqual(deployer.asa, new Map()); }); - it("Should return empty ASA map on no CP; with ASA in other net", async () => { + it("Should return empty ASA map on no CP; with ASA in other net", async function () { const deployer = new DeployerDeployMode(deployerCfg); deployerCfg.cpData.registerASA("hi", "hi123", { creator: "", @@ -638,7 +638,7 @@ describe("DeployerDeployMode", () => { assert.deepEqual(deployer.asa, new Map()); }); - it("Should return correct ASA in ASA map", async () => { + it("Should return correct ASA in ASA map", async function () { deployerCfg.asaDefs = { ASA_key: mkASA() }; const deployer = new DeployerDeployMode(deployerCfg); await deployer.deployASA("ASA_key", { creator: deployer.accounts[0] }); @@ -660,7 +660,7 @@ describe("DeployerDeployMode", () => { ); }); - it("Should deploy asa without using asa.yaml", async () => { + it("Should deploy asa without using asa.yaml", async function () { const deployer = new DeployerDeployMode(deployerCfg); const asaDef = { total: 10000, diff --git a/packages/algob/test/internal/tx-log-writer.ts b/packages/algob/test/internal/tx-log-writer.ts index 84a592e59..1df4a0835 100644 --- a/packages/algob/test/internal/tx-log-writer.ts +++ b/packages/algob/test/internal/tx-log-writer.ts @@ -10,15 +10,15 @@ class TxWriterMock extends TxWriterImpl { } } -describe("Log Writer", () => { +describe("Log Writer", function () { const writer = new TxWriterMock(""); - it("change script name", () => { + it("change script name", function () { writer.setScriptName("sc-1.js"); assert.equal("sc-1.js", writer.scriptName); }); - it("Write files", () => { + it("Write files", function () { writer.writtenContent.pop(); writer.push("WriteFile", { file: "file1" }); assert.deepEqual(writer.writtenContent, [ diff --git a/packages/algob/test/internal/util/caller-package.ts b/packages/algob/test/internal/util/caller-package.ts index c791665d0..e7931688a 100644 --- a/packages/algob/test/internal/util/caller-package.ts +++ b/packages/algob/test/internal/util/caller-package.ts @@ -3,20 +3,20 @@ import { assert } from "chai"; import * as nested from "../../fixture-projects/nested-node-project/project/nested-caller-package-tester"; import * as top from "../../fixture-projects/nested-node-project/top-caller-package-tester"; -describe("getClosestCallerPackage", () => { +describe("getClosestCallerPackage", function () { top.callFromNestedModule(); top.callFromTopModule(); top.indirectlyCallFromTopModule(); - describe("When calling directly from a package", () => { - it("Should return the package it was called from", () => { + describe("When calling directly from a package", function () { + it("Should return the package it was called from", function () { assert.equal(top.callFromTopModule(), "top-level-node-project"); assert.equal(nested.callFromNestedModule(), "nested-node-project"); }); }); - describe("When calling indirectly", () => { - it("Should return the closest package from where it was called", () => { + describe("When calling indirectly", function () { + it("Should return the closest package from where it was called", function () { assert.equal(top.callFromNestedModule(), "nested-node-project"); assert.equal(top.indirectlyCallFromTopModule(), "top-level-node-project"); diff --git a/packages/algob/test/internal/util/files.ts b/packages/algob/test/internal/util/files.ts index 2d3ca16e5..9a725e3cc 100644 --- a/packages/algob/test/internal/util/files.ts +++ b/packages/algob/test/internal/util/files.ts @@ -6,7 +6,7 @@ import { loadFilenames } from "../../../src/internal/util/files"; import { expectBuilderError } from "../../helpers/errors"; import { useCleanFixtureProject } from "../../helpers/project"; -describe("loadFilenames", () => { +describe("loadFilenames", function () { useCleanFixtureProject("typescript-project"); it("Should load ts and js files from test folder", function () { const ls = loadFilenames("test"); diff --git a/packages/algob/test/internal/util/lang.ts b/packages/algob/test/internal/util/lang.ts index 3fdc77493..74f3e5f54 100644 --- a/packages/algob/test/internal/util/lang.ts +++ b/packages/algob/test/internal/util/lang.ts @@ -2,12 +2,12 @@ import { assert } from "chai"; import { fromEntries } from "../../../src/internal/util/lang"; -describe("From entries", () => { - it("Should return an empty object if entries is an empty array", () => { +describe("From entries", function () { + it("Should return an empty object if entries is an empty array", function () { assert.deepEqual(fromEntries([]), {}); }); - it("Should construct an object", () => { + it("Should construct an object", function () { const o = {}; assert.deepEqual( fromEntries([ @@ -23,7 +23,7 @@ describe("From entries", () => { ); }); - it("Should keep the last entry if there are multiple ones with the same key", () => { + it("Should keep the last entry if there are multiple ones with the same key", function () { assert.deepEqual( fromEntries([ ["a", 1], diff --git a/packages/algob/test/internal/util/lazy.ts b/packages/algob/test/internal/util/lazy.ts index aff495e82..d2de4add1 100644 --- a/packages/algob/test/internal/util/lazy.ts +++ b/packages/algob/test/internal/util/lazy.ts @@ -6,11 +6,11 @@ import { expectBuilderError } from "../../helpers/errors"; // tslint:disable no-inferred-empty-object-type -describe("lazy module", () => { - describe("lazyObject", () => { - it("shouldn't call the initializer function eagerly", () => { +describe("lazy module", function () { + describe("lazyObject", function () { + it("shouldn't call the initializer function eagerly", function () { let called = false; - lazyObject(() => { + lazyObject(function () { called = true; return {}; }); @@ -18,15 +18,15 @@ describe("lazy module", () => { assert.isFalse(called); }); - it("should throw if the objectConstructor doesn't return an object", () => { + it("should throw if the objectConstructor doesn't return an object", function () { const num = lazyObject(() => 123 as any); assert.throws(() => num.asd); }); - it("should call the initializer just once", () => { + it("should call the initializer just once", function () { let numberOfCalls = 0; - const obj = lazyObject(() => { + const obj = lazyObject(function () { numberOfCalls += 1; return { a: 1 as number | undefined, @@ -55,7 +55,7 @@ describe("lazy module", () => { assert.equal(numberOfCalls, 1); }); - it("should be equivalent to the object returned by the initializer", () => { + it("should be equivalent to the object returned by the initializer", function () { const expected = { a: 123, b: "asd", @@ -71,16 +71,16 @@ describe("lazy module", () => { assert.deepEqual(obj, expected); }); - it("doesn't support classes", () => { - const obj = lazyObject(() => class {}) as any; // eslint-disable-line @typescript-eslint/no-extraneous-class + it("doesn't support classes", function () { + const obj = lazyObject(() => class { }) as any; // eslint-disable-line @typescript-eslint/no-extraneous-class expectBuilderError(() => (obj.asd = 123), ERRORS.GENERAL.UNSUPPORTED_OPERATION); expectBuilderError(() => obj.asd, ERRORS.GENERAL.UNSUPPORTED_OPERATION); assert.throws(() => new obj(), "obj is not a constructor"); // eslint-disable-line new-cap }); - it("doesn't support functions", () => { - const obj = lazyObject(() => () => {}) as any; // eslint-disable-line @typescript-eslint/no-empty-function + it("doesn't support functions", function () { + const obj = lazyObject(() => function () { }) as any; // eslint-disable-line @typescript-eslint/no-empty-function expectBuilderError(() => (obj.asd = 123), ERRORS.GENERAL.UNSUPPORTED_OPERATION); expectBuilderError(() => obj.asd, ERRORS.GENERAL.UNSUPPORTED_OPERATION); @@ -88,26 +88,26 @@ describe("lazy module", () => { assert.throws(() => obj(), "obj is not a function"); }); - it("should trap defineProperty correctly", () => { + it("should trap defineProperty correctly", function () { const obj = lazyObject(() => ({})) as any; obj.asd = 123; assert.equal(obj.asd, 123); }); - it("should trap deleteProperty correctly", () => { + it("should trap deleteProperty correctly", function () { const obj = lazyObject(() => ({ a: 1 as number | undefined })); delete obj.a; assert.isUndefined(obj.a); }); - it("should trap get correctly", () => { + it("should trap get correctly", function () { const obj = lazyObject(() => ({ a: 1 })); assert.equal(obj.a, 1); }); - it("should trap getOwnPropertyDescriptor correctly", () => { + it("should trap getOwnPropertyDescriptor correctly", function () { const obj = lazyObject(() => ({ a: 1 })); assert.deepEqual(Object.getOwnPropertyDescriptor(obj, "a"), { @@ -118,15 +118,15 @@ describe("lazy module", () => { }); }); - it("should trap getPrototypeOf correctly", () => { + it("should trap getPrototypeOf correctly", function () { const proto = {}; const obj = lazyObject(() => Object.create(proto)); assert.equal(Object.getPrototypeOf(obj), proto); }); - it("should trap isExtensible correctly", () => { - const obj = lazyObject(() => { + it("should trap isExtensible correctly", function () { + const obj = lazyObject(function () { const v = {}; Object.preventExtensions(v); @@ -139,36 +139,36 @@ describe("lazy module", () => { assert.isTrue(Object.isExtensible(obj2)); }); - describe("Lazy object with a property", () => { + describe("Lazy object with a property", function () { const proto = { a: 1 }; - const obj = lazyObject(() => { + const obj = lazyObject(function () { const v = Object.create(proto); v.b = 1; return v; }); - it("should trap has correctly", () => { + it("should trap has correctly", function () { assert.isTrue("a" in obj); assert.isTrue("b" in obj); assert.isFalse("c" in obj); }); - it("should trap ownKeys correctly", () => { + it("should trap ownKeys correctly", function () { obj.c = 123; assert.deepEqual(Object.getOwnPropertyNames(obj), ["b", "c"]); }); }); - it("should trap preventExtensions correctly", () => { + it("should trap preventExtensions correctly", function () { const obj = lazyObject(() => ({})); Object.preventExtensions(obj); assert.isFalse(Object.isExtensible(obj)); }); - it("should trap set correctly", () => { + it("should trap set correctly", function () { const obj = lazyObject(() => ({})) as any; obj.asd = 123; @@ -176,7 +176,7 @@ describe("lazy module", () => { assert.equal(obj.asd, 123); }); - it("should trap setPrototypeOf correctly", () => { + it("should trap setPrototypeOf correctly", function () { const proto = Object.create(null); const obj = lazyObject(() => Object.create(proto)); assert.equal(Object.getPrototypeOf(obj), proto); @@ -188,20 +188,20 @@ describe("lazy module", () => { assert.equal(obj.a, 123); }); - it("should throw if it's used to create an object without prototype", () => { + it("should throw if it's used to create an object without prototype", function () { const obj = lazyObject(() => Object.create(null)); expectBuilderError(() => obj.asd, ERRORS.GENERAL.UNSUPPORTED_OPERATION); }); }); }); -describe("lazy import", () => { - it("should work with a function module", () => { +describe("lazy import", function () { + it("should work with a function module", function () { const lazyF = lazyFunction(() => () => ({ a: 1, b: 2 })); assert.deepEqual(lazyF(), { a: 1, b: 2 }); }); - it("should work with a class module", () => { + it("should work with a class module", function () { const lazyC = lazyFunction( () => class { diff --git a/packages/algob/test/internal/util/package-info.ts b/packages/algob/test/internal/util/package-info.ts index 6689c3cba..7f7b5579f 100644 --- a/packages/algob/test/internal/util/package-info.ts +++ b/packages/algob/test/internal/util/package-info.ts @@ -4,15 +4,15 @@ import path from "path"; import { getPackageJson, getPackageRoot } from "../../../src/internal/util/package-info"; -describe("package-info", () => { - it("Should give the right package.json", async () => { +describe("package-info", function () { + it("Should give the right package.json", async function () { const packageJson = await getPackageJson(); assert.equal(packageJson.name, "@algo-builder/algob"); // We don't test the version number because that would be hard to maintain assert.isString(packageJson.version); }); - it("should give the right package root", async () => { + it("should give the right package root", async function () { const root = await fsExtra.realpath(path.join(__dirname, "..", "..", "..")); assert.equal(await getPackageRoot(), root); }); diff --git a/packages/algob/test/internal/util/unsafe.ts b/packages/algob/test/internal/util/unsafe.ts index 88c39ba44..7e4996487 100644 --- a/packages/algob/test/internal/util/unsafe.ts +++ b/packages/algob/test/internal/util/unsafe.ts @@ -2,9 +2,9 @@ import { assert } from "chai"; import { unsafeObjectKeys } from "../../../src/internal/util/unsafe"; -describe("Type unsafe helpers functions", () => { - describe("unsafeObjectKeys", () => { - it("Should return the right type", () => { +describe("Type unsafe helpers functions", function () { + describe("unsafeObjectKeys", function () { + it("Should return the right type", function () { interface T { a: string; b: number; @@ -18,7 +18,7 @@ describe("Type unsafe helpers functions", () => { assert.deepEqual([...new Set(keys)], [...new Set(["a", "b"])]); }); - it("Should work with extended types, but that's unsafe", () => { + it("Should work with extended types, but that's unsafe", function () { interface T { a: string; b: number; diff --git a/packages/algob/test/lib/account.ts b/packages/algob/test/lib/account.ts index 8e77e8aaa..c6bcd3e7c 100644 --- a/packages/algob/test/lib/account.ts +++ b/packages/algob/test/lib/account.ts @@ -5,13 +5,13 @@ import { assert } from "chai"; import { loadAccountsFromEnv, mkAccounts } from "../../src/lib/account"; import { AccountDef } from "../../src/types"; -describe("Loading accounts", () => { +describe("Loading accounts", function () { const genAccount = generateAccount(); const gen = { name: "gen_1", addr: genAccount.addr, sk: genAccount.sk }; const skArray = Array.from({ length: 64 }, (_, i) => i + 1); const account1 = { name: "a1", addr: "a1", sk: new Uint8Array(skArray) }; - it("mkAccounts works when input is a list of Account objects", () => { + it("mkAccounts works when input is a list of Account objects", function () { let a = mkAccounts([]); assert.deepEqual(a, [], "should return empty list on empty input"); @@ -23,7 +23,7 @@ describe("Loading accounts", () => { assert.deepEqual(a, expected, "Account instances should be just copied"); }); - it("mkAccounts handles mnemonic accounts and handles address check", () => { + it("mkAccounts handles mnemonic accounts and handles address check", function () { // we don't check empty addreses const expected = [gen]; let input = [{ name: "gen_1", addr: "", mnemonic: secretKeyToMnemonic(gen.sk) }]; @@ -57,7 +57,7 @@ describe("Loading accounts", () => { ); }); - it("Handles mixture of accounts", () => { + it("Handles mixture of accounts", function () { // fails on HD account let input: AccountDef[] = [{ path: "0/1", mnemonic: "" }]; const errmsg = "ABLDR402: HD accounts is not yet supported"; @@ -72,7 +72,7 @@ describe("Loading accounts", () => { assert.deepEqual(mkAccounts(input), [account1, gen]); }); - it("From ENV variable (ALGOB_ACCOUNTS) ", () => { + it("From ENV variable (ALGOB_ACCOUNTS) ", function () { const goodMnemonic = "call boy rubber fashion arch day capable one sweet skate outside purse six early learn tuition eagle love breeze pizza loud today popular able divide"; process.env.ALGOB_ACCOUNTS = JSON.stringify([{ name: "master", mnemonic: goodMnemonic }]); @@ -86,7 +86,7 @@ describe("Loading accounts", () => { assert.deepEqual(algobAccounts, [], "Loaded accounts mismatch"); }); - it("ENV variables validate ALGOB_ACCOUNTS ", () => { + it("ENV variables validate ALGOB_ACCOUNTS ", function () { const goodMnemonic = "call boy rubber fashion arch day capable one sweet skate outside purse six early learn tuition eagle love breeze pizza loud today popular able divide"; const emptyMnemonic = ""; diff --git a/packages/algob/test/lib/credentials.ts b/packages/algob/test/lib/credentials.ts index d9d48972b..85e8c9650 100644 --- a/packages/algob/test/lib/credentials.ts +++ b/packages/algob/test/lib/credentials.ts @@ -4,24 +4,24 @@ import * as path from "path"; import { algodCredentialsFromEnv, KMDCredentialsFromEnv } from "../../src/lib/credentials"; import { getFixtureProjectPath, useFixtureProject } from "../helpers/project"; -describe("Credentials loading from env: ", () => { +describe("Credentials loading from env: ", function () { useFixtureProject("algorand-node-data"); process.env.ALGOD_ADDR = "127.0.0.1:8080"; process.env.ALGOD_TOKEN = "algod_token"; - it("Algod Credentials Using Method 1", () => { + it("Algod Credentials Using Method 1", function () { const result = algodCredentialsFromEnv(); assert.deepEqual(result, { host: "127.0.0.1", port: 8080, token: "algod_token" }); }); - it("Algod Credentials Missing (Method 1)", () => { + it("Algod Credentials Missing (Method 1)", function () { delete process.env.ALGOD_ADDR; const errmsg = "Both Algod Token and Algod Address should be defined in env"; assert.throws(() => algodCredentialsFromEnv(), errmsg); }); - it("Algod Credentials Using Method 2", () => { + it("Algod Credentials Using Method 2", function () { delete process.env.ALGOD_TOKEN; process.env.ALGORAND_DATA = path.join(getFixtureProjectPath("algorand-node-data"), "Node"); @@ -33,7 +33,7 @@ describe("Credentials loading from env: ", () => { }); }); - it("Algod Credentials Missing (Method 2)", () => { + it("Algod Credentials Missing (Method 2)", function () { delete process.env.ALGORAND_DATA; const errmsg = @@ -44,19 +44,19 @@ describe("Credentials loading from env: ", () => { process.env.KMD_ADDR = "127.0.0.1:3480"; process.env.KMD_TOKEN = "kmd_token"; - it("KMD Credentials Using Method 1", () => { + it("KMD Credentials Using Method 1", function () { const result = KMDCredentialsFromEnv(); assert.deepEqual(result, { host: "http://127.0.0.1", port: 3480, token: "kmd_token" }); }); - it("KMD Credentials Missing (Method 1)", () => { + it("KMD Credentials Missing (Method 1)", function () { delete process.env.KMD_TOKEN; const errmsg = "Both KMD Token and KMD Address should be defined in env"; assert.throws(() => KMDCredentialsFromEnv(), errmsg); }); - it("KMD Credentials Using Method 2", () => { + it("KMD Credentials Using Method 2", function () { delete process.env.KMD_ADDR; process.env.KMD_DATA = path.join(getFixtureProjectPath("algorand-node-data"), "Node/kmd"); @@ -68,7 +68,7 @@ describe("Credentials loading from env: ", () => { }); }); - it("KMD Credentials Missing (Method 2)", () => { + it("KMD Credentials Missing (Method 2)", function () { delete process.env.KMD_DATA; const errmsg = "Either KMD Credentials or KMD_DATA should be defined in env"; diff --git a/packages/algob/test/lib/dryrun.ts b/packages/algob/test/lib/dryrun.ts index 09825e907..f330fc15a 100644 --- a/packages/algob/test/lib/dryrun.ts +++ b/packages/algob/test/lib/dryrun.ts @@ -42,14 +42,14 @@ class TealDbgMock extends Tealdbg { } } -describe("Debugging TEAL code using tealdbg", () => { +describe("Debugging TEAL code using tealdbg", function () { useFixtureProject("config-project"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; let txParam: ExecParams; let tealDebugger: TealDbgMock; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -86,7 +86,7 @@ describe("Debugging TEAL code using tealdbg", () => { tealDebugger = new TealDbgMock(deployer, txParam); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.dryrun as SinonStub).restore(); (algod.algodClient.accountInformation as SinonStub).restore(); @@ -94,7 +94,7 @@ describe("Debugging TEAL code using tealdbg", () => { (algod.algodClient.genesis as SinonStub).restore(); }); - it("dump dryrunResponse in assets/", async () => { + it("dump dryrunResponse in assets/", async function () { const resp = await tealDebugger.dryRunResponse(); // assert recieved response @@ -112,7 +112,7 @@ describe("Debugging TEAL code using tealdbg", () => { fs.rmSync(outPath); }); - it("should warn or overwrite existing dryRunResponse based on --force flag", async () => { + it("should warn or overwrite existing dryRunResponse based on --force flag", async function () { const stub = console.error as SinonStub; stub.reset(); @@ -132,7 +132,7 @@ describe("Debugging TEAL code using tealdbg", () => { fs.rmSync(path.join(process.cwd(), ASSETS_DIR, "response.json")); }); - it("should write --dryrun-dump in `cache/dryrun` and run debugger with provided args", async () => { + it("should write --dryrun-dump in `cache/dryrun` and run debugger with provided args", async function () { assert.equal(tealDebugger.writtenFiles.length, 0); await tealDebugger.run(); @@ -158,7 +158,7 @@ describe("Debugging TEAL code using tealdbg", () => { assert.include(tealDebugger.debugArgs, "0"); }); - it("should throw error if groupIndex is greator than txGroup length", async () => { + it("should throw error if groupIndex is greator than txGroup length", async function () { tealDebugger.execParams = [txParam, { ...txParam, payFlags: { note: "Algrand" } }]; try { @@ -171,7 +171,7 @@ describe("Debugging TEAL code using tealdbg", () => { } }); - it("should run debugger using pyteal files as well", async () => { + it("should run debugger using pyteal files as well", async function () { const writtenFilesBeforeLen = tealDebugger.writtenFiles.length; await tealDebugger.run({ tealFile: "gold-asa.py" }); @@ -179,7 +179,7 @@ describe("Debugging TEAL code using tealdbg", () => { assert.equal(tealDebugger.writtenFiles.length, writtenFilesBeforeLen + 2); }); - it("should run debugger from cached TEAL code", async () => { + it("should run debugger from cached TEAL code", async function () { const stub = console.info as SinonStub; stub.reset(); const writtenFilesBeforeLen = tealDebugger.writtenFiles.length; diff --git a/packages/algob/test/lib/files.ts b/packages/algob/test/lib/files.ts index 8e7c53627..fc546e553 100644 --- a/packages/algob/test/lib/files.ts +++ b/packages/algob/test/lib/files.ts @@ -4,18 +4,18 @@ import { assert } from "chai"; import { assertDirChildren, assertDirectDirChildren } from "../../src/lib/files"; import { expectBuilderError } from "../helpers/errors"; -describe("assertDirChildren", () => { - it("Should pass for children inputs", async () => { +describe("assertDirChildren", function () { + it("Should pass for children inputs", async function () { const out = assertDirChildren("a", ["a/a/a/b", "a/b", "a/b/c", "./a/e"]); assert.deepEqual(out, ["a/a/a/b", "a/b", "a/b/c", "a/e"]); }); - it("Should normalize paths", async () => { + it("Should normalize paths", async function () { const out = assertDirChildren("a", ["a/q/q/../../a/a/b", "a/q/q/../../b"]); assert.deepEqual(out, ["a/a/a/b", "a/b"]); }); - it("Should crash on outside path", async () => { + it("Should crash on outside path", async function () { expectBuilderError( () => assertDirChildren("a", ["../../q/q/a/c"]), ERRORS.BUILTIN_TASKS.SCRIPTS_OUTSIDE_SCRIPTS_DIRECTORY, @@ -24,8 +24,8 @@ describe("assertDirChildren", () => { }); }); -describe("assertDirectDirChildren", () => { - it("Should pass for children inputs", async () => { +describe("assertDirectDirChildren", function () { + it("Should pass for children inputs", async function () { const out = assertDirectDirChildren("a", [ "a/b", "a/c", @@ -37,7 +37,7 @@ describe("assertDirectDirChildren", () => { assert.deepEqual(out, ["a/b", "a/c", "a/d", "a/e", "a/f", "a/g"]); }); - it("Should crash on deep path", async () => { + it("Should crash on deep path", async function () { expectBuilderError( () => assertDirectDirChildren("a", ["a/b/c"]), ERRORS.BUILTIN_TASKS.DEPLOY_SCRIPT_NON_DIRECT_CHILD, @@ -45,7 +45,7 @@ describe("assertDirectDirChildren", () => { ); }); - it("Should crash on outside path", async () => { + it("Should crash on outside path", async function () { expectBuilderError( () => assertDirectDirChildren("a", ["a/../b/1"]), ERRORS.BUILTIN_TASKS.DEPLOY_SCRIPT_NON_DIRECT_CHILD, diff --git a/packages/algob/test/lib/script-checkpoints.ts b/packages/algob/test/lib/script-checkpoints.ts index 672e47a2c..ed8e09fc9 100644 --- a/packages/algob/test/lib/script-checkpoints.ts +++ b/packages/algob/test/lib/script-checkpoints.ts @@ -34,8 +34,8 @@ function createNetwork(timestamp: number): Checkpoint { }; } -describe("Checkpoint", () => { - it("Should create a network checkpoint", async () => { +describe("Checkpoint", function () { + it("Should create a network checkpoint", async function () { const beforeTimestamp = +new Date(); const netCheckpoint: Checkpoint = new CheckpointImpl(); const afterTimestamp = +new Date(); @@ -45,7 +45,7 @@ describe("Checkpoint", () => { assert.deepEqual(netCheckpoint, createNetwork(12345)); }); - it("Should append to a checkpoint map", async () => { + it("Should append to a checkpoint map", async function () { let checkpoints: Checkpoints = {}; const netCheckpoint: Checkpoint = cleanupMutableData(new CheckpointImpl(), 34251); const checkpoint = appendToCheckpoint(checkpoints, "network213", netCheckpoint); @@ -58,7 +58,7 @@ describe("Checkpoint", () => { }); }); - it("Should replace in checkpoint map", async () => { + it("Should replace in checkpoint map", async function () { let checkpoints: Checkpoints = {}; const netCheckpoint: Checkpoint = cleanupMutableData(new CheckpointImpl(), 34251); checkpoints = appendToCheckpoint(checkpoints, "network525", netCheckpoint); @@ -72,7 +72,7 @@ describe("Checkpoint", () => { }); }); - it("Should merge metadata maps", async () => { + it("Should merge metadata maps", async function () { let checkpoints: Checkpoints = {}; const netCheckpoint: Checkpoint = cleanupMutableData( new CheckpointImpl( @@ -208,7 +208,7 @@ describe("Checkpoint", () => { }); }); - it("Should crash if duplicate asa or SSC name is detected", async () => { + it("Should crash if duplicate asa or SSC name is detected", async function () { const checkpoints: Checkpoints = {}; const cp1: Checkpoint = cleanupMutableData( new CheckpointImpl( @@ -244,7 +244,7 @@ describe("Checkpoint", () => { ); }); // add test - it("Should crash if duplicate SSC name is detected", async () => { + it("Should crash if duplicate SSC name is detected", async function () { const checkpoints: Checkpoints = {}; const cp1: Checkpoint = cleanupMutableData( new CheckpointImpl( @@ -290,22 +290,22 @@ describe("Checkpoint", () => { ); }); - it("Should produce a checkpoint file name from script name", async () => { + it("Should produce a checkpoint file name from script name", async function () { const checkpointFileName = toCheckpointFileName("script-1.js"); assert.equal(checkpointFileName, "artifacts/script-1.js.cp.yaml"); }); - it("Should produce a script file name from checkpoint name", async () => { + it("Should produce a script file name from checkpoint name", async function () { const checkpointFileName = toScriptFileName("artifacts/script-1.js.cp.yaml.hi.cp.yaml"); assert.equal(checkpointFileName, "script-1.js.cp.yaml.hi"); }); - it("Should default to empty cp if loading nonexistent file", async () => { + it("Should default to empty cp if loading nonexistent file", async function () { const loadedCP = loadCheckpoint("nonexistent"); assert.deepEqual(loadedCP, {}); }); - it("Should allow registration of an asset", async () => { + it("Should allow registration of an asset", async function () { const cp: CheckpointImpl = new CheckpointImpl(); cp.timestamp = 12345; assert.deepEqual(cp, createNetwork(12345)); @@ -352,8 +352,8 @@ describe("Checkpoint", () => { }); }); -describe("Checkpoint with cleanup", () => { - afterEach(() => { +describe("Checkpoint with cleanup", function () { + afterEach(function () { try { fs.rmdirSync("artifacts", { recursive: true }); } catch (err) { @@ -361,7 +361,7 @@ describe("Checkpoint with cleanup", () => { } }); - it("Should persist and load the checkpoint", async () => { + it("Should persist and load the checkpoint", async function () { const origCP = appendToCheckpoint( { hi: createNetwork(123), @@ -374,16 +374,16 @@ describe("Checkpoint with cleanup", () => { assert.deepEqual(loadedCP, origCP); }); - it("Should persist empty checkpoint as empty file", async () => { + it("Should persist empty checkpoint as empty file", async function () { persistCheckpoint("script-1.js", {}); const loadedCP = loadCheckpoint("script-1.js"); assert.deepEqual(loadedCP, {}); }); }); -describe("CheckpointRepoImpl", () => { +describe("CheckpointRepoImpl", function () { const nestedMap = new Map(); - it("Should crash if duplication is detected between scripts", async () => { + it("Should crash if duplication is detected between scripts", async function () { const cp1: Checkpoints = { network1: { timestamp: 1, @@ -434,7 +434,7 @@ describe("CheckpointRepoImpl", () => { ); }); - it("Should allow to set metadata", async () => { + it("Should allow to set metadata", async function () { const cp = new CheckpointRepoImpl().putMetadata("myNetworkName", "key", "data").precedingCP; assert.isNotNull(cp.myNetworkName); cp.myNetworkName = cleanupMutableData(cp.myNetworkName, 951); @@ -449,7 +449,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should allow to set metadata two networks", async () => { + it("Should allow to set metadata two networks", async function () { const cp = new CheckpointRepoImpl() .putMetadata("myNetworkName", "key", "data") .putMetadata("myNetworkName2", "key2", "data2").precedingCP; @@ -474,7 +474,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should allow placing state; one network", () => { + it("Should allow placing state; one network", function () { const cpData = new CheckpointRepoImpl() .registerASA("network1", "ASA name", { creator: "ASA creator 123", @@ -509,7 +509,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should allow placing state; two networks", () => { + it("Should allow placing state; two networks", function () { const nestedMap = new Map(); nestedMap.set(1, { creator: "SSC creator 951", @@ -555,7 +555,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should merge checkpoints", async () => { + it("Should merge checkpoints", async function () { const cp1: Checkpoints = { network1: { timestamp: 1, @@ -593,7 +593,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should deeply merge the checkpoints", async () => { + it("Should deeply merge the checkpoints", async function () { const cp1: Checkpoints = { network1: { timestamp: 1, @@ -693,7 +693,7 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should deeply merge global checkpoints", async () => { + it("Should deeply merge global checkpoints", async function () { const nestedMap = new Map(); const nestedMap1 = new Map(); nestedMap.set(1, { @@ -777,7 +777,7 @@ describe("CheckpointRepoImpl", () => { }); }); - describe("CheckpointRepoImpl with sample data", () => { + describe("CheckpointRepoImpl with sample data", function () { const cp1: Checkpoints = { network1: { timestamp: 1, @@ -832,7 +832,7 @@ describe("CheckpointRepoImpl", () => { assert.isUndefined(cpData.strippedCP.network4); cpData.strippedCP["net 0195"].timestamp = 195; - it("Should contain factory methods for ASA anc SSC asset registration", () => { + it("Should contain factory methods for ASA anc SSC asset registration", function () { const nestedMap = new Map(); nestedMap.set(1, { creator: "SSC creator 951", @@ -948,14 +948,14 @@ describe("CheckpointRepoImpl", () => { }); }); - it("Should return metadata for specified network", () => { + it("Should return metadata for specified network", function () { assert.equal(cpData.getMetadata("network1", "hi"), undefined); assert.equal(cpData.getMetadata("network1", "metadata key"), "metadata value"); assert.equal(cpData.getMetadata("network4", "metadata key"), undefined); }); }); - it("isDefined should return true regardless of the asset type", () => { + it("isDefined should return true regardless of the asset type", function () { const cpData = new CheckpointRepoImpl(); assert.isFalse(cpData.isDefined("network1", "ASA name")); assert.isFalse(cpData.isDefined("network1", "SSC name")); diff --git a/packages/algob/test/lib/status.ts b/packages/algob/test/lib/status.ts index 136043e7c..5fdb751fe 100644 --- a/packages/algob/test/lib/status.ts +++ b/packages/algob/test/lib/status.ts @@ -10,13 +10,13 @@ import { mkEnv } from "../helpers/params"; import { mockAccountInformation } from "../mocks/tx"; import { AlgoOperatorDryRunImpl } from "../stubs/algo-operator"; -describe("Status package", () => { +describe("Status package", function () { let deployer: Deployer; const algod = new AlgoOperatorDryRunImpl(); const env = mkEnv("network1"); const deployerCfg = new DeployerConfig(env, algod); - before(async () => { + before(async function () { deployer = new DeployerRunMode(deployerCfg); (sinon.stub(algod.algodClient, "accountInformation") as any).returns({ @@ -24,24 +24,24 @@ describe("Status package", () => { }) as ReturnType; }); - after(async () => { + after(async function () { (algod.algodClient.accountInformation as sinon.SinonStub).restore(); }); - it("balanceOf should return corrent amount when account hold an asset", async () => { + it("balanceOf should return corrent amount when account hold an asset", async function () { const assetID = mockAccountInformation.assets[0]["asset-id"]; const amount = mockAccountInformation.assets[0].amount; expect(await balanceOf(deployer, mockAccountInformation.address, assetID)).to.equal(amount); }); - it("balanceOf should return 0 when account does hold an asset", async () => { + it("balanceOf should return 0 when account does hold an asset", async function () { const otherAssetID = 0; expect(await balanceOf(deployer, mockAccountInformation.address, otherAssetID)).to.equal( 0n ); }); - it("balaceOf should return account balance(in ALGO) when assetID undefined", async () => { + it("balaceOf should return account balance(in ALGO) when assetID undefined", async function () { expect(await balanceOf(deployer, mockAccountInformation.address)).to.equal( mockAccountInformation.amount ); diff --git a/packages/algob/test/lib/tx.ts b/packages/algob/test/lib/tx.ts index 0a221672b..4cd5193c2 100644 --- a/packages/algob/test/lib/tx.ts +++ b/packages/algob/test/lib/tx.ts @@ -27,19 +27,19 @@ import { } from "../mocks/tx"; import { AlgoOperatorDryRunImpl } from "../stubs/algo-operator"; -describe("Note in TxParams", () => { +describe("Note in TxParams", function () { const encoder = new TextEncoder(); const note = "Hello Algob!"; const noteb64Src = "hello"; const noteb64 = Buffer.from(noteb64Src).toString("base64"); - it("Both notes given", () => { - assert.throw(() => { + it("Both notes given", function () { + assert.throw(function () { webTx.encodeNote(note, noteb64); }, "both note and noteb64"); }); - it("Only note given", () => { + it("Only note given", function () { let result = webTx.encodeNote(note, undefined); assert.deepEqual(result, encoder.encode(note), "note not encoded"); @@ -48,7 +48,7 @@ describe("Note in TxParams", () => { assert.deepEqual(result, noteEncoded, "note not encoded"); }); - it("Only noteb64 given", () => { + it("Only noteb64 given", function () { const result = webTx.encodeNote(undefined, noteb64); assert.isDefined(result); assert.deepEqual( @@ -77,14 +77,14 @@ function stubAlgodGenesisAndTxParams(algodClient: algosdk.Algodv2): void { >); } -describe("Opt-In to ASA", () => { +describe("Opt-In to ASA", function () { useFixtureProject("config-project"); let deployer: Deployer; let execParams: wtypes.OptInASAParam; let algod: AlgoOperatorDryRunImpl; let expected: TxnReceipt[]; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -113,18 +113,18 @@ describe("Opt-In to ASA", () => { ]; }); - afterEach(() => { + afterEach(function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("should opt-in to asa using asset id as number", async () => { + it("should opt-in to asa using asset id as number", async function () { const res = await deployer.executeTx([execParams]); assert.deepEqual(res, expected); }); - it("Should fail if asset name is passed but not found in checkpoints", async () => { + it("Should fail if asset name is passed but not found in checkpoints", async function () { execParams.assetID = "unknown"; await expectBuilderErrorAsync( @@ -134,7 +134,7 @@ describe("Opt-In to ASA", () => { ); }); - it("Should set asset id to asset id of asset name passed", async () => { + it("Should set asset id to asset id of asset name passed", async function () { execParams.assetID = "silver"; const res = await deployer.executeTx([execParams]); @@ -143,13 +143,13 @@ describe("Opt-In to ASA", () => { }); }); -describe("ASA modify fields", () => { +describe("ASA modify fields", function () { useFixtureProject("config-project"); let deployer: Deployer; let execParams: wtypes.ModifyAssetParam; let algod: AlgoOperatorDryRunImpl; let assetFields: wtypes.AssetModFields; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -169,7 +169,7 @@ describe("ASA modify fields", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); @@ -193,7 +193,7 @@ describe("ASA modify fields", () => { return algod.sendAndWait(rawTxns); } - it("Should set fields, freeze is not sent, therefore it should be picked from assetInfo", async () => { + it("Should set fields, freeze is not sent, therefore it should be picked from assetInfo", async function () { // Manager should be set to ""(sent as undefined to network) // Clawback should be updated stub(algod, "sendAndWait").callsFake(checkTx); @@ -202,11 +202,11 @@ describe("ASA modify fields", () => { }); }); -describe("Delete ASA and SSC", () => { +describe("Delete ASA and SSC", function () { useFixtureProjectCopy("stateful"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -216,12 +216,12 @@ describe("Delete ASA and SSC", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("Should delete ASA, and set delete boolean in ASAInfo", async () => { + it("Should delete ASA, and set delete boolean in ASAInfo", async function () { const execParams: wtypes.DestroyAssetParam = { type: wtypes.TransactionType.DestroyAsset, sign: wtypes.SignType.SecretKey, @@ -235,7 +235,7 @@ describe("Delete ASA and SSC", () => { assert.equal(res.deleted, true); }); - it("Should delete ASA If asset index is used, instead of asset name", async () => { + it("Should delete ASA If asset index is used, instead of asset name", async function () { const execParams: wtypes.DestroyAssetParam = { type: wtypes.TransactionType.DestroyAsset, sign: wtypes.SignType.SecretKey, @@ -249,7 +249,7 @@ describe("Delete ASA and SSC", () => { assert.equal(res.deleted, true); }); - it("Should not fail if ASA is not in checkpoints", async () => { + it("Should not fail if ASA is not in checkpoints", async function () { const execParams: wtypes.DestroyAssetParam = { type: wtypes.TransactionType.DestroyAsset, sign: wtypes.SignType.SecretKey, @@ -260,7 +260,7 @@ describe("Delete ASA and SSC", () => { await deployer.executeTx([execParams]); }); - it("Should delete SSC, set delete boolean in latest AppInfo", async () => { + it("Should delete SSC, set delete boolean in latest AppInfo", async function () { const appDefinition: wtypes.AppDefinitionFromFile = { appName: "app", metaType: wtypes.MetaType.FILE, @@ -287,7 +287,7 @@ describe("Delete ASA and SSC", () => { if (res) assert.equal(res.deleted, true); }); - it("Should not fail if SSC is not in checkpoints", async () => { + it("Should not fail if SSC is not in checkpoints", async function () { const execParams: wtypes.AppCallsParam = { type: wtypes.TransactionType.DeleteApp, sign: wtypes.SignType.SecretKey, @@ -299,14 +299,14 @@ describe("Delete ASA and SSC", () => { }); }); -describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () => { +describe("Delete ASA and SSC transaction flow(with functions and executeTx)", function () { useFixtureProject("stateful"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; let appID: number; let assetID: number; const assetName = "silver"; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -349,12 +349,12 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () await deployer.executeTx([execParam]); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("should throw error with opt-in asa functions, if asa exist and deleted", async () => { + it("should throw error with opt-in asa functions, if asa exist and deleted", async function () { await expectBuilderErrorAsync( async () => await deployer.optInAccountToASA(assetName, "acc-name-1", {}), ERRORS.GENERAL.ASSET_DELETED @@ -366,13 +366,13 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should pass with opt-in asa functions, if asa doesn't exist in checkpoint", async () => { + it("should pass with opt-in asa functions, if asa doesn't exist in checkpoint", async function () { await deployer.optInAccountToASA("23", "acc-name-1", {}); await deployer.optInLsigToASA("233212", mockLsig, {}); }); - it("should throw error with opt-in app functions, if app exist and deleted", async () => { + it("should throw error with opt-in app functions, if app exist and deleted", async function () { await expectBuilderErrorAsync( async () => await deployer.optInAccountToApp(bobAcc, appID, {}, {}), ERRORS.GENERAL.APP_DELETED @@ -384,13 +384,13 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should pass with opt-in app functions, if app doesn't exist in checkpoint", async () => { + it("should pass with opt-in app functions, if app doesn't exist in checkpoint", async function () { await deployer.optInAccountToApp(bobAcc, 122, {}, {}); await deployer.optInLsigToApp(12223, mockLsig, {}, {}); }); - it("should throw error with update app function, if app exist and deleted", async () => { + it("should throw error with update app function, if app exist and deleted", async function () { await expectBuilderErrorAsync( async () => await deployer.updateApp( @@ -409,7 +409,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should pass with update app functions, if app doesn't exist in checkpoint", async () => { + it("should pass with update app functions, if app doesn't exist in checkpoint", async function () { await deployer.updateApp( "app", bobAcc, @@ -424,7 +424,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to opt-in through execute tx", async () => { + it("should fail if user tries to opt-in through execute tx", async function () { const execParam: wtypes.OptInASAParam = { type: wtypes.TransactionType.OptInASA, sign: wtypes.SignType.SecretKey, @@ -438,7 +438,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to modify through execute tx", async () => { + it("should fail if user tries to modify through execute tx", async function () { const execParam: wtypes.ModifyAssetParam = { type: wtypes.TransactionType.ModifyAsset, sign: wtypes.SignType.SecretKey, @@ -453,7 +453,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to freeze through execute tx", async () => { + it("should fail if user tries to freeze through execute tx", async function () { const execParam: wtypes.FreezeAssetParam = { type: wtypes.TransactionType.FreezeAsset, sign: wtypes.SignType.SecretKey, @@ -469,7 +469,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to revoke through execute tx", async () => { + it("should fail if user tries to revoke through execute tx", async function () { const execParam: wtypes.RevokeAssetParam = { type: wtypes.TransactionType.RevokeAsset, sign: wtypes.SignType.SecretKey, @@ -486,7 +486,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to destroy through execute tx", async () => { + it("should fail if user tries to destroy through execute tx", async function () { const execParam: wtypes.DestroyAssetParam = { type: wtypes.TransactionType.DestroyAsset, sign: wtypes.SignType.SecretKey, @@ -500,7 +500,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should fail if user tries to transfer asa through execute tx", async () => { + it("should fail if user tries to transfer asa through execute tx", async function () { const execParam: wtypes.AssetTransferParam = { type: wtypes.TransactionType.TransferAsset, sign: wtypes.SignType.SecretKey, @@ -516,7 +516,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should pass if user tries to opt-out through execute tx", async () => { + it("should pass if user tries to opt-out through execute tx", async function () { const execParam: wtypes.AssetTransferParam = { type: wtypes.TransactionType.TransferAsset, sign: wtypes.SignType.SecretKey, @@ -529,7 +529,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () await deployer.executeTx([execParam]); }); - it("should throw error if user tries to delete deleted app", async () => { + it("should throw error if user tries to delete deleted app", async function () { const execParam: wtypes.AppCallsParam = { type: wtypes.TransactionType.DeleteApp, sign: wtypes.SignType.SecretKey, @@ -543,7 +543,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should throw error if user tries to update deleted app", async () => { + it("should throw error if user tries to update deleted app", async function () { const execParam: wtypes.UpdateAppParam = { type: wtypes.TransactionType.UpdateApp, sign: wtypes.SignType.SecretKey, @@ -563,7 +563,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should throw error if user tries to call deleted app", async () => { + it("should throw error if user tries to call deleted app", async function () { const execParam: wtypes.AppCallsParam = { type: wtypes.TransactionType.CallApp, sign: wtypes.SignType.SecretKey, @@ -577,7 +577,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should throw error if user tries to opt-in deleted app", async () => { + it("should throw error if user tries to opt-in deleted app", async function () { const execParam: wtypes.AppCallsParam = { type: wtypes.TransactionType.OptInToApp, sign: wtypes.SignType.SecretKey, @@ -591,7 +591,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () ); }); - it("should pass if user tries to opt-out deleted app", async () => { + it("should pass if user tries to opt-out deleted app", async function () { const execParam: wtypes.AppCallsParam = { type: wtypes.TransactionType.CloseApp, sign: wtypes.SignType.SecretKey, @@ -614,7 +614,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () await deployer.executeTx([execParams]); }); - it("should pass if user tries delete app that doesn't exist in checkpoint", async () => { + it("should pass if user tries delete app that doesn't exist in checkpoint", async function () { const execParam: wtypes.DestroyAssetParam = { type: wtypes.TransactionType.DestroyAsset, sign: wtypes.SignType.SecretKey, @@ -626,7 +626,7 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () await deployer.executeTx([execParam]); }); - it("should pass if user tries delete (asset + app) that doesn't exist in checkpoint", async () => { + it("should pass if user tries delete (asset + app) that doesn't exist in checkpoint", async function () { const txGroup: wtypes.ExecParams[] = [ { type: wtypes.TransactionType.DestroyAsset, @@ -648,12 +648,12 @@ describe("Delete ASA and SSC transaction flow(with functions and executeTx)", () }); }); -describe("Deploy, Delete transactions test in run mode", () => { +describe("Deploy, Delete transactions test in run mode", function () { useFixtureProject("stateful"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; let deployerCfg: DeployerConfig; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); deployerCfg = new DeployerConfig(env, algod); @@ -662,12 +662,12 @@ describe("Deploy, Delete transactions test in run mode", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("should deploy asa in run mode", async () => { + it("should deploy asa in run mode", async function () { const execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployASA, sign: wtypes.SignType.SecretKey, @@ -685,7 +685,7 @@ describe("Deploy, Delete transactions test in run mode", () => { ); }); - it("should deploy application in run mode", async () => { + it("should deploy application in run mode", async function () { const execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, sign: wtypes.SignType.SecretKey, @@ -708,7 +708,7 @@ describe("Deploy, Delete transactions test in run mode", () => { expectBuilderError(() => deployer.getApp("app"), ERRORS.GENERAL.APP_NOT_FOUND_IN_CP); }); - it("should deploy application in deploy mode and save info by name", async () => { + it("should deploy application in deploy mode and save info by name", async function () { deployer = new DeployerDeployMode(deployerCfg); const execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, @@ -732,7 +732,7 @@ describe("Deploy, Delete transactions test in run mode", () => { assert.isDefined(deployer.getApp("dao-app")); }); - it("should delete application in run mode", async () => { + it("should delete application in run mode", async function () { deployer = new DeployerDeployMode(deployerCfg); let execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, @@ -769,12 +769,12 @@ describe("Deploy, Delete transactions test in run mode", () => { }); }); -describe("Update transaction test in run mode", () => { +describe("Update transaction test in run mode", function () { useFixtureProject("stateful"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; let deployerCfg: DeployerConfig; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); deployerCfg = new DeployerConfig(env, algod); @@ -782,12 +782,12 @@ describe("Update transaction test in run mode", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("should update in run mode", async () => { + it("should update in run mode", async function () { let execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, sign: wtypes.SignType.SecretKey, @@ -828,7 +828,7 @@ describe("Update transaction test in run mode", () => { expectBuilderError(() => deployer.getApp("app"), ERRORS.GENERAL.APP_NOT_FOUND_IN_CP); }); - it("deploy in deploy mode, update in run mode", async () => { + it("deploy in deploy mode, update in run mode", async function () { deployer = new DeployerDeployMode(deployerCfg); let execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, @@ -871,7 +871,7 @@ describe("Update transaction test in run mode", () => { } }); - it("deploy in run mode, update in deploy mode", async () => { + it("deploy in run mode, update in deploy mode", async function () { let execParams: wtypes.ExecParams = { type: wtypes.TransactionType.DeployApp, sign: wtypes.SignType.SecretKey, @@ -912,12 +912,12 @@ describe("Update transaction test in run mode", () => { }); }); -describe("Deploy ASA without asa.yaml", () => { +describe("Deploy ASA without asa.yaml", function () { useFixtureProject("config-project"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -926,12 +926,12 @@ describe("Deploy ASA without asa.yaml", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - afterEach(async () => { + afterEach(async function () { (algod.algodClient.getTransactionParams as SinonStub).restore(); (algod.algodClient.genesis as SinonStub).restore(); }); - it("should deploy asa without asa.yaml", async () => { + it("should deploy asa without asa.yaml", async function () { const exp = { total: 10000, decimals: 0, @@ -958,12 +958,12 @@ describe("Deploy ASA without asa.yaml", () => { }); }); -describe("SDK Transaction object", () => { +describe("SDK Transaction object", function () { useFixtureProject("config-project"); let deployer: Deployer; let algod: AlgoOperatorDryRunImpl; - beforeEach(async () => { + beforeEach(async function () { const env = mkEnv("network1"); algod = new AlgoOperatorDryRunImpl(); const deployerCfg = new DeployerConfig(env, algod); @@ -971,7 +971,7 @@ describe("SDK Transaction object", () => { stubAlgodGenesisAndTxParams(algod.algodClient); }); - it("should sign and send transaction", async () => { + it("should sign and send transaction", async function () { const tx = makeAssetCreateTxn( bobAcc.addr, mockSuggestedParam.fee, diff --git a/packages/runtime/test/integration/asa-load-fail.ts b/packages/runtime/test/integration/asa-load-fail.ts index e8165d850..5feb50204 100644 --- a/packages/runtime/test/integration/asa-load-fail.ts +++ b/packages/runtime/test/integration/asa-load-fail.ts @@ -11,7 +11,7 @@ describe("Deploy ASA with mutiple opt-in accounts", function () { let bob: AccountStore; let alice: AccountStore; - it("Should not load runtime, because while loading asa.yaml, account doesn't exist", () => { + it("Should not load runtime, because while loading asa.yaml, account doesn't exist", function () { john = new AccountStore(minBalance, "john"); bob = new AccountStore(minBalance, "bob"); alice = new AccountStore(minBalance, "alice"); @@ -21,7 +21,7 @@ describe("Deploy ASA with mutiple opt-in accounts", function () { ); }); - it("Should load runtime if all accounts exist", () => { + it("Should load runtime if all accounts exist", function () { const elon = new AccountStore(minBalance, "elon"); bob = new AccountStore(minBalance, "bob"); alice = new AccountStore(minBalance, "alice"); diff --git a/packages/runtime/test/integration/atomic-transfer.ts b/packages/runtime/test/integration/atomic-transfer.ts index 9c5d7d5d2..be0a0b859 100644 --- a/packages/runtime/test/integration/atomic-transfer.ts +++ b/packages/runtime/test/integration/atomic-transfer.ts @@ -18,7 +18,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { let assetId: number; let appID: number; - this.beforeEach(() => { + this.beforeEach(function () { john = new AccountStore(initialBalance, elonMuskAccount); alice = new AccountStore(initialBalance); runtime = new Runtime([john, alice]); // setup test @@ -58,7 +58,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { const key = "counter"; - it("should execute group of (payment + asset transaction) successfully", () => { + it("should execute group of (payment + asset transaction) successfully", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -94,7 +94,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { } }); - it("should not execute payment transaction (in group) if asset transaction fails", () => { + it("should not execute payment transaction (in group) if asset transaction fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -132,7 +132,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(alice.balance(), initialBalance); }); - it("should execute payment and ssc call", () => { + it("should execute payment and ssc call", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.CallApp, @@ -165,7 +165,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(alice.balance(), initialBalance + 100n); }); - it("should fail if payment transaction in group fails", () => { + it("should fail if payment transaction in group fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.CallApp, @@ -199,7 +199,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(alice.balance(), initialBalance); }); - it("should not freeze asset if payment fails", () => { + it("should not freeze asset if payment fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.FreezeAsset, @@ -229,7 +229,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(alice.getAssetHolding(assetId)?.["is-frozen"], false); }); - it("should not modify asset if payment fails", () => { + it("should not modify asset if payment fails", function () { const modFields = { manager: john.address, reserve: john.address, @@ -265,7 +265,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(runtime.getAssetDef(assetId).manager, assetManagerOrig); }); - it("should not revoke asset if payment fails", () => { + it("should not revoke asset if payment fails", function () { // transfer asset to alice runtime.executeTx([ { @@ -310,7 +310,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(alice.getAssetHolding(assetId)?.amount, initialAliceAssets); }); - it("should not destroy asset if payment fails", () => { + it("should not destroy asset if payment fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.DestroyAsset, @@ -338,7 +338,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.equal(runtime.getAssetDef(assetId).creator, john.address); }); - it("should fail close app if payment transaction fails", () => { + it("should fail close app if payment transaction fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.CloseApp, @@ -366,7 +366,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.isDefined(john.getLocalState(appID, key)); }); - it("should fail clear app if payment transaction fails", () => { + it("should fail clear app if payment transaction fails", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.ClearApp, @@ -394,7 +394,7 @@ describe("Algorand Smart Contracts - Atomic Transfers", function () { assert.isDefined(john.getLocalState(appID, key)); }); - it("should fail asset payment, and algo payment if ssc call fails", () => { + it("should fail asset payment, and algo payment if ssc call fails", function () { // close out from app runtime.executeTx([ { diff --git a/packages/runtime/test/integration/c2c-call/c2c-call.ts b/packages/runtime/test/integration/c2c-call/c2c-call.ts index eb4f66202..65e524308 100644 --- a/packages/runtime/test/integration/c2c-call/c2c-call.ts +++ b/packages/runtime/test/integration/c2c-call/c2c-call.ts @@ -33,7 +33,7 @@ describe("C2C call", function () { runtime.executeTx([fundTx]); } - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [alice] = runtime.defaultAccounts(); appDefinition = { @@ -62,7 +62,7 @@ describe("C2C call", function () { appCallArgs = ["str:call_method", "int:1"]; }); - it("should succeed: call another application", () => { + it("should succeed: call another application", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -79,7 +79,7 @@ describe("C2C call", function () { assert.deepEqual(new TextDecoder().decode(logs[0]).substring(6), "Call from applicatiton"); }); - it("should fail: call another application when not enough fee", () => { + it("should fail: call another application when not enough fee", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -99,7 +99,7 @@ describe("C2C call", function () { }); describe("Inner transaction in group", function () { - it("should succeed: enough fee for 4 transaction call(4000 micro algo)", () => { + it("should succeed: enough fee for 4 transaction call(4000 micro algo)", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -123,7 +123,7 @@ describe("C2C call", function () { ]); }); - it("should fail because not enough fee (4 transaction call but only 3000 micro algo)", () => { + it("should fail because not enough fee (4 transaction call but only 3000 micro algo)", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -154,7 +154,7 @@ describe("C2C call", function () { describe("c2c call unhappy case", function () { let thirdApp: AppInfo; - this.beforeEach(() => { + this.beforeEach(function () { thirdApp = runtime.deployApp( alice.account, { @@ -168,7 +168,7 @@ describe("C2C call", function () { fundToApp(alice, thirdApp); }); - it("should fail: inner call to app implemented in older teal", () => { + it("should fail: inner call to app implemented in older teal", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -188,7 +188,7 @@ describe("C2C call", function () { ); }); - it("should fail: inner tx app self-call", () => { + it("should fail: inner tx app self-call", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -212,7 +212,7 @@ describe("C2C call", function () { let apps: AppInfo[]; let baseApp: AppInfo; let bob: AccountStoreI; - this.beforeEach(() => { + this.beforeEach(function () { apps = []; bob = runtime.defaultAccounts()[1]; baseApp = runtime.deployApp( @@ -240,7 +240,7 @@ describe("C2C call", function () { } }); - it("Should succeed: inner call with maximum depth = 8", () => { + it("Should succeed: inner call with maximum depth = 8", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -256,7 +256,7 @@ describe("C2C call", function () { assert.doesNotThrow(() => runtime.executeTx([execParams])); }); - it("Should fail: inner call with depth > 8", () => { + it("Should fail: inner call with depth > 8", function () { const execParams: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -281,7 +281,7 @@ describe("C2C call", function () { describe("Only support application call for now", function () { let execParams: types.ExecParams; - this.beforeEach(() => { + this.beforeEach(function () { const appInfo = runtime.deployApp( alice.account, { @@ -303,7 +303,7 @@ describe("C2C call", function () { }; }); - it("Should not support other inner tx appl(not include appcall)", () => { + it("Should not support other inner tx appl(not include appcall)", function () { assert.doesNotThrow(() => runtime.executeTx([execParams])); assert.isTrue( (console["log"] as any).calledWith( diff --git a/packages/runtime/test/integration/close-clear-ssc.ts b/packages/runtime/test/integration/close-clear-ssc.ts index 6b928b300..3ece0c6f6 100644 --- a/packages/runtime/test/integration/close-clear-ssc.ts +++ b/packages/runtime/test/integration/close-clear-ssc.ts @@ -48,7 +48,7 @@ describe("ASC - CloseOut from Application and Clear State", function () { }; }); - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([john, alice]); // setup test }); const syncAccount = (): void => { @@ -72,7 +72,7 @@ describe("ASC - CloseOut from Application and Clear State", function () { assert.equal( john.minBalance, initialJohnMinBalance + - (APPLICATION_BASE_FEE + (SSC_VALUE_UINT * 3 + SSC_VALUE_BYTES * 3)) // optInToApp increase + (APPLICATION_BASE_FEE + (SSC_VALUE_UINT * 3 + SSC_VALUE_BYTES * 3)) // optInToApp increase ); // verify minimum balance raised after optIn runtime.executeTx([{ ...closeOutParams, appID: appID }]); @@ -118,7 +118,7 @@ describe("ASC - CloseOut from Application and Clear State", function () { assert.equal( minBalanceAfterOptIn, initialJohnMinBalance + - (APPLICATION_BASE_FEE + (SSC_VALUE_UINT * 3 + SSC_VALUE_BYTES * 3)) // optInToApp increase + (APPLICATION_BASE_FEE + (SSC_VALUE_UINT * 3 + SSC_VALUE_BYTES * 3)) // optInToApp increase ); // verify minimum balance raised after optIn const invalidParams: types.AppCallsParam = { diff --git a/packages/runtime/test/integration/deleteApp.ts b/packages/runtime/test/integration/deleteApp.ts index e88c0d178..7ba1b4e61 100644 --- a/packages/runtime/test/integration/deleteApp.ts +++ b/packages/runtime/test/integration/deleteApp.ts @@ -44,7 +44,7 @@ describe("Algorand Smart Contracts - Delete Application", function () { }; }); - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([john, alice]); // setup test }); diff --git a/packages/runtime/test/integration/deploy-app.ts b/packages/runtime/test/integration/deploy-app.ts index ea8e98fc1..78078821c 100644 --- a/packages/runtime/test/integration/deploy-app.ts +++ b/packages/runtime/test/integration/deploy-app.ts @@ -98,7 +98,7 @@ describe("Algorand Smart Contracts - Stateful Contract Account", function () { assert.isDefined(res?.applicationAccount); }); - it("Should failed if deploy duplicate app name", () => { + it("Should failed if deploy duplicate app name", function () { expectRuntimeError( () => runtime.deployApp( diff --git a/packages/runtime/test/integration/deploy-asa.ts b/packages/runtime/test/integration/deploy-asa.ts index e6543b9b5..46c6b3f55 100644 --- a/packages/runtime/test/integration/deploy-asa.ts +++ b/packages/runtime/test/integration/deploy-asa.ts @@ -28,7 +28,7 @@ describe("Deploy ASA with mutiple opt-in accounts", function () { alice = runtime.getAccount(alice.address); } - it("Should opt-in to multiple accounts mentioned in asa.yaml", () => { + it("Should opt-in to multiple accounts mentioned in asa.yaml", function () { const asset = runtime.deployASA("asa", { creator: { ...john.account, name: "john" }, }).assetIndex; @@ -38,7 +38,7 @@ describe("Deploy ASA with mutiple opt-in accounts", function () { assert.isDefined(alice.getAssetHolding(asset)); }); - it("Should throw an error when ASA definition not found in asa.yaml", () => { + it("Should throw an error when ASA definition not found in asa.yaml", function () { expectRuntimeError( () => runtime.deployASA("asa-invalid", { @@ -50,7 +50,7 @@ describe("Deploy ASA with mutiple opt-in accounts", function () { describe("ASA file is undefinded", function () { useFixture("loop"); // project does not have an asa-file - it("Should throw an error when we tried to get asa from asa file for deploy", () => { + it("Should throw an error when we tried to get asa from asa file for deploy", function () { expectRuntimeError( () => runtime.deployASA("asa", { diff --git a/packages/runtime/test/integration/execute-transaction.ts b/packages/runtime/test/integration/execute-transaction.ts index 692718234..f177ed57a 100644 --- a/packages/runtime/test/integration/execute-transaction.ts +++ b/packages/runtime/test/integration/execute-transaction.ts @@ -26,7 +26,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { let clearProgramFilename: string; let assetId: number; - this.beforeEach(() => { + this.beforeEach(function () { john = new AccountStore(initialBalance, elonMuskAccount); alice = new AccountStore(initialBalance); elonMusk = new AccountStore(initialBalance); @@ -86,7 +86,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(alice.balance(), initialBalance + 100n); }); - it("should execute group of (payment + asset creation) successfully", () => { + it("should execute group of (payment + asset creation) successfully", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -111,7 +111,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(alice.balance(), initialBalance + 100n); }); - it("should fail execution group (payment + asset creation), if asset def is not found", () => { + it("should fail execution group (payment + asset creation), if asset def is not found", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -131,7 +131,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { ]; const initialJohnAssets = john.getAssetHolding(assetId)?.amount; assert.isUndefined(initialJohnAssets); - assert.throws(() => { + assert.throws(function () { runtime.executeTx(txGroup); }, "ABLDR17"); @@ -141,7 +141,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(alice.balance(), initialBalance); }); - it("Should opt-in to asset, through execute transaction", () => { + it("Should opt-in to asset, through execute transaction", function () { setupAsset(); const tx: types.ExecParams[] = [ { @@ -159,7 +159,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.isDefined(alice.getAssetHolding(assetId)); }); - it("should execute group of (payment + app creation) successfully", () => { + it("should execute group of (payment + app creation) successfully", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -193,7 +193,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(alice.balance(), initialBalance + 100n); }); - it("should fail execution group (payment + asset creation), if not enough balance", () => { + it("should fail execution group (payment + asset creation), if not enough balance", function () { const txGroup: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, @@ -231,7 +231,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.isUndefined(res); }); - it("Should opt-in to app, through execute transaction", () => { + it("Should opt-in to app, through execute transaction", function () { setupApp(); syncAccounts(); const appInfo = runtime.getAppInfoFromName(approvalProgramFilename, clearProgramFilename); @@ -255,7 +255,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { } }); - it("Should opt-in ASA and transfer asset, through execute transaction", () => { + it("Should opt-in ASA and transfer asset, through execute transaction", function () { setupAsset(); const tx: types.ExecParams[] = [ @@ -285,7 +285,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.isDefined(alice.getAssetHolding(assetId)); }); - it("Should do key registration, through execute transaction", () => { + it("Should do key registration, through execute transaction", function () { const txSKParams: types.KeyRegistrationParam = { type: types.TransactionType.KeyRegistration, // payment sign: types.SignType.SecretKey, @@ -303,7 +303,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.isDefined(r.txID); }); - it("Should modify asset, through execute transaction", () => { + it("Should modify asset, through execute transaction", function () { setupAsset(); const modFields: types.AssetModFields = { manager: elonMusk.address, @@ -328,7 +328,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(res.freeze, alice.address); }); - it("should freeze asset, through execute transaction", () => { + it("should freeze asset, through execute transaction", function () { setupAsset(); runtime.optInToASA(assetId, alice.address, {}); syncAccounts(); @@ -348,7 +348,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(aliceAssetHolding["is-frozen"], true); }); - it("should revoke asset, through execute transaction", () => { + it("should revoke asset, through execute transaction", function () { setupAsset(); runtime.optInToASA(assetId, alice.address, {}); syncAccounts(); @@ -369,7 +369,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(john.balance(), initialBalance - 1000n); }); - it("Should destroy asset, through execute transaction", () => { + it("Should destroy asset, through execute transaction", function () { setupAsset(); const destroyParam: types.DestroyAssetParam = { type: types.TransactionType.DestroyAsset, @@ -385,7 +385,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { assert.equal(john.balance(), initialBalance - 1000n); }); - it("Should clear app, through execute transaction", () => { + it("Should clear app, through execute transaction", function () { setupApp(); syncAccounts(); const appInfo = runtime.getAppInfoFromName(approvalProgramFilename, clearProgramFilename); @@ -408,7 +408,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { } }); - it("Should close app, through execute transaction", () => { + it("Should close app, through execute transaction", function () { setupApp(); syncAccounts(); const appInfo = runtime.getAppInfoFromName(approvalProgramFilename, clearProgramFilename); @@ -431,7 +431,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { } }); - it("Should delete app, through execute transaction", () => { + it("Should delete app, through execute transaction", function () { setupApp(); syncAccounts(); const appInfo = runtime.getAppInfoFromName(approvalProgramFilename, clearProgramFilename); @@ -454,7 +454,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { } }); - it("Should update app, through execute transaction", () => { + it("Should update app, through execute transaction", function () { setupApp(); syncAccounts(); const appInfo = runtime.getAppInfoFromName(approvalProgramFilename, clearProgramFilename); @@ -480,7 +480,7 @@ describe("Algorand Smart Contracts - Execute transaction", function () { } }); - it("Should be able to pass signed transaction in executeTx", () => { + it("Should be able to pass signed transaction in executeTx", function () { const suggestedParams = mockSuggestedParams({ totalFee: fee }, runtime.getRound()); const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: john.address, diff --git a/packages/runtime/test/integration/global-opcodebudget.ts b/packages/runtime/test/integration/global-opcodebudget.ts index 7d55445ca..a99b6be76 100644 --- a/packages/runtime/test/integration/global-opcodebudget.ts +++ b/packages/runtime/test/integration/global-opcodebudget.ts @@ -74,8 +74,8 @@ describe("TEALv6: Global Opcode Budget", function () { assert.doesNotThrow(() => runtime.executeTx([txnParam])); }); - describe("Test on application", () => { - it("call application with single tx", () => { + describe("Test on application", function () { + it("call application with single tx", function () { txnParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -92,7 +92,7 @@ describe("TEALv6: Global Opcode Budget", function () { assert.deepEqual(algosdk.bytesToBigInt(logs[0]), 692n); }); - it("call application with group tx", () => { + it("call application with group tx", function () { txnParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, @@ -116,7 +116,7 @@ describe("TEALv6: Global Opcode Budget", function () { assert.deepEqual(algosdk.bytesToBigInt(logs[0]), 1392n); }); - it("call application with inside inner tx", () => { + it("call application with inside inner tx", function () { txnParam = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, diff --git a/packages/runtime/test/integration/group-index.ts b/packages/runtime/test/integration/group-index.ts index 2633ea29e..db2b16ae6 100644 --- a/packages/runtime/test/integration/group-index.ts +++ b/packages/runtime/test/integration/group-index.ts @@ -61,7 +61,7 @@ describe("Current Transaction Tests", function () { ).appID; } - it("Group Index Check", () => { + it("Group Index Check", function () { setupApps(); const txGroup: types.ExecParams[] = [ @@ -84,7 +84,7 @@ describe("Current Transaction Tests", function () { runtime.executeTx(txGroup); }); - it("Failure test for group index", () => { + it("Failure test for group index", function () { setupApps(); const txGroup: types.ExecParams[] = [ diff --git a/packages/runtime/test/integration/group-inner-transaction.ts b/packages/runtime/test/integration/group-inner-transaction.ts index b0b55a1b9..65b1ba330 100644 --- a/packages/runtime/test/integration/group-inner-transaction.ts +++ b/packages/runtime/test/integration/group-inner-transaction.ts @@ -58,14 +58,14 @@ describe("Group inner transaction", function () { return appInfo; } - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [alice] = runtime.defaultAccounts(); firstAppInfo = deployAppAndFund("group.py", "clear.teal"); }); - it("Can use itxn_next for create group inner tx transaction", () => { + it("Can use itxn_next for create group inner tx transaction", function () { const contractBalance = contractAcc.balance(); const aliceBalance = alice.balance(); @@ -90,11 +90,11 @@ describe("Group inner transaction", function () { }); describe("inner transaction limit tealv6", function () { - this.beforeEach(() => { + this.beforeEach(function () { secondAppInfo = deployAppAndFund("limit-number-txn.py", "clear.teal"); }); - it("Should fail when issue more than 256 inner txn", () => { + it("Should fail when issue more than 256 inner txn", function () { const firstTxn: types.ExecParams = { type: types.TransactionType.CallApp, sign: types.SignType.SecretKey, diff --git a/packages/runtime/test/integration/inner-transaction/asset-tx.ts b/packages/runtime/test/integration/inner-transaction/asset-tx.ts index fa73df8ec..560894fd9 100644 --- a/packages/runtime/test/integration/inner-transaction/asset-tx.ts +++ b/packages/runtime/test/integration/inner-transaction/asset-tx.ts @@ -43,7 +43,7 @@ describe("Algorand Smart Contracts(TEALv5) - Inner Transactions[Asset Transfer, }; }); - this.beforeEach(() => { + this.beforeEach(function () { // reset app (delete + create) john.createdApps.delete(appID); appDefinition.appName = "app" + Date.now(); diff --git a/packages/runtime/test/integration/inner-transaction/payment.ts b/packages/runtime/test/integration/inner-transaction/payment.ts index 8137f81d0..85921c78a 100644 --- a/packages/runtime/test/integration/inner-transaction/payment.ts +++ b/packages/runtime/test/integration/inner-transaction/payment.ts @@ -41,7 +41,7 @@ describe("Algorand Smart Contracts(TEALv5) - Inner Transactions[ALGO Payment]", }; }); - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([master, john, elon, bob]); // setup test appID = runtime.deployApp(john.account, appDefinition, {}).appID; appAccount = runtime.getAccount(getApplicationAddress(appID)); // update app account diff --git a/packages/runtime/test/integration/loop.ts b/packages/runtime/test/integration/loop.ts index 4f3fc5967..27c182acf 100644 --- a/packages/runtime/test/integration/loop.ts +++ b/packages/runtime/test/integration/loop.ts @@ -72,7 +72,7 @@ describe("TEALv4: Loops", function () { ); }); - it("should skip b1 & b2 (continuous labels)", () => { + it("should skip b1 & b2 (continuous labels)", function () { approvalProgramPassFileName = "continuous-labels.teal"; // this code will pass, because at the end we check if counter is incremented 10 times assert.doesNotThrow(() => diff --git a/packages/runtime/test/integration/pooled-op-cost.ts b/packages/runtime/test/integration/pooled-op-cost.ts index 4369eea89..5f3b52ae8 100644 --- a/packages/runtime/test/integration/pooled-op-cost.ts +++ b/packages/runtime/test/integration/pooled-op-cost.ts @@ -145,11 +145,11 @@ describe("TEALv5: Pooled Opcode Cost calculation", function () { }; }); - it("Should succeed because enough budget when group 2 appl call transaction(1400)", () => { + it("Should succeed because enough budget when group 2 appl call transaction(1400)", function () { assert.doesNotThrow(() => runtime.executeTx([increaseBudgetTx, callAppTx])); }); - it("Should failed because budget only from call appl(700)", () => { + it("Should failed because budget only from call appl(700)", function () { expectRuntimeError( () => runtime.executeTx([callAppTx, transferTx]), RUNTIME_ERRORS.TEAL.MAX_COST_EXCEEDED diff --git a/packages/runtime/test/integration/rekey/rekey-and-inner-tx.ts b/packages/runtime/test/integration/rekey/rekey-and-inner-tx.ts index 4defa4b47..28354135d 100644 --- a/packages/runtime/test/integration/rekey/rekey-and-inner-tx.ts +++ b/packages/runtime/test/integration/rekey/rekey-and-inner-tx.ts @@ -51,7 +51,7 @@ describe("Rekey transaction and inner transaction ", function () { }); describe("Apply Inner transaction when rekey application to account", function () { - this.beforeEach(() => { + this.beforeEach(function () { // deploy application const approvalProgramFilename = "approval-rekey.teal"; const clearProgramFilename = "clear-rekey.teal"; @@ -104,7 +104,7 @@ describe("Rekey transaction and inner transaction ", function () { assert.equal(appAccount.getSpendAddress(), alice.address); }); - it("account should have permission transfer asset of application(ALGO transfer)", () => { + it("account should have permission transfer asset of application(ALGO transfer)", function () { const applBalanceBefore = appAccount.amount; const aliceBalanceBefore = alice.amount; const bobBalanceBefore = bob.amount; @@ -135,7 +135,7 @@ describe("Rekey transaction and inner transaction ", function () { assert.equal(bobBalanceBefore + amount, bobBalanceAfter); }); - it("should throw an error if auth/spend account invalid", () => { + it("should throw an error if auth/spend account invalid", function () { const tranferAlgoTx: types.AlgoTransferParam = { type: types.TransactionType.TransferAlgo, sign: types.SignType.SecretKey, @@ -159,7 +159,7 @@ describe("Rekey transaction and inner transaction ", function () { describe("apply rekey account to application with rekey transaction", function () { let txnParams: types.ExecParams; - this.beforeEach(() => { + this.beforeEach(function () { // deploy app const approvalProgramFilename = "rekey-approval-payment.py"; const clearProgramFilename = "clear.teal"; @@ -193,11 +193,11 @@ describe("Rekey transaction and inner transaction ", function () { syncAccounts(); }); - it("check account after rekey", () => { + it("check account after rekey", function () { assert.equal(alice.getSpendAddress(), getApplicationAddress(appID)); }); - it("Should transfer algo by inner transaction", () => { + it("Should transfer algo by inner transaction", function () { const masterBalanceBefore = master.amount; const aliceBalanceBefore = alice.amount; const bobBalanceBefore = bob.amount; @@ -229,7 +229,7 @@ describe("Rekey transaction and inner transaction ", function () { assert.equal(bobBalanceBefore + amount, bobBalanceAfter); }); - it("Should failed: contract can't transfer asset if account not rekey to contract", () => { + it("Should failed: contract can't transfer asset if account not rekey to contract", function () { // transfer ALGO from bob to alice by contract, but bob didn't rekey to contract. txnParams = { type: types.TransactionType.CallApp, diff --git a/packages/runtime/test/integration/shared-space.ts b/packages/runtime/test/integration/shared-space.ts index 7042c293d..ec501eecc 100644 --- a/packages/runtime/test/integration/shared-space.ts +++ b/packages/runtime/test/integration/shared-space.ts @@ -84,7 +84,7 @@ describe("TEALv4: shared space between contracts", function () { expectRuntimeError(() => runtime.executeTx(groupTx), RUNTIME_ERRORS.TEAL.REJECTED_BY_LOGIC); }); - it("should fail if scratch doesn't have values for first application tx", () => { + it("should fail if scratch doesn't have values for first application tx", function () { groupTx[0].appDefinition = { ...firstAppDefinition, approvalProgramCode: approvalProgramFail1, @@ -99,7 +99,7 @@ describe("TEALv4: shared space between contracts", function () { expectRuntimeError(() => runtime.executeTx(groupTx), RUNTIME_ERRORS.TEAL.REJECTED_BY_LOGIC); }); - it("should fail if given transaction is not application tx", () => { + it("should fail if given transaction is not application tx", function () { const tx: types.ExecParams[] = [ { type: types.TransactionType.TransferAlgo, diff --git a/packages/runtime/test/integration/sub-routine.ts b/packages/runtime/test/integration/sub-routine.ts index f9111d3ef..6bb4c87dd 100644 --- a/packages/runtime/test/integration/sub-routine.ts +++ b/packages/runtime/test/integration/sub-routine.ts @@ -59,7 +59,7 @@ describe("TEALv4: Sub routine", function () { ); }); - it("should calculate correct fibonacci number", () => { + it("should calculate correct fibonacci number", function () { appDefinition.approvalProgramFilename = "fibonacci.teal"; appDefinition.appName = "Fibo5"; let appID = runtime.deployApp( @@ -99,7 +99,7 @@ describe("TEALv4: Sub routine", function () { assert.equal(result, 1n); }); - it("should throw cost exceed error", () => { + it("should throw cost exceed error", function () { appDefinition.appArgs = ["int:9"]; appDefinition.approvalProgramFilename = "fibonacci.teal"; expectRuntimeError( diff --git a/packages/runtime/test/src/interpreter/inner-transaction.ts b/packages/runtime/test/src/interpreter/inner-transaction.ts index a091d3c18..b659cad13 100644 --- a/packages/runtime/test/src/interpreter/inner-transaction.ts +++ b/packages/runtime/test/src/interpreter/inner-transaction.ts @@ -414,7 +414,7 @@ describe("Inner Transactions", function () { "ConfigAssetClawback", ]; - it("should pass: teal understand 32 bytes value is address with acfg address", () => { + it("should pass: teal understand 32 bytes value is address with acfg address", function () { ConfigAddresses.forEach((configAddr) => { tealCode = ` itxn_begin @@ -427,7 +427,7 @@ describe("Inner Transactions", function () { }); }); - it("should pass: use random address with asa config transaction with acfg address", () => { + it("should pass: use random address with asa config transaction with acfg address", function () { ConfigAddresses.forEach((configAddress) => { tealCode = ` itxn_begin @@ -530,7 +530,7 @@ describe("Inner Transactions", function () { describe("TestAppPay", function () { let pay: string; - this.beforeAll(() => { + this.beforeAll(function () { pay = ` itxn_begin itxn_field Amount @@ -663,7 +663,7 @@ describe("Inner Transactions", function () { describe("TestAppAssetOptIn", function () { let axfer: string; - this.beforeAll(() => { + this.beforeAll(function () { axfer = ` itxn_begin int axfer @@ -808,7 +808,7 @@ describe("Inner Transactions", function () { let axfer: string; let assetID1: number; let assetID2: number; - this.beforeAll(() => { + this.beforeAll(function () { const elonAcc = interpreter.runtime.ctx.state.accounts.get(elonAddr); if (elonAcc) { // in foreign-assets @@ -1006,7 +1006,7 @@ describe("Inner Transactions", function () { }); }); - describe("TestBadField", () => { + describe("TestBadField", function () { it(`should fail if fields are invalid`, function () { const pay = ` global CurrentApplicationAddress @@ -1030,7 +1030,7 @@ describe("Inner Transactions", function () { }); }); - describe("TestNumInner", () => { + describe("TestNumInner", function () { it(`should fail number of inner transactions > 16`, function () { const pay = ` itxn_begin @@ -1060,7 +1060,7 @@ describe("Inner Transactions", function () { }); }); - describe("TestAssetCreate", () => { + describe("TestAssetCreate", function () { it(`should test asset creation inner transaction`, function () { const create = ` itxn_begin @@ -1086,7 +1086,7 @@ describe("Inner Transactions", function () { }); }); - describe("TestAssetFreeze", () => { + describe("TestAssetFreeze", function () { it(`should test asset freeze inner transaction (flow test)`, function () { const lastAssetID = interpreter.runtime.ctx.state.assetCounter; @@ -1156,7 +1156,7 @@ describe("Inner Transactions", function () { }); }); - describe("Log", () => { + describe("Log", function () { it(`should log bytes to current transaction receipt`, function () { const txnInfo = interpreter.runtime.getTxReceipt(TXN_OBJ.txID); assert.isUndefined(txnInfo?.logs); // no logs before @@ -1244,13 +1244,13 @@ describe("Inner Transactions", function () { }); describe("Teal v6 update", function () { - this.beforeEach(() => { + this.beforeEach(function () { setUpInterpreter(6, ALGORAND_ACCOUNT_MIN_BALANCE); }); describe("keyreg transaction", function () { let program: string; - this.beforeEach(() => { + this.beforeEach(function () { // init more balance for application to test inner transaction setUpInterpreter(6, ALGORAND_ACCOUNT_MIN_BALANCE * 10); }); @@ -1281,7 +1281,7 @@ describe("Inner Transactions", function () { assert.doesNotThrow(() => executeTEAL(program)); }); - it("should fail on invalid field keyreg transaction", () => { + it("should fail on invalid field keyreg transaction", function () { ["VotePK", "SelectionPK"].forEach((field) => { program = ` itxn_begin @@ -1295,9 +1295,9 @@ describe("Inner Transactions", function () { }); }); - describe("RekeyTo", () => { + describe("RekeyTo", function () { let rekeyProgram: string; - this.beforeEach(() => { + this.beforeEach(function () { setUpInterpreter(6); rekeyProgram = ` itxn_begin @@ -1313,8 +1313,8 @@ describe("Inner Transactions", function () { }); }); - describe("Note", () => { - this.beforeEach(() => { + describe("Note", function () { + this.beforeEach(function () { setUpInterpreter(6); }); @@ -1365,12 +1365,12 @@ describe("Inner Transactions", function () { }); }); - describe("itxn_next", () => { - this.beforeEach(() => { + describe("itxn_next", function () { + this.beforeEach(function () { setUpInterpreter(6, 1e9); }); - it("Should succeed: create inner group transactions", () => { + it("Should succeed: create inner group transactions", function () { const prog = ` itxn_begin int pay @@ -1397,7 +1397,7 @@ describe("Inner Transactions", function () { assert.equal(interpreter.currentInnerTxnGroup.length, 2); }); - it("Should fail: use itxn_next without start with itxn_begin", () => { + it("Should fail: use itxn_next without start with itxn_begin", function () { const prog = ` itxn_next int 1 @@ -1413,12 +1413,12 @@ describe("Inner Transactions", function () { }); describe("Teal v7", function () { - describe("Inner transaction", () => { + describe("Inner transaction", function () { useFixture("teal-files"); - this.beforeEach(() => { + this.beforeEach(function () { setUpInterpreter(1, ALGORAND_ACCOUNT_MIN_BALANCE); }); - it("Should execute a teal file successfully", () => { + it("Should execute a teal file successfully", function () { const file = "test-innerTxn-v7.teal"; interpreter.execute(getProgram(file), ExecutionMode.APPLICATION, interpreter.runtime); assert.deepEqual(interpreter.innerTxnGroups.length, 0); @@ -1427,12 +1427,12 @@ describe("Inner Transactions", function () { }); }) - describe("Foreign application account access", () => { - this.beforeEach(() => { + describe("Foreign application account access", function () { + this.beforeEach(function () { setUpInterpreter(7, 1e9); }); - it("Should not throw error when accessing foreign application in create inner transaction", () => { + it("Should not throw error when accessing foreign application in create inner transaction", function () { const prog = ` itxn_begin int pay diff --git a/packages/runtime/test/src/interpreter/interpreter.ts b/packages/runtime/test/src/interpreter/interpreter.ts index ecc22cc1f..a9790d3bf 100644 --- a/packages/runtime/test/src/interpreter/interpreter.ts +++ b/packages/runtime/test/src/interpreter/interpreter.ts @@ -114,49 +114,49 @@ describe("Interpreter", function () { interpreter.execute(tealCode, ExecutionMode.APPLICATION, interpreter.runtime, 0); }; - this.beforeAll(() => { + this.beforeAll(function () { setUpInterpreter(6); //setup interpreter for execute }); - describe("Teal cost", () => { + describe("Teal cost", function () { useFixture("teal-files"); - beforeEach(() => { + beforeEach(function () { resetInterpreterState(); interpreter.cost = 0; interpreter.tealVersion = 1; }); - it("Should return correct cost for a simple .teal program ", () => { + it("Should return correct cost for a simple .teal program ", function () { const file = "test-file-1.teal"; interpreter.execute(getProgram(file), ExecutionMode.SIGNATURE, interpreter.runtime); assert.equal(interpreter.cost, 3); }); - it("Should return correct cost for a simple .teal program ", () => { + it("Should return correct cost for a simple .teal program ", function () { const file = "test-file-3.teal"; interpreter.execute(getProgram(file), ExecutionMode.SIGNATURE, interpreter.runtime); assert.equal(interpreter.cost, 3); }); - it("Should return correct cost for a .teal program(if-else)", () => { + it("Should return correct cost for a .teal program(if-else)", function () { const file = "test-if-else.teal"; interpreter.execute(getProgram(file), ExecutionMode.SIGNATURE, interpreter.runtime); assert.equal(interpreter.cost, 9); }); - it("Should return correct cost for a .teal program with different version(v1)", () => { + it("Should return correct cost for a .teal program with different version(v1)", function () { const file = "test-sha256-v1.teal"; interpreter.execute(getProgram(file), ExecutionMode.SIGNATURE, interpreter.runtime); assert.equal(interpreter.cost, 14); }); - it("Should return correct cost for a .teal program for different version(v2)", () => { + it("Should return correct cost for a .teal program for different version(v2)", function () { const file = "test-sha256-v2.teal"; interpreter.execute(getProgram(file), ExecutionMode.APPLICATION, interpreter.runtime); assert.equal(interpreter.cost, 42); }); - it("Should fail when executing wrong logic teal", () => { + it("Should fail when executing wrong logic teal", function () { // logic of teal file failed const file = "test-label.teal"; expectRuntimeError( @@ -167,12 +167,12 @@ describe("Interpreter", function () { }); }); - describe("Foreign application access", () => { - describe("foreign application account can not be access by opcode that modify local storage", () => { - this.beforeEach(() => { + describe("Foreign application access", function () { + describe("foreign application account can not be access by opcode that modify local storage", function () { + this.beforeEach(function () { setUpInterpreter(7, 1e9); }); - it("Should throw an error when accessing account that are not in transaction's account field", () => { + it("Should throw an error when accessing account that are not in transaction's account field", function () { const prog = ` txn Applications 2 app_params_get AppAddress @@ -188,11 +188,11 @@ describe("Interpreter", function () { }); }); - describe("Foreign application account can be accessed by opcode that modify local storage in specific case", () => { - this.beforeEach(() => { + describe("Foreign application account can be accessed by opcode that modify local storage in specific case", function () { + this.beforeEach(function () { setUpInterpreter(7, 1e9); }); - it("Should not throw an error when accessing account that are in transaction's account field", () => { + it("Should not throw an error when accessing account that are in transaction's account field", function () { const prog = ` txn Applications 2 app_params_get AppAddress diff --git a/packages/runtime/test/src/interpreter/opcode-list.ts b/packages/runtime/test/src/interpreter/opcode-list.ts index 333319143..1c64682b9 100644 --- a/packages/runtime/test/src/interpreter/opcode-list.ts +++ b/packages/runtime/test/src/interpreter/opcode-list.ts @@ -223,21 +223,21 @@ describe("Teal Opcodes", function () { }); }); - describe("Pragma", () => { + describe("Pragma", function () { const interpreter = new Interpreter(); const stack = new Stack(); - it("should store pragma version", () => { + it("should store pragma version", function () { const op = new Pragma(["version", "2"], 1, interpreter); assert.equal(op.version, 2); }); - it("should store throw length error", () => { + it("should store throw length error", function () { expectRuntimeError( () => new Pragma(["version", "2", "some-value"], 1, interpreter), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("Should return correct cost", () => { + it("Should return correct cost", function () { const op = new Pragma(["version", "3"], 1, interpreter); assert.equal(0, op.execute(stack)); }); @@ -382,7 +382,7 @@ describe("Teal Opcodes", function () { let interpreter: Interpreter; const args = ["Arg0", "Arg1", "Arg2", "Arg3"].map(parsing.stringToBytes); - this.beforeAll(() => { + this.beforeAll(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); interpreter.runtime.ctx.args = args; @@ -616,7 +616,7 @@ describe("Teal Opcodes", function () { describe("Store", function () { let stack: Stack; - beforeEach(() => { + beforeEach(function () { stack = new Stack(); }); @@ -814,7 +814,7 @@ describe("Teal Opcodes", function () { interpreter.scratch = scratch; let stack: Stack; - beforeEach(() => { + beforeEach(function () { stack = new Stack(); }); @@ -848,7 +848,7 @@ describe("Teal Opcodes", function () { assert.equal(DEFAULT_STACK_ELEM, stack.pop()); }); - it("should load uint64 from scratch space to stack using `loads`", () => { + it("should load uint64 from scratch space to stack using `loads`", function () { stack.push(0n); const op = new Loads([], 1, interpreter); @@ -892,7 +892,7 @@ describe("Teal Opcodes", function () { const stack = new Stack(); const interpreter = new Interpreter(); - it("should return correct hash for Sha256", () => { + it("should return correct hash for Sha256", function () { stack.push(parsing.stringToBytes("MESSAGE")); const op = new Sha256([], 1, interpreter); op.execute(stack); @@ -926,7 +926,7 @@ describe("Teal Opcodes", function () { ) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { stack.push(parsing.stringToBytes("MESSAGE")); interpreter.tealVersion = 1; let op = new Sha256([], 1, interpreter); @@ -976,7 +976,7 @@ describe("Teal Opcodes", function () { ) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { stack.push(parsing.stringToBytes("MESSAGE")); interpreter.tealVersion = 1; let op = new Sha512_256([], 1, interpreter); @@ -1027,7 +1027,7 @@ describe("Teal Opcodes", function () { ) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { stack.push(parsing.stringToBytes("MESSAGE")); interpreter.tealVersion = 1; let op = new Keccak256([], 1, interpreter); @@ -1057,12 +1057,12 @@ describe("Teal Opcodes", function () { txID: TXN_OBJ.txID, }); }; - this.beforeAll(() => { + this.beforeAll(function () { setUpInterpreter(6); //setup interpreter for execute }); - describe("Verification", () => { - this.beforeEach(() => { + describe("Verification", function () { + this.beforeEach(function () { interpreter.instructionIndex = 0; }); @@ -1079,14 +1079,14 @@ describe("Teal Opcodes", function () { const toBeSigned = Buffer.from(concatArrays(programHash, msgUint8Array)); const signature = nacl.sign.detached(toBeSigned, account.sk); - it("Should not throw an exception when executing a correct teal file", () => { + it("Should not throw an exception when executing a correct teal file", function () { interpreter.runtime.ctx.args = [msgUint8Array, signature]; assert.doesNotThrow(() => interpreter.execute(tealCode, ExecutionMode.SIGNATURE, interpreter.runtime) ); }); - it("Should throw an exeption when the message is different", () => { + it("Should throw an exeption when the message is different", function () { // flip a bit in the message and the test does not pass msg = "52fdfc072182654f163f5f0f9a621d729566c74d0aa413bf009c9800418c19cd"; msgUint8Array = new Uint8Array(Buffer.from(msg)); @@ -1097,7 +1097,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should throw an exeption when the program is different", () => { + it("Should throw an exeption when the program is different", function () { //change the program code and the test does not pass tealCode = ` int 1 @@ -1133,7 +1133,7 @@ describe("Teal Opcodes", function () { ) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { const account = generateAccount(); const toSign = new Uint8Array(Buffer.from([1, 9, 25, 49])); const signed = signBytes(toSign, account.sk); @@ -1150,7 +1150,7 @@ describe("Teal Opcodes", function () { describe("LessThan", function () { const stack = new Stack(); - it("should push 1 to stack because 5 < 10", () => { + it("should push 1 to stack because 5 < 10", function () { stack.push(5n); stack.push(10n); @@ -1161,7 +1161,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 1n); }); - it("should push 0 to stack as 10 > 5", () => { + it("should push 0 to stack as 10 > 5", function () { stack.push(10n); stack.push(5n); @@ -1196,7 +1196,7 @@ describe("Teal Opcodes", function () { describe("GreaterThan", function () { const stack = new Stack(); - it("should push 1 to stack as 5 > 2", () => { + it("should push 1 to stack as 5 > 2", function () { stack.push(5n); stack.push(2n); @@ -1207,7 +1207,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 1n); }); - it("should push 0 to stack as 50 > 10", () => { + it("should push 0 to stack as 50 > 10", function () { stack.push(10n); stack.push(50n); @@ -1242,7 +1242,7 @@ describe("Teal Opcodes", function () { describe("LessThanEqualTo", function () { const stack = new Stack(); - it("should push 1 to stack", () => { + it("should push 1 to stack", function () { const op = new LessThanEqualTo([], 1); stack.push(20n); stack.push(20n); @@ -1253,7 +1253,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 1n); }); - it("should push 0 to stack", () => { + it("should push 0 to stack", function () { const op = new LessThanEqualTo([], 1); stack.push(100n); stack.push(50n); @@ -1288,7 +1288,7 @@ describe("Teal Opcodes", function () { describe("GreaterThanEqualTo", function () { const stack = new Stack(); - it("should push 1 to stack", () => { + it("should push 1 to stack", function () { const op = new GreaterThanEqualTo([], 1); stack.push(20n); stack.push(20n); @@ -1299,7 +1299,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 1n); }); - it("should push 0 to stack", () => { + it("should push 0 to stack", function () { const op = new GreaterThanEqualTo([], 1); stack.push(100n); stack.push(500n); @@ -1331,10 +1331,10 @@ describe("Teal Opcodes", function () { ); }); - describe("And", () => { + describe("And", function () { const stack = new Stack(); - it("should push true to stack as both values are 1", () => { + it("should push true to stack as both values are 1", function () { stack.push(1n); stack.push(1n); @@ -1345,7 +1345,7 @@ describe("Teal Opcodes", function () { assert.equal(1n, top); }); - it("should push false to stack as one value is 0", () => { + it("should push false to stack as one value is 0", function () { stack.push(0n); stack.push(1n); @@ -1377,10 +1377,10 @@ describe("Teal Opcodes", function () { ); }); - describe("Or", () => { + describe("Or", function () { const stack = new Stack(); - it("should push true to stack as one value is 1", () => { + it("should push true to stack as one value is 1", function () { stack.push(0n); stack.push(1n); @@ -1391,7 +1391,7 @@ describe("Teal Opcodes", function () { assert.equal(1n, top); }); - it("should push false to stack as both values are 0", () => { + it("should push false to stack as both values are 0", function () { stack.push(0n); stack.push(0n); @@ -1423,10 +1423,10 @@ describe("Teal Opcodes", function () { ); }); - describe("EqualTo", () => { + describe("EqualTo", function () { const stack = new Stack(); - it("should push true to stack", () => { + it("should push true to stack", function () { stack.push(22n); stack.push(22n); @@ -1444,7 +1444,7 @@ describe("Teal Opcodes", function () { assert.equal(1n, top); }); - it("should push false to stack", () => { + it("should push false to stack", function () { stack.push(22n); stack.push(1n); @@ -1462,7 +1462,7 @@ describe("Teal Opcodes", function () { assert.equal(0n, top); }); - it("should throw error", () => { + it("should throw error", function () { stack.push(12n); stack.push(new Uint8Array([1, 2, 3])); const op = new EqualTo([], 1); @@ -1471,10 +1471,10 @@ describe("Teal Opcodes", function () { }); }); - describe("NotEqualTo", () => { + describe("NotEqualTo", function () { const stack = new Stack(); - it("should push true to stack", () => { + it("should push true to stack", function () { stack.push(21n); stack.push(22n); @@ -1492,7 +1492,7 @@ describe("Teal Opcodes", function () { assert.equal(1n, top); }); - it("should push false to stack", () => { + it("should push false to stack", function () { stack.push(22n); stack.push(22n); @@ -1510,7 +1510,7 @@ describe("Teal Opcodes", function () { assert.equal(0n, top); }); - it("should throw error", () => { + it("should throw error", function () { stack.push(12n); stack.push(new Uint8Array([1, 2, 3])); const op = new EqualTo([], 1); @@ -1519,10 +1519,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Not", () => { + describe("Not", function () { const stack = new Stack(); - it("should push 1", () => { + it("should push 1", function () { stack.push(0n); const op = new Not([], 1); op.execute(stack); @@ -1531,7 +1531,7 @@ describe("Teal Opcodes", function () { assert.equal(1n, top); }); - it("should push 0", () => { + it("should push 0", function () { stack.push(122n); const op = new Not([], 1); op.execute(stack); @@ -1541,10 +1541,10 @@ describe("Teal Opcodes", function () { }); }); - describe("itob", () => { + describe("itob", function () { const stack = new Stack(); - it("should convert int to bytes", () => { + it("should convert int to bytes", function () { stack.push(4n); const op = new Itob([], 1); op.execute(stack); @@ -1565,10 +1565,10 @@ describe("Teal Opcodes", function () { ); }); - describe("btoi", () => { + describe("btoi", function () { const stack = new Stack(); - it("should convert bytes to int", () => { + it("should convert bytes to int", function () { stack.push(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1])); const op = new Btoi([], 1); op.execute(stack); @@ -1577,7 +1577,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 1n); }); - it("should throw invalid type error", () => { + it("should throw invalid type error", function () { stack.push(new Uint8Array([0, 1, 1, 1, 1, 1, 1, 1, 0])); const op = new Btoi([], 1); assert.throws( @@ -1587,10 +1587,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Addw", () => { + describe("Addw", function () { const stack = new Stack(); - it("should add carry", () => { + it("should add carry", function () { stack.push(MAX_UINT64); stack.push(3n); const op = new Addw([], 1); @@ -1602,7 +1602,7 @@ describe("Teal Opcodes", function () { assert.equal(valueCARRY, 1n); }); - it("should not add carry", () => { + it("should not add carry", function () { stack.push(10n); stack.push(3n); const op = new Addw([], 1); @@ -1615,10 +1615,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Mulw", () => { + describe("Mulw", function () { const stack = new Stack(); - it("should return correct low and high value", () => { + it("should return correct low and high value", function () { stack.push(4581298449n); stack.push(9162596898n); const op = new Mulw([], 1); @@ -1630,7 +1630,7 @@ describe("Teal Opcodes", function () { assert.equal(high, 2n); }); - it("should return correct low and high value on big numbers", () => { + it("should return correct low and high value on big numbers", function () { stack.push(MAX_UINT64 - 2n); stack.push(9162596898n); const op = new Mulw([], 1); @@ -1642,7 +1642,7 @@ describe("Teal Opcodes", function () { assert.equal(high, 9162596897n); }); - it("high bits should be 0", () => { + it("high bits should be 0", function () { stack.push(10n); stack.push(3n); const op = new Mulw([], 1); @@ -1654,7 +1654,7 @@ describe("Teal Opcodes", function () { assert.equal(high, 0n); }); - it("low and high should be 0 on a*b if a or b is 0", () => { + it("low and high should be 0 on a*b if a or b is 0", function () { stack.push(0n); stack.push(3n); const op = new Mulw([], 1); @@ -1682,10 +1682,10 @@ describe("Teal Opcodes", function () { ); }); - describe("Dup", () => { + describe("Dup", function () { const stack = new Stack(); - it("should duplicate value", () => { + it("should duplicate value", function () { stack.push(2n); const op = new Dup([], 1); op.execute(stack); @@ -1697,10 +1697,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Dup2", () => { + describe("Dup2", function () { const stack = new Stack(); - it("should duplicate value(A, B -> A, B, A, B)", () => { + it("should duplicate value(A, B -> A, B, A, B)", function () { stack.push(2n); stack.push(3n); const op = new Dup2([], 1); @@ -1726,10 +1726,10 @@ describe("Teal Opcodes", function () { ); }); - describe("Concat", () => { + describe("Concat", function () { const stack = new Stack(); - it("should concat two byte strings", () => { + it("should concat two byte strings", function () { stack.push(new Uint8Array([3, 2, 1])); stack.push(new Uint8Array([1, 2, 3])); let op = new Concat([], 1); @@ -1747,7 +1747,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(top, parsing.stringToBytes("HelloFriend")); }); - it("should throw error as byte strings too long", () => { + it("should throw error as byte strings too long", function () { stack.push(new Uint8Array(4000)); stack.push(new Uint8Array(1000)); const op = new Concat([], 1); @@ -2011,7 +2011,7 @@ describe("Teal Opcodes", function () { describe("Transaction opcodes", function () { const stack = new Stack(); let interpreter: Interpreter; - before(() => { + before(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); interpreter.runtime.ctx.tx = TXN_OBJ; @@ -2091,7 +2091,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(TXN_OBJ.rekey, stack.pop()); }); - it("should throw error on FirstValidTime", () => { + it("should throw error on FirstValidTime", function () { execExpectError( stack, [], @@ -2525,19 +2525,19 @@ describe("Teal Opcodes", function () { }); describe("Txn: teal v6", function () { - it("should return empty log if no log emit before", () => { + it("should return empty log if no log emit before", function () { const op = new Txn(["LastLog"], 1, interpreter); op.execute(stack); assert.deepEqual(stack.pop(), new Uint8Array(0)); }); - it("should return last log", () => { + it("should return last log", function () { interpreter.runtime.ctx.lastLog = new Uint8Array([42, 32]); const op = new Txn(["LastLog"], 1, interpreter); op.execute(stack); assert.deepEqual(stack.pop(), new Uint8Array([42, 32])); }); - it("should return StateProofPK", () => { + it("should return StateProofPK", function () { const op = new Txn(["StateProofPK"], 1, interpreter); op.execute(stack); assert.deepEqual(stack.pop(), new Uint8Array(64).fill(0)); @@ -2832,7 +2832,7 @@ describe("Teal Opcodes", function () { }); describe("Gitxna", function () { - this.beforeEach(() => { + this.beforeEach(function () { interpreter.tealVersion = 6; const tx = interpreter.runtime.ctx.tx; // a) 'apas' represents 'foreignAssets', b) @@ -2927,7 +2927,7 @@ describe("Teal Opcodes", function () { }); // setup test account setDummyAccInfo(acc1); - before(() => { + before(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([acc1]); interpreter.runtime.ctx.tx = TXN_OBJ; @@ -3034,11 +3034,11 @@ describe("Teal Opcodes", function () { }); describe("Tealv6 fields", function () { - this.beforeEach(() => { + this.beforeEach(function () { interpreter.tealVersion = 6; interpreter.runtime.ctx.innerTxAppIDCallStack = [1, 2]; }); - it("Tealv6: CalllerApplicationAddress", () => { + it("Tealv6: CalllerApplicationAddress", function () { // caller app id = 2 const op = new Global(["CallerApplicationAddress"], 1, interpreter); op.execute(stack); @@ -3050,7 +3050,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(ZERO_ADDRESS, stack.pop()); }); - it("Tealv6: CallerApplicationID", () => { + it("Tealv6: CallerApplicationID", function () { // caller app id = 2 const op = new Global(["CallerApplicationID"], 1, interpreter); op.execute(stack); @@ -3127,7 +3127,7 @@ describe("Teal Opcodes", function () { setDummyAccInfo(acc2); let interpreter: Interpreter; - this.beforeAll(() => { + this.beforeAll(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([acc1, acc2]); @@ -3580,7 +3580,7 @@ describe("Teal Opcodes", function () { }); }); - describe("TEALv4: More Versatile Global and Local Storage", () => { + describe("TEALv4: More Versatile Global and Local Storage", function () { before(function () { interpreter.runtime.ctx.tx.apid = 1828; }); @@ -3694,18 +3694,18 @@ describe("Teal Opcodes", function () { assert.equal(5n, stack.pop()); }); - it("Int: Should work with 2^64 - 1 (max supported number)", () => { + it("Int: Should work with 2^64 - 1 (max supported number)", function () { const total = 2n ** 64n - 1n; assert.doesNotThrow(() => new Int([total.toString()], 0)); }); - it("Int: Should throw an overflow error on 2^64", () => { + it("Int: Should throw an overflow error on 2^64", function () { const total = 2n ** 64n; expectRuntimeError( () => new Int([total.toString()], 0), RUNTIME_ERRORS.TEAL.UINT64_OVERFLOW ); }); - it("Int: Should throw an overflow error on 2^64+1", () => { + it("Int: Should throw an overflow error on 2^64+1", function () { const total = 2n ** 64n + 1n; expectRuntimeError( () => new Int([total.toString()], 0), @@ -3815,7 +3815,7 @@ describe("Teal Opcodes", function () { }); // setup test account setDummyAccInfo(acc1); - this.beforeAll(() => { + this.beforeAll(function () { interpreter = new Interpreter(); const runtime = new Runtime([acc1]); interpreter.runtime = runtime; // setup runtime @@ -3830,7 +3830,7 @@ describe("Teal Opcodes", function () { interpreter.runtime.ctx.tx.apas = [3, 112]; }); - it("should push correct account balance", () => { + it("should push correct account balance", function () { const op = new Balance([], 1, interpreter); stack.push(0n); // push sender id @@ -3841,7 +3841,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 123n); }); - it("should throw account doesn't exist error", () => { + it("should throw account doesn't exist error", function () { const op = new Balance([], 1, interpreter); stack.push(2n); @@ -3851,14 +3851,14 @@ describe("Teal Opcodes", function () { ); }); - it("should throw index out of bound error", () => { + it("should throw index out of bound error", function () { const op = new Balance([], 1, interpreter); stack.push(8n); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); - it("should push correct Asset Balance", () => { + it("should push correct Asset Balance", function () { const op = new GetAssetHolding(["AssetBalance"], 1, interpreter); stack.push(1n); // account index @@ -3872,7 +3872,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev.toString(), "2"); }); - it("should push correct Asset Freeze status", () => { + it("should push correct Asset Freeze status", function () { const op = new GetAssetHolding(["AssetFrozen"], 1, interpreter); stack.push(1n); // account index @@ -3886,7 +3886,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, 0n); }); - it("should push 0 if not defined", () => { + it("should push 0 if not defined", function () { stack.push(1n); // account index stack.push(4n); // asset id @@ -3899,7 +3899,7 @@ describe("Teal Opcodes", function () { assert.equal(prev, 0n); }); - it("should throw index out of bound error", () => { + it("should throw index out of bound error", function () { const op = new GetAssetHolding(["1"], 1, interpreter); stack.push(10n); // account index @@ -3908,7 +3908,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); - it("should push correct Asset Total", () => { + it("should push correct Asset Total", function () { const op = new GetAssetDef(["AssetTotal"], 1, interpreter); stack.push(0n); // asset index @@ -3921,7 +3921,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev.toString(), "10000"); }); - it("should push correct Asset Decimals", () => { + it("should push correct Asset Decimals", function () { const op = new GetAssetDef(["AssetDecimals"], 1, interpreter); stack.push(0n); // asset index @@ -3934,7 +3934,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev.toString(), "10"); }); - it("should push correct Asset Default Frozen", () => { + it("should push correct Asset Default Frozen", function () { const op = new GetAssetDef(["AssetDefaultFrozen"], 1, interpreter); stack.push(0n); // asset index @@ -3947,7 +3947,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, 0n); }); - it("should push correct Asset Unit Name", () => { + it("should push correct Asset Unit Name", function () { const op = new GetAssetDef(["AssetUnitName"], 1, interpreter); stack.push(0n); // asset index @@ -3960,7 +3960,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("AD")); }); - it("should push correct Asset Name", () => { + it("should push correct Asset Name", function () { const op = new GetAssetDef(["AssetName"], 1, interpreter); stack.push(0n); // asset index @@ -3973,7 +3973,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("ASSETAD")); }); - it("should push correct Asset URL", () => { + it("should push correct Asset URL", function () { const op = new GetAssetDef(["AssetURL"], 1, interpreter); stack.push(0n); // asset index @@ -3986,7 +3986,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("assetUrl")); }); - it("should push correct Asset MetaData Hash", () => { + it("should push correct Asset MetaData Hash", function () { const op = new GetAssetDef(["AssetMetadataHash"], 1, interpreter); stack.push(0n); // asset index @@ -3999,7 +3999,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("hash", EncodingType.BASE64)); }); - it("should push correct Asset Manager", () => { + it("should push correct Asset Manager", function () { const op = new GetAssetDef(["AssetManager"], 1, interpreter); stack.push(0n); // asset index @@ -4012,7 +4012,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("addr-1")); }); - it("should push correct Asset Reserve", () => { + it("should push correct Asset Reserve", function () { const op = new GetAssetDef(["AssetReserve"], 1, interpreter); stack.push(0n); // asset index @@ -4025,7 +4025,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("addr-2")); }); - it("should push correct Asset Freeze", () => { + it("should push correct Asset Freeze", function () { const op = new GetAssetDef(["AssetFreeze"], 1, interpreter); stack.push(0n); // asset index @@ -4038,7 +4038,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("addr-3")); }); - it("should push correct Asset Clawback", () => { + it("should push correct Asset Clawback", function () { const op = new GetAssetDef(["AssetClawback"], 1, interpreter); stack.push(0n); // asset index @@ -4051,7 +4051,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(prev, convertToBuffer("addr-4")); }); - it("TEALv5: should push correct Asset Creator", () => { + it("TEALv5: should push correct Asset Creator", function () { interpreter.tealVersion = 5; const op = new GetAssetDef(["AssetCreator"], 1, interpreter); @@ -4065,7 +4065,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(creator, convertToBuffer("addr-1")); }); - it("should push 0 if Asset not defined", () => { + it("should push 0 if Asset not defined", function () { const op = new GetAssetDef(["AssetFreeze"], 1, interpreter); stack.push(1n); // account index @@ -4078,7 +4078,7 @@ describe("Teal Opcodes", function () { assert.equal(prev, 0n); }); - it("should throw index out of bound error for Asset Param", () => { + it("should throw index out of bound error for Asset Param", function () { interpreter.tealVersion = 1; const op = new GetAssetDef(["AssetFreeze"], 1, interpreter); @@ -4090,7 +4090,7 @@ describe("Teal Opcodes", function () { ); }); - it("tealv4: should push correct value accepting offset to foreignAssets", () => { + it("tealv4: should push correct value accepting offset to foreignAssets", function () { interpreter.tealVersion = 4; // interpreter.runtime.ctx.tx.apas = [1234, 3]; const op = new GetAssetHolding(["AssetBalance"], 1, interpreter); @@ -4108,7 +4108,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop().toString(), "2"); }); - it("tealv4: should return value as treating ref as offset, if it represents an index", () => { + it("tealv4: should return value as treating ref as offset, if it represents an index", function () { interpreter.tealVersion = 4; interpreter.runtime.ctx.tx.apas = [1234, 3, 34, 45, 67]; const op = new GetAssetHolding(["AssetBalance"], 1, interpreter); @@ -4127,13 +4127,13 @@ describe("Teal Opcodes", function () { }); }); - describe("PushInt", () => { + describe("PushInt", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should push uint64 to stack", () => { + it("should push uint64 to stack", function () { const op = new PushInt([MAX_UINT64.toString()], 0); op.execute(stack); @@ -4142,13 +4142,13 @@ describe("Teal Opcodes", function () { }); }); - describe("PushBytes", () => { + describe("PushBytes", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should push bytes to stack", () => { + it("should push bytes to stack", function () { const str = '"Algorand"'; const expectedBytes = new Uint8Array(Buffer.from("Algorand")); @@ -4160,21 +4160,21 @@ describe("Teal Opcodes", function () { }); }); - describe("Assert", () => { + describe("Assert", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should not panic if top of stack is non zero uint64", () => { + it("should not panic if top of stack is non zero uint64", function () { const op = new Assert([], 0); stack.push(55n); - assert.doesNotThrow(() => { + assert.doesNotThrow(function () { op.execute(stack); }); }); - it("should panic if top of stack is zero or bytes", () => { + it("should panic if top of stack is zero or bytes", function () { const op = new Assert([], 0); stack.push(0n); @@ -4184,20 +4184,20 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should throw error if stack is empty", () => { + it("should throw error if stack is empty", function () { const op = new Assert([], 0); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); }); - describe("Swap", () => { + describe("Swap", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should not panic if top of stack is non zero uint64", () => { + it("should not panic if top of stack is non zero uint64", function () { let op = new Swap([], 0); stack.push(5n); stack.push(10n); @@ -4226,7 +4226,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), parsing.stringToBytes("a")); }); - it("should throw error if length of stack < 2", () => { + it("should throw error if length of stack < 2", function () { const op = new Swap([], 0); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); @@ -4235,13 +4235,13 @@ describe("Teal Opcodes", function () { }); }); - describe("SetBit", () => { + describe("SetBit", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should set bit for uint64", () => { + it("should set bit for uint64", function () { const op = new SetBit([], 0); stack.push(0n); // target stack.push(4n); // index @@ -4289,7 +4289,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), MAX_UINT64 - 2n); }); - it("should panic if index bit is not uint64", () => { + it("should panic if index bit is not uint64", function () { const op = new SetBit([], 0); stack.push(0n); // target stack.push(new Uint8Array([1, 2])); // index @@ -4298,7 +4298,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if set bit is not uint64", () => { + it("should panic if set bit is not uint64", function () { const op = new SetBit([], 0); stack.push(0n); // target stack.push(4n); // index @@ -4307,7 +4307,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if stack length is less than 3", () => { + it("should panic if stack length is less than 3", function () { const op = new SetBit([], 0); stack.push(0n); stack.push(4n); @@ -4315,7 +4315,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("should panic if set bit is greater than 1", () => { + it("should panic if set bit is greater than 1", function () { const op = new SetBit([], 0); stack.push(0n); stack.push(4n); @@ -4324,7 +4324,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SET_BIT_VALUE_ERROR); }); - it("should panic if set bit index is greater than 63 and target is uint64", () => { + it("should panic if set bit index is greater than 63 and target is uint64", function () { const op = new SetBit([], 0); stack.push(0n); stack.push(400n); @@ -4333,7 +4333,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SET_BIT_INDEX_ERROR); }); - it("should set bit in bytes array", () => { + it("should set bit in bytes array", function () { const op = new SetBit([], 0); stack.push(new Uint8Array([0, 0, 0])); // target stack.push(8n); // index @@ -4375,7 +4375,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), new Uint8Array([1, 2 ** 7, 0])); }); - it("should panic if index bit in out of bytes array", () => { + it("should panic if index bit in out of bytes array", function () { const op = new SetBit([], 0); stack.push(new Uint8Array([0, 0, 0])); // target stack.push(80n); // index @@ -4397,13 +4397,13 @@ describe("Teal Opcodes", function () { }); }); - describe("GetBit", () => { + describe("GetBit", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should push correct bit to stack(uint64)", () => { + it("should push correct bit to stack(uint64)", function () { const op = new GetBit([], 0); stack.push(8n); // target stack.push(3n); // index @@ -4418,7 +4418,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("should push correct bit to stack(bytes array)", () => { + it("should push correct bit to stack(bytes array)", function () { const op = new GetBit([], 0); stack.push(new Uint8Array([0, 128, 1])); // target stack.push(8n); // index @@ -4436,14 +4436,14 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("should panic if stack length is less than 2", () => { + it("should panic if stack length is less than 2", function () { const op = new GetBit([], 0); stack.push(0n); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("should panic if index bit is not uint64", () => { + it("should panic if index bit is not uint64", function () { const op = new GetBit([], 0); stack.push(8n); // target stack.push(new Uint8Array(0)); // index @@ -4451,7 +4451,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if index bit in out of uint64 bits", () => { + it("should panic if index bit in out of uint64 bits", function () { const op = new GetBit([], 0); stack.push(8n); // target stack.push(500n); // index @@ -4459,7 +4459,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SET_BIT_INDEX_ERROR); }); - it("should panic if index bit in out of bytes array", () => { + it("should panic if index bit in out of bytes array", function () { const op = new GetBit([], 0); stack.push(new Uint8Array(0)); // target stack.push(500n); // index @@ -4471,13 +4471,13 @@ describe("Teal Opcodes", function () { }); }); - describe("GetByte", () => { + describe("GetByte", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should get correct bytes from stack", () => { + it("should get correct bytes from stack", function () { const op = new GetByte([], 0); stack.push(new Uint8Array([8, 2, 1, 9])); // target stack.push(0n); // index @@ -4498,7 +4498,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 3n); }); - it("should panic if target is not bytes", () => { + it("should panic if target is not bytes", function () { const op = new GetByte([], 0); stack.push(10n); // target stack.push(0n); // index @@ -4506,7 +4506,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if index is not uint", () => { + it("should panic if index is not uint", function () { const op = new GetByte([], 0); stack.push(new Uint8Array(0)); // target stack.push(new Uint8Array(0)); // index @@ -4514,7 +4514,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if index bit is out of bytes array", () => { + it("should panic if index bit is out of bytes array", function () { const op = new GetByte([], 0); stack.push(new Uint8Array(0)); // target stack.push(500n); // index @@ -4534,13 +4534,13 @@ describe("Teal Opcodes", function () { }); }); - describe("SetByte", () => { + describe("SetByte", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should set correct bytes and push to stack", () => { + it("should set correct bytes and push to stack", function () { const op = new SetByte([], 0); stack.push(new Uint8Array([8, 2, 1, 9])); // target stack.push(0n); // index @@ -4557,7 +4557,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), new Uint8Array([8, 2, 1, 0])); }); - it("should panic if target is not bytes(Uint8Array)", () => { + it("should panic if target is not bytes(Uint8Array)", function () { const op = new SetByte([], 0); stack.push(1n); // target stack.push(0n); // index @@ -4566,7 +4566,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if index of small integer is not uint", () => { + it("should panic if index of small integer is not uint", function () { const op = new SetByte([], 0); stack.push(new Uint8Array(0)); // target stack.push(new Uint8Array(0)); // index @@ -4581,7 +4581,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_TYPE); }); - it("should panic if index bit is out of bytes array", () => { + it("should panic if index bit is out of bytes array", function () { const op = new SetByte([], 0); stack.push(new Uint8Array(0)); // target stack.push(500n); // index @@ -4603,13 +4603,13 @@ describe("Teal Opcodes", function () { }); }); - describe("Dig", () => { + describe("Dig", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should duplicate nth slot from top of stack (with uint64 and bytes)", () => { + it("should duplicate nth slot from top of stack (with uint64 and bytes)", function () { let op = new Dig(["1"], 0); stack.push(5n); stack.push(10n); @@ -4629,7 +4629,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), parsing.stringToBytes("hello")); }); - it("should duplicate nth slot from top of stack (mixed cases)", () => { + it("should duplicate nth slot from top of stack (mixed cases)", function () { stack.push(5n); stack.push(10n); stack.push(parsing.stringToBytes("hello")); @@ -4661,7 +4661,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), parsing.stringToBytes("Algorand")); }); - it("should panic if depth of stack is insufficient", () => { + it("should panic if depth of stack is insufficient", function () { const op = new Dig(["4"], 0); stack.push(5n); stack.push(10n); @@ -4670,13 +4670,13 @@ describe("Teal Opcodes", function () { }); }); - describe("Select", () => { + describe("Select", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should push '2nd element from top of stack' to stack if top is not zero", () => { + it("should push '2nd element from top of stack' to stack if top is not zero", function () { let op = new Select([], 0); stack.push(parsing.stringToBytes("lionel")); stack.push(parsing.stringToBytes("messi")); @@ -4696,7 +4696,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 100n); }); - it("should push '3rd element from top of stack' to stack if top is zero", () => { + it("should push '3rd element from top of stack' to stack if top is zero", function () { let op = new Select([], 0); stack.push(parsing.stringToBytes("lionel")); stack.push(parsing.stringToBytes("messi")); @@ -4716,7 +4716,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 100n); }); - it("should panic if length of stack is < 3", () => { + it("should panic if length of stack is < 3", function () { const op = new Select([], 0); stack.push(parsing.stringToBytes("lionel")); stack.push(0n); @@ -4724,7 +4724,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("should panic if top of stack is not uint64", () => { + it("should panic if top of stack is not uint64", function () { const op = new Select([], 0); stack.push(parsing.stringToBytes("lionel")); stack.push(parsing.stringToBytes("andres")); @@ -4734,12 +4734,12 @@ describe("Teal Opcodes", function () { }); }); - describe("Gtxns and Gtxnsa", () => { + describe("Gtxns and Gtxnsa", function () { let stack: Stack; let interpreter: Interpreter; let tx0: EncodedTx, tx1: EncodedTx; - this.beforeAll(() => { + this.beforeAll(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); interpreter.tealVersion = MaxTEALVersion; @@ -4748,11 +4748,11 @@ describe("Teal Opcodes", function () { interpreter.runtime.ctx.gtxs = [tx0, tx1]; }); - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("Gtxns: should push value of txfield from tx in group", () => { + it("Gtxns: should push value of txfield from tx in group", function () { stack.push(0n); // tx to fetch "fee" of (set as first) let op = new Gtxns(["Fee"], 1, interpreter); op.execute(stack); @@ -4785,18 +4785,18 @@ describe("Teal Opcodes", function () { assert.deepEqual(parsing.stringToBytes("argC"), stack.pop()); }); - it("Gtxns: should panic if length of stack is < 1", () => { + it("Gtxns: should panic if length of stack is < 1", function () { const op = new Gtxns(["Fee"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("Gtxns: should panic if transaction index is out of bounds", () => { + it("Gtxns: should panic if transaction index is out of bounds", function () { stack.push(5n); // we only have 2 transactions in group const op = new Gtxns(["Fee"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); - it("Gtxnsa: should push value of txfieldArr[index] from tx in group", () => { + it("Gtxnsa: should push value of txfieldArr[index] from tx in group", function () { TXN_OBJ.apaa = [Buffer.from("arg1"), Buffer.from("arg2")]; stack.push(0n); let op = new Gtxnsa(["ApplicationArgs", "1"], 1, interpreter); @@ -4811,7 +4811,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(parsing.stringToBytes("argA"), stack.pop()); // args from tx1 }); - it("Gtxnsa: should panic if index is out of bounds for txFieldArr", () => { + it("Gtxnsa: should panic if index is out of bounds for txFieldArr", function () { // should throw error as appArgs[10] is undefined stack.push(0n); let op = new Gtxnsa(["ApplicationArgs", "10"], 1, interpreter); @@ -4822,14 +4822,14 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); - it("Gtxns: should panic if transaction index is out of bounds", () => { + it("Gtxns: should panic if transaction index is out of bounds", function () { stack.push(5n); // we only have 2 transactions in group const op = new Gtxnsa(["ApplicationArgs", "1"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); }); - describe("min_balance", () => { + describe("min_balance", function () { useFixture("asa-check"); const stack = new Stack(); @@ -4842,7 +4842,7 @@ describe("Teal Opcodes", function () { setDummyAccInfo(john); let interpreter: Interpreter; - before(() => { + before(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([elon, john]); interpreter.runtime.ctx.tx.snd = Buffer.from(decodeAddress(elonAddr).publicKey); @@ -4854,7 +4854,7 @@ describe("Teal Opcodes", function () { ].map(Buffer.from); }); - it("should push correct account minimum balance", () => { + it("should push correct account minimum balance", function () { let op = new MinBalance([], 1, interpreter); stack.push(0n); // push sender id @@ -4870,7 +4870,7 @@ describe("Teal Opcodes", function () { assert.equal(top, BigInt(ALGORAND_ACCOUNT_MIN_BALANCE)); }); - it("should push raised min_balance to stack after creating asset", () => { + it("should push raised min_balance to stack after creating asset", function () { interpreter.runtime.deployASA("gold", { creator: { ...elon.account, name: "elon" } }); // create asset elon = interpreter.runtime.getAccount(elon.address); // sync @@ -4882,7 +4882,7 @@ describe("Teal Opcodes", function () { assert.equal(top, BigInt(ALGORAND_ACCOUNT_MIN_BALANCE + ASSET_CREATION_FEE)); }); - it("should panic if account does not exist", () => { + it("should panic if account does not exist", function () { interpreter.runtime.ctx.tx.apat = [ decodeAddress(johnAddr).publicKey, decodeAddress(generateAccount().addr).publicKey, // random account @@ -4897,7 +4897,7 @@ describe("Teal Opcodes", function () { ); }); - it("should throw index out of bound error", () => { + it("should throw index out of bound error", function () { const op = new Balance([], 1, interpreter); stack.push(8n); @@ -4905,11 +4905,11 @@ describe("Teal Opcodes", function () { }); }); - describe("Shared data between contracts opcode(gload, gloads, gloadss)", () => { + describe("Shared data between contracts opcode(gload, gloads, gloadss)", function () { let stack: Stack; let interpreter: Interpreter; - this.beforeAll(() => { + this.beforeAll(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); interpreter.tealVersion = MaxTEALVersion; @@ -4919,12 +4919,12 @@ describe("Teal Opcodes", function () { interpreter.runtime.ctx.sharedScratchSpace.set(2, [12n, 2n, 0n, 1n]); }); - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); describe("gload opcode", function () { - it("should push value from ith tx in shared scratch space(gload)", () => { + it("should push value from ith tx in shared scratch space(gload)", function () { const op = new Gload(["0", "1"], 1, interpreter); op.execute(stack); @@ -4933,7 +4933,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 2n); }); - it("should throw error if tx doesn't exist(gload)", () => { + it("should throw error if tx doesn't exist(gload)", function () { let op = new Gload(["1", "1"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SCRATCH_EXIST_ERROR); @@ -4943,7 +4943,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SCRATCH_EXIST_ERROR); }); - it("should throw error if value doesn't exist in stack elem array(gload)", () => { + it("should throw error if value doesn't exist in stack elem array(gload)", function () { const op = new Gload(["2", "5"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); @@ -4951,7 +4951,7 @@ describe("Teal Opcodes", function () { }); describe("gloads opcode", function () { - it("should push value from ith tx in shared scratch space(gloads)", () => { + it("should push value from ith tx in shared scratch space(gloads)", function () { const op = new Gloads(["1"], 1, interpreter); stack.push(0n); @@ -4961,7 +4961,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 2n); }); - it("should throw error if tx doesn't exist(gloads)", () => { + it("should throw error if tx doesn't exist(gloads)", function () { let op = new Gloads(["1"], 1, interpreter); stack.push(1n); @@ -4973,7 +4973,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SCRATCH_EXIST_ERROR); }); - it("should throw error if value doesn't exist in stack elem array(gloads)", () => { + it("should throw error if value doesn't exist in stack elem array(gloads)", function () { const op = new Gloads(["5"], 1, interpreter); stack.push(2n); @@ -4982,7 +4982,7 @@ describe("Teal Opcodes", function () { }); describe("gloadss opcode(TEAL v6)", function () { - it("should push value from ith tx in shared scratch space(gloadss)", () => { + it("should push value from ith tx in shared scratch space(gloadss)", function () { const op = new Gloadss([], 1, interpreter); stack.push(0n); // transaction 0th stack.push(1n); // scratch space 1st @@ -4993,7 +4993,7 @@ describe("Teal Opcodes", function () { assert.equal(top, 2n); }); - it("should throw error if tx doesn't exist(gloadss)", () => { + it("should throw error if tx doesn't exist(gloadss)", function () { let op = new Gloadss([], 1, interpreter); stack.push(1n); stack.push(1n); @@ -5007,7 +5007,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.SCRATCH_EXIST_ERROR); }); - it("should throw error if value doesn't exist in stack elem array(gloadss)", () => { + it("should throw error if value doesn't exist in stack elem array(gloadss)", function () { const op = new Gloadss([], 1, interpreter); stack.push(2n); // transaction id stack.push(5n); // scratch id @@ -5017,13 +5017,13 @@ describe("Teal Opcodes", function () { }); }); - describe("TEALv4: Byteslice Arithmetic Ops", () => { + describe("TEALv4: Byteslice Arithmetic Ops", function () { const hexToByte = (hex: string): Uint8Array => { const [string, encoding] = getEncoding([hex], 0); return Uint8Array.from(convertToBuffer(string, encoding)); }; - describe("ByteAdd", () => { + describe("ByteAdd", function () { const stack = new Stack(); // hex values are taken from go-algorand tests @@ -5086,7 +5086,7 @@ describe("Teal Opcodes", function () { assert.isAbove(top.length, 64); // output array is of 65 bytes (because o/p length is limited to 128 bytes) }); - it("should throw error with ByteAdd if input > 64 bytes", () => { + it("should throw error with ByteAdd if input > 64 bytes", function () { let str = ""; for (let i = 0; i < 65; i++) { str += "ff"; @@ -5113,7 +5113,7 @@ describe("Teal Opcodes", function () { execExpectError(stack, [1n, 2n], new ByteAdd([], 0), RUNTIME_ERRORS.TEAL.INVALID_TYPE) ); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteAdd([], 0); @@ -5121,7 +5121,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteSub", () => { + describe("ByteSub", function () { const stack = new Stack(); it("should return correct subtraction of two byte arrays", function () { @@ -5188,7 +5188,7 @@ describe("Teal Opcodes", function () { execExpectError(stack, [1n, 2n], new ByteSub([], 0), RUNTIME_ERRORS.TEAL.INVALID_TYPE) ); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteSub([], 0); @@ -5196,7 +5196,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteMul", () => { + describe("ByteMul", function () { const stack = new Stack(); it("should return correct multiplication of two byte arrays", function () { @@ -5239,7 +5239,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteMul([], 0); @@ -5249,7 +5249,7 @@ describe("Teal Opcodes", function () { // rest of tests for all opcodes are common, which should be covered by b+, b- }); - describe("ByteDiv", () => { + describe("ByteDiv", function () { const stack = new Stack(); it("should return correct division of two byte arrays", function () { @@ -5288,7 +5288,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ZERO_DIV); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteDiv([], 0); @@ -5296,7 +5296,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteMod", () => { + describe("ByteMod", function () { const stack = new Stack(); it("should return correct modulo of two byte arrays", function () { @@ -5335,7 +5335,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ZERO_DIV); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteMod([], 0); @@ -5343,7 +5343,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteLessThan", () => { + describe("ByteLessThan", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for bytelessthan", function () { @@ -5370,7 +5370,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteGreaterThan", () => { + describe("ByteGreaterThan", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for ByteGreaterThan", function () { @@ -5397,7 +5397,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteLessThanEqualTo", () => { + describe("ByteLessThanEqualTo", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for ByteLessThanEqualTo", function () { @@ -5424,7 +5424,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteGreaterThanEqualTo", () => { + describe("ByteGreaterThanEqualTo", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for ByteGreaterThanEqualTo", function () { @@ -5451,7 +5451,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteEqualTo", () => { + describe("ByteEqualTo", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for ByteEqualTo", function () { @@ -5478,7 +5478,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteNotEqualTo", () => { + describe("ByteNotEqualTo", function () { const stack = new Stack(); it("should push 0/1 depending on value of two byte arrays for ByteNotEqualTo", function () { @@ -5505,7 +5505,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteBitwiseOr", () => { + describe("ByteBitwiseOr", function () { const stack = new Stack(); it("should push OR of two byte arrays for ByteBitwiseOr", function () { @@ -5534,7 +5534,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), hexToByte("0x00f1")); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteBitwiseOr([], 0); @@ -5542,7 +5542,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteBitwiseAnd", () => { + describe("ByteBitwiseAnd", function () { const stack = new Stack(); it("should push AND of two byte arrays for ByteBitwiseAnd", function () { @@ -5587,7 +5587,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteBitwiseAnd([], 0); @@ -5595,7 +5595,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteBitwiseXOR", () => { + describe("ByteBitwiseXOR", function () { const stack = new Stack(); it("should push XOR of two byte arrays for ByteBitwiseXOR", function () { @@ -5640,7 +5640,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteBitwiseXor([], 0); @@ -5648,7 +5648,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteBitwiseInvert", () => { + describe("ByteBitwiseInvert", function () { const stack = new Stack(); it("should push bitwise invert of byte array", function () { @@ -5681,7 +5681,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(hexToByte("0x01")); stack.push(hexToByte("0x01")); const op = new ByteBitwiseInvert([], 0); @@ -5689,7 +5689,7 @@ describe("Teal Opcodes", function () { }); }); - describe("ByteZero", () => { + describe("ByteZero", function () { const stack = new Stack(); it("should push zero byte array to stack", function () { @@ -5719,10 +5719,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Tealv4: Additional mathematical opcodes", () => { + describe("Tealv4: Additional mathematical opcodes", function () { const stack = new Stack(); - it("divmodw", () => { + it("divmodw", function () { stack.push(0n); stack.push(500n); stack.push(0n); @@ -5761,7 +5761,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("exp", () => { + it("exp", function () { stack.push(2n); stack.push(5n); const op = new Exp([], 1); @@ -5803,7 +5803,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.UINT64_OVERFLOW); }); - it("expw", () => { + it("expw", function () { stack.push(2n); stack.push(66n); const op = new Expw([], 1); @@ -5833,7 +5833,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.UINT128_OVERFLOW); }); - it("shl", () => { + it("shl", function () { stack.push(0n); stack.push(20n); @@ -5852,7 +5852,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), exp); }); - it("shr", () => { + it("shr", function () { stack.push(0n); stack.push(20n); @@ -5868,7 +5868,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), exp); }); - it("sqrt", () => { + it("sqrt", function () { stack.push(5n); const op = new Sqrt([], 1); op.execute(stack); @@ -5887,11 +5887,11 @@ describe("Teal Opcodes", function () { }); }); - describe("Tealv5: Extract opcodes", () => { + describe("Tealv5: Extract opcodes", function () { const stack = new Stack(); const longByte = parsing.stringToBytes("a".repeat(400)); - it("extract", () => { + it("extract", function () { stack.push(new Uint8Array([12, 23, 3, 2, 23, 43, 43, 12])); let op = new Extract(["1", "3"], 1); op.execute(stack); @@ -5923,7 +5923,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.EXTRACT_RANGE_ERROR); }); - it("extract3", () => { + it("extract3", function () { const op = new Extract3([], 1); stack.push(new Uint8Array([12, 23, 3, 2, 23, 43, 43, 12])); @@ -5944,7 +5944,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.EXTRACT_RANGE_ERROR); }); - it("extract_uint16", () => { + it("extract_uint16", function () { const op = new ExtractUint16([], 1); let expected: bigint; @@ -5967,7 +5967,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.EXTRACT_RANGE_ERROR); }); - it("extract_uint32", () => { + it("extract_uint32", function () { const op = new ExtractUint32([], 1); let expected: bigint; @@ -5990,7 +5990,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.EXTRACT_RANGE_ERROR); }); - it("extract_uint64", () => { + it("extract_uint64", function () { const op = new ExtractUint64([], 1); let expected: bigint; @@ -6012,7 +6012,7 @@ describe("Teal Opcodes", function () { }); }); - describe("Tealv5: ECDSA", () => { + describe("Tealv5: ECDSA", function () { const stack = new Stack(); const ec = new EC("secp256k1"); const key = ec.genKeyPair(); @@ -6021,7 +6021,7 @@ describe("Teal Opcodes", function () { const msgHash = new Uint8Array([0, 1, 2, 3, 4, 5]); const signature = key.sign(msgHash); - it("ecdsa_verify, should verify correct signature", () => { + it("ecdsa_verify, should verify correct signature", function () { // push message stack.push(msgHash); // push signature @@ -6059,7 +6059,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("ecdsa_verify, should not verify wrong signature", () => { + it("ecdsa_verify, should not verify wrong signature", function () { // push message stack.push(msgHash); // push signature (signed by key) @@ -6076,7 +6076,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("ecdsa_verify, should throw error if curve is not supported", () => { + it("ecdsa_verify, should throw error if curve is not supported", function () { stack.push(msgHash); stack.push(signature.r.toBuffer()); stack.push(signature.s.toBuffer()); @@ -6087,7 +6087,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.CURVE_NOT_SUPPORTED); }); - it("ecdsa_pk_decompress", () => { + it("ecdsa_pk_decompress", function () { // https://bitcoin.stackexchange.com/questions/69315/how-are-compressed-pubkeys-generated // example taken from above link const compressed = "0250863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352"; @@ -6111,7 +6111,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.CURVE_NOT_SUPPORTED); }); - it("ecdsa_pk_recover", () => { + it("ecdsa_pk_recover", function () { // push message stack.push(msgHash); // push recovery id @@ -6135,7 +6135,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.CURVE_NOT_SUPPORTED); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { //EdcsaVerify stack.push(msgHash); stack.push(signature.r.toBuffer()); @@ -6160,9 +6160,9 @@ describe("Teal Opcodes", function () { }); }); - describe("Tealv5: cover, uncover", () => { + describe("Tealv5: cover, uncover", function () { let stack: Stack; - beforeEach(() => { + beforeEach(function () { stack = new Stack(); }); @@ -6172,7 +6172,7 @@ describe("Teal Opcodes", function () { } }; - it("cover: move top to below N elements", () => { + it("cover: move top to below N elements", function () { push(stack, 4); const op = new Cover(["2"], 1); @@ -6184,7 +6184,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 4n); assert.equal(stack.pop(), 1n); }); - it("cover: should throw error is length of stack is not enough", () => { + it("cover: should throw error is length of stack is not enough", function () { push(stack, 4); const op = new Cover(["5"], 1); @@ -6192,7 +6192,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("cover: n == 0", () => { + it("cover: n == 0", function () { push(stack, 4); const op = new Cover(["0"], 1); @@ -6204,7 +6204,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 1n); }); - it("cover: n == stack.length", () => { + it("cover: n == stack.length", function () { push(stack, 4); const op = new Cover(["4"], 1); @@ -6212,7 +6212,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("uncover: n = 1", () => { + it("uncover: n = 1", function () { push(stack, 4); // stack state = [1, 2, 3, 4] const op = new Uncover(["1"], 1); @@ -6228,7 +6228,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 1n); }); - it("uncover: n = 0 - stack state should not change", () => { + it("uncover: n = 0 - stack state should not change", function () { push(stack, 4); // stack state = [1, 2, 3, 4] const op = new Uncover(["0"], 1); @@ -6243,7 +6243,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 1n); }); - it("uncover: push bytes and apply 'uncover 1'", () => { + it("uncover: push bytes and apply 'uncover 1'", function () { push(stack, 3); // stack state = [1, 2, 3] stack.push(parsing.stringToBytes("Hello world")); // stack state = [1, 2, 3, "Hello world"] @@ -6261,7 +6261,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 1n); }); - it("uncover: move Nth value to top", () => { + it("uncover: move Nth value to top", function () { push(stack, 4); // stack state = [1, 2, 3, 4] const op = new Uncover(["3"], 1); @@ -6277,7 +6277,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 2n); }); - it("uncover: should throw error is length of stack is not enough", () => { + it("uncover: should throw error is length of stack is not enough", function () { push(stack, 4); const op = new Uncover(["5"], 1); @@ -6286,10 +6286,10 @@ describe("Teal Opcodes", function () { }); }); - describe("Tealv5: txnas, Gtxnas, gtxnsas, args, log", () => { + describe("Tealv5: txnas, Gtxnas, gtxnsas, args, log", function () { const stack = new Stack(); let interpreter: Interpreter; - before(() => { + before(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); interpreter.runtime.ctx.tx = TXN_OBJ; @@ -6437,7 +6437,7 @@ describe("Teal Opcodes", function () { describe("Args[N]", function () { const args = ["Arg0", "Arg1", "Arg2", "Arg3"].map(parsing.stringToBytes); - this.beforeAll(() => { + this.beforeAll(function () { interpreter.runtime.ctx.args = args; }); @@ -6486,7 +6486,7 @@ describe("Teal Opcodes", function () { describe("Log", function () { let txID: string; - this.beforeAll(() => { + this.beforeAll(function () { txID = interpreter.runtime.ctx.tx.txID; interpreter.runtime.ctx.state.txReceipts.set(txID, { txn: interpreter.runtime.ctx.tx, @@ -6525,11 +6525,11 @@ describe("Teal Opcodes", function () { describe("BitLen opcode", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("should work with number", () => { + it("should work with number", function () { const numbers = [0n, 1n, 2n, 4n, 5n, 8n]; const expecteds = [0n, 1n, 2n, 3n, 3n, 4n]; numbers.forEach((num, index) => { @@ -6540,7 +6540,7 @@ describe("Teal Opcodes", function () { }); }); - it("shoud work with any short byte array", () => { + it("shoud work with any short byte array", function () { const bytes = "abcd"; const op = new BitLen([], 1); @@ -6549,7 +6549,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 31n); }); - it("shoud work with a long byte array", () => { + it("shoud work with a long byte array", function () { const bytes = "f".repeat(78); const op = new BitLen([], 1); @@ -6568,7 +6568,7 @@ describe("Teal Opcodes", function () { let interpreter: Interpreter; let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { alan = new AccountStore(1e9); runtime = new Runtime([alan]); appID = runtime.deployApp( @@ -6596,7 +6596,7 @@ describe("Teal Opcodes", function () { stack = new Stack(); }); - it("should return AppApprovalProgram", () => { + it("should return AppApprovalProgram", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppApprovalProgram"], 1, interpreter); op.execute(stack); @@ -6604,7 +6604,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), parsing.stringToBytes(getProgram("counter-approval.teal"))); }); - it("should return AppClearStateProgram", () => { + it("should return AppClearStateProgram", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppClearStateProgram"], 1, interpreter); op.execute(stack); @@ -6612,7 +6612,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), parsing.stringToBytes(getProgram("clear.teal"))); }); - it("should return AppGlobalNumUint", () => { + it("should return AppGlobalNumUint", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppGlobalNumUint"], 1, interpreter); op.execute(stack); @@ -6620,7 +6620,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), BigInt(appInfo["global-state-schema"].numUint)); }); - it("should return AppGlobalNumByteSlice", () => { + it("should return AppGlobalNumByteSlice", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppGlobalNumByteSlice"], 1, interpreter); op.execute(stack); @@ -6628,7 +6628,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), BigInt(appInfo["global-state-schema"].numByteSlice)); }); - it("should return AppLocalNumUint", () => { + it("should return AppLocalNumUint", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppLocalNumUint"], 1, interpreter); op.execute(stack); @@ -6636,7 +6636,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), BigInt(appInfo["local-state-schema"].numUint)); }); - it("should return AppLocalNumByteSlice", () => { + it("should return AppLocalNumByteSlice", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppLocalNumByteSlice"], 1, interpreter); op.execute(stack); @@ -6644,7 +6644,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), BigInt(appInfo["local-state-schema"].numByteSlice)); }); - it("should return AppExtraProgramPages", () => { + it("should return AppExtraProgramPages", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppExtraProgramPages"], 1, interpreter); op.execute(stack); @@ -6652,7 +6652,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 1n); }); - it("should return AppCreator", () => { + it("should return AppCreator", function () { stack.push(BigInt(appID)); const op = new AppParamsGet(["AppCreator"], 1, interpreter); op.execute(stack); @@ -6660,7 +6660,7 @@ describe("Teal Opcodes", function () { assert.equal(encodeAddress(stack.pop() as Uint8Array), alan.address); }); - it("should return AppAddress", () => { + it("should return AppAddress", function () { const op = new AppParamsGet(["AppAddress"], 1, interpreter); stack.push(BigInt(appID)); op.execute(stack); @@ -6668,7 +6668,7 @@ describe("Teal Opcodes", function () { assert.equal(encodeAddress(stack.pop() as Uint8Array), getApplicationAddress(appID)); }); - it("return '0,0' when app is undefined", () => { + it("return '0,0' when app is undefined", function () { stack.push(10n); const op = new AppParamsGet(["AppCreator"], 1, interpreter); op.execute(stack); @@ -6676,13 +6676,13 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("Should fail number element in stack less than 1", () => { + it("Should fail number element in stack less than 1", function () { assert.equal(stack.length(), 0); const op = new AppParamsGet(["AppCreator"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("should fail when teal version is less than 5", () => { + it("should fail when teal version is less than 5", function () { const versions = [1, 2, 3, 4]; versions.forEach((version) => { interpreter.tealVersion = version; @@ -6694,7 +6694,7 @@ describe("Teal Opcodes", function () { }); }); - it("should fail when arguments invalid", () => { + it("should fail when arguments invalid", function () { stack.push(BigInt(appID)); expectRuntimeError( () => new AppParamsGet(["AppCreatorInvalid"], 1, interpreter), @@ -6714,7 +6714,7 @@ describe("Teal Opcodes", function () { return st; }; - it("Divw opcode happy cases", () => { + it("Divw opcode happy cases", function () { const op = new Divw([], 0); // 1/ 1 @@ -6731,7 +6731,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 9223372036854775808n); }); - it("Divw opcode unhappy cases", () => { + it("Divw opcode unhappy cases", function () { const op = new Divw([], 0); // div by Zero @@ -6746,7 +6746,7 @@ describe("Teal Opcodes", function () { expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.UINT64_OVERFLOW); }); - it("Bsqrt opcode happy cases", () => { + it("Bsqrt opcode happy cases", function () { const op = new Bsqrt([], 0); // should run success for case 64 bytes. const inputs = [0n, 1n, 10n, 1n << 32n, BigInt("0x" + "ff".repeat(64))]; @@ -6759,14 +6759,14 @@ describe("Teal Opcodes", function () { }); }); - it("Bsqrt opcode unhappy cases", () => { + it("Bsqrt opcode unhappy cases", function () { const op = new Bsqrt([], 0); // length of input more than 64 stack = initStack([bigintToBigEndianBytes(BigInt("0x" + "ff".repeat(100)))]); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.BYTES_LEN_EXCEEDED); }); - it("Should calculate correct cost", () => { + it("Should calculate correct cost", function () { stack.push(bigintToBigEndianBytes(0n)); const op = new Bsqrt([], 0); assert.equal(40, op.execute(stack)); @@ -6781,7 +6781,7 @@ describe("Teal Opcodes", function () { let op: AcctParamsGet; const zeroBalanceAddr = "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"; - this.beforeEach(() => { + this.beforeEach(function () { interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); [alice, bob] = interpreter.runtime.defaultAccounts(); @@ -6799,28 +6799,28 @@ describe("Teal Opcodes", function () { stack.push(decodeAddress(alice.address).publicKey); }); - it("Should return balance", () => { + it("Should return balance", function () { op = new AcctParamsGet(["AcctBalance"], 1, interpreter); op.execute(stack); assert.equal(stack.pop(), 1n); // balance > 0 assert.equal(stack.pop(), alice.balance()); }); - it("Should return min balance", () => { + it("Should return min balance", function () { op = new AcctParamsGet(["AcctMinBalance"], 1, interpreter); op.execute(stack); assert.equal(stack.pop(), 1n); // balance > 0 assert.equal(stack.pop(), BigInt(alice.minBalance)); }); - it("Should return Auth Address", () => { + it("Should return Auth Address", function () { op = new AcctParamsGet(["AcctAuthAddr"], 1, interpreter); op.execute(stack); assert.equal(stack.pop(), 1n); // balance > 0 assert.deepEqual(stack.pop(), ZERO_ADDRESS); }); - it("Shoud return Auth Address - rekey case", () => { + it("Shoud return Auth Address - rekey case", function () { // set spend key for alice is bob alice.rekeyTo(bob.address); interpreter.runtime.ctx.state.accounts.set(alice.address, alice); @@ -6830,7 +6830,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), decodeAddress(bob.address).publicKey); }); - it("Should return balance with account own zero balance", () => { + it("Should return balance with account own zero balance", function () { op = new AcctParamsGet(["AcctBalance"], 1, interpreter); stack.push(decodeAddress(zeroBalanceAddr).publicKey); op.execute(stack); @@ -6838,7 +6838,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), 0n); }); - it("Should return min balance with account own zero balance", () => { + it("Should return min balance with account own zero balance", function () { op = new AcctParamsGet(["AcctMinBalance"], 1, interpreter); stack.push(decodeAddress(zeroBalanceAddr).publicKey); op.execute(stack); @@ -6846,7 +6846,7 @@ describe("Teal Opcodes", function () { assert.equal(stack.pop(), BigInt(ALGORAND_ACCOUNT_MIN_BALANCE)); }); - it("Should return Auth Address with account own zero balance", () => { + it("Should return Auth Address with account own zero balance", function () { op = new AcctParamsGet(["AcctAuthAddr"], 1, interpreter); stack.push(decodeAddress(zeroBalanceAddr).publicKey); op.execute(stack); @@ -6854,14 +6854,14 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), ZERO_ADDRESS); }); - it("Should throw error when query unknow field", () => { + it("Should throw error when query unknow field", function () { expectRuntimeError( () => new AcctParamsGet(["Miles"], 1, interpreter), RUNTIME_ERRORS.TEAL.UNKNOWN_ACCT_FIELD ); }); - it("Should throw error if query account not in ref account list", () => { + it("Should throw error if query account not in ref account list", function () { op = new AcctParamsGet(["AcctBalance"], 1, interpreter); stack.push(decodeAddress(bob.address).publicKey); @@ -6878,7 +6878,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should throw error if top element in stack is not an address", () => { + it("Should throw error if top element in stack is not an address", function () { op = new AcctParamsGet(["AcctBalance"], 1, interpreter); stack.push(parsing.stringToBytes("ABCDE")); @@ -6889,14 +6889,14 @@ describe("Teal Opcodes", function () { describe("Tealv6: itxnas opcode", function () { let stack: Stack; let interpreter: Interpreter; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); interpreter = new Interpreter(); interpreter.tealVersion = 6; interpreter.innerTxnGroups = [[TXN_OBJ, { ...TXN_OBJ, fee: 1000 }]]; }); - it("Should succeed: query data use itxnas", () => { + it("Should succeed: query data use itxnas", function () { const op = new ITxnas(["Accounts"], 1, interpreter); stack.push(1n); op.execute(stack); @@ -6904,7 +6904,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), TXN_OBJ.apat[0]); }); - it("Should fail: not any inner tx submited", () => { + it("Should fail: not any inner tx submited", function () { interpreter.innerTxnGroups = []; const op = new ITxnas(["Accounts"], 1, interpreter); stack.push(1n); @@ -6914,7 +6914,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should fail: stack empty", () => { + it("Should fail: stack empty", function () { const op = new ITxnas(["Accounts"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); @@ -6923,7 +6923,7 @@ describe("Teal Opcodes", function () { describe("Tealv5: itxn opcode", function () { let stack: Stack; let interpreter: Interpreter; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); @@ -6937,13 +6937,13 @@ describe("Teal Opcodes", function () { }); }); - it("Should put on top of the stack logs from innerTx", () => { + it("Should put on top of the stack logs from innerTx", function () { const op = new ITxn(["Logs", "0"], 1, interpreter); op.execute(stack); assert.deepEqual(stack.pop(), parsing.stringToBytes("Hello")); }); - it("Should throw an error, no inner transaction", () => { + it("Should throw an error, no inner transaction", function () { interpreter.innerTxnGroups = []; const op = new ITxn(["Logs", "0"], 1, interpreter); expectRuntimeError( @@ -6952,7 +6952,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should throw an error, no inner transaction", () => { + it("Should throw an error, no inner transaction", function () { interpreter.innerTxnGroups = []; const op = new ITxn(["NumLogs"], 1, interpreter); expectRuntimeError( @@ -6961,7 +6961,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should put the number of logs on top of the stack", () => { + it("Should put the number of logs on top of the stack", function () { const op = new ITxn(["NumLogs"], 1, interpreter); op.execute(stack); assert.equal(1n, stack.pop()); @@ -6971,7 +6971,7 @@ describe("Teal Opcodes", function () { describe("Logs", function () { let stack: Stack; let interpreter: Interpreter; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); interpreter = new Interpreter(); interpreter.runtime = new Runtime([]); @@ -6985,18 +6985,18 @@ describe("Teal Opcodes", function () { }); }); - it("Should put on top of the stack log from group transaction", () => { + it("Should put on top of the stack log from group transaction", function () { const op = new Gitxna(["1", "Logs", "0"], 1, interpreter); op.execute(stack); assert.deepEqual(stack.pop(), parsing.stringToBytes("Monty")); }); - it("Should throw an error index out of bound", () => { + it("Should throw an error index out of bound", function () { const op = new Gitxna(["1", "Logs", "2"], 1, interpreter); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INDEX_OUT_OF_BOUND); }); - it("Should put on top of stack log from group transaction", () => { + it("Should put on top of stack log from group transaction", function () { stack.push(1n); const op = new Gitxnas(["1", "Logs"], 1, interpreter); op.execute(stack); @@ -7013,11 +7013,11 @@ describe("Teal Opcodes", function () { const toPushUrl = Buffer.from(encoded64BaseUrl, "utf-8"); const expectedBytes = new Uint8Array(Buffer.from(decoded64Base, "utf-8")); - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("Should decode base64 encoded data and push it to stack", () => { + it("Should decode base64 encoded data and push it to stack", function () { stack.push(toPushUrl); const opUrl = new Base64Decode(["URLEncoding"], 0); opUrl.execute(stack); @@ -7028,24 +7028,24 @@ describe("Teal Opcodes", function () { assert.deepEqual(expectedBytes, stack.pop()); }); - it("Should throw an error when last stack element is not base64 encoded", () => { + it("Should throw an error when last stack element is not base64 encoded", function () { stack.push(new Uint8Array(Buffer.from(encoded64BaseUrl, "utf-8"))); const op = new Base64Decode(["StdEncoding"], 0); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_BASE64); }); - it("Should throw an error when last stack element is not base64Url encoded", () => { + it("Should throw an error when last stack element is not base64Url encoded", function () { stack.push(new Uint8Array(Buffer.from(encoded64BaseStd, "utf-8"))); const op = new Base64Decode(["URLEncoding"], 0); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.INVALID_BASE64URL); }); - it("Should throw an error when the stack is empty", () => { + it("Should throw an error when the stack is empty", function () { const op = new Base64Decode(["StdEncoding"], 0); expectRuntimeError(() => op.execute(stack), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH); }); - it("Should throw an error when argument not in bound", () => { + it("Should throw an error when argument not in bound", function () { stack.push(toPushStd); expectRuntimeError( () => new Base64Decode(["3"], 0), @@ -7053,7 +7053,7 @@ describe("Teal Opcodes", function () { ); }); - it("Should calculate the correct cost", () => { + it("Should calculate the correct cost", function () { let toPush = Buffer.from("", "utf-8"); stack.push(toPush); let op = new Base64Decode(["URLEncoding"], 0); @@ -7088,7 +7088,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(6, cost); // base64_decode cost = 6 (68 bytes -> 1 + ceil(68/16)) }); - it("Should throw an error when argument not provided", () => { + it("Should throw an error when argument not provided", function () { stack.push(toPushStd); expectRuntimeError(() => new Base64Decode([], 0), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH); }); @@ -7096,11 +7096,11 @@ describe("Teal Opcodes", function () { describe("Tealv7: replace2 opcode", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("Should replace bytes correctly", () => { + it("Should replace bytes correctly", function () { const original = "0x11111111"; const replace = "0x2222"; let hexStr = "0x22221111"; @@ -7136,11 +7136,11 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), expectedRemain); //check if the remaining data in the stack are stay the same }); - it("Should throw an error when argument not provided", () => { + it("Should throw an error when argument not provided", function () { expectRuntimeError(() => new Replace2([], 0), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH); }); - it("Should throw error for wrong index replace", () => { + it("Should throw error for wrong index replace", function () { const original = "0x11111111"; const replace = "0x2222"; stack.push(strHexToBytes(original)); @@ -7152,11 +7152,11 @@ describe("Teal Opcodes", function () { describe("Tealv7: replace3 opcode", function () { let stack: Stack; - this.beforeEach(() => { + this.beforeEach(function () { stack = new Stack(); }); - it("Should replace bytes correctly", () => { + it("Should replace bytes correctly", function () { const original = "0x11111111"; const replace = "0x2222"; let hexStr = "0x22221111"; @@ -7195,7 +7195,7 @@ describe("Teal Opcodes", function () { assert.deepEqual(stack.pop(), expectedRemain); //check if the remaining data in the stack are stay the same }); - it("Should throw error for wrong index replace", () => { + it("Should throw error for wrong index replace", function () { const original = "0x11111111"; const replace = "0x2222"; stack.push(strHexToBytes(original)); @@ -7234,7 +7234,7 @@ describe("Teal Opcodes", function () { execExpectError(stack, [], new Sha3_256([], 1), RUNTIME_ERRORS.TEAL.ASSERT_STACK_LENGTH) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { stack.push(parsing.stringToBytes("MESSAGE")); const op = new Sha3_256([], 1); assert.equal(130, op.execute(stack)); @@ -7298,7 +7298,7 @@ describe("Teal Opcodes", function () { ) ); - it("Should return correct cost", () => { + it("Should return correct cost", function () { const account = generateAccount(); const data = new Uint8Array(Buffer.from([1, 9, 25, 49])); const signature = signBytes(data, account.sk); @@ -7312,7 +7312,7 @@ describe("Teal Opcodes", function () { }); }); - describe("json_ref", () => { + describe("json_ref", function () { const stack = new Stack(); const jsonByte = '{"key0": 0,"key1": "algo","key2":{"key3": "teal", "key4": {"key40": 10}}, "key5": 18446744073709551615 }'; diff --git a/packages/runtime/test/src/lib/asa.ts b/packages/runtime/test/src/lib/asa.ts index a464b25dd..05e5e9220 100644 --- a/packages/runtime/test/src/lib/asa.ts +++ b/packages/runtime/test/src/lib/asa.ts @@ -13,8 +13,8 @@ const namedAccount: Account = { sk: new Uint8Array(1), }; -describe("ASA parser", () => { - it("Should validate correct obj", async () => { +describe("ASA parser", function () { + it("Should validate correct obj", async function () { const asaUrl = "u".repeat(96); const valid: types.ASADefs = { A1: { @@ -44,7 +44,7 @@ describe("ASA parser", () => { }); }); - it("Should validate all parameters", async () => { + it("Should validate all parameters", async function () { const valid = { A1: { total: 213, @@ -81,7 +81,7 @@ describe("ASA parser", () => { }); }); - it("Should check total to be a number", async () => { + it("Should check total to be a number", async function () { const obj = { A1: { total: "hi", @@ -97,7 +97,7 @@ describe("ASA parser", () => { ); }); - it("Should accept ASA with total == 0", async () => { + it("Should accept ASA with total == 0", async function () { const obj = { A1: { total: 0, @@ -109,7 +109,7 @@ describe("ASA parser", () => { assert.doesNotThrow(() => validateASADefs(obj, new Map(), "")); }); - it("Should check total to be a positive number <= 2^64 - 1", async () => { + it("Should check total to be a positive number <= 2^64 - 1", async function () { let obj = { A1: { total: 0xffffffffffffffffn + 5n, @@ -137,7 +137,7 @@ describe("ASA parser", () => { ); }); - it("Should include filename", async () => { + it("Should include filename", async function () { const obj = { A1: { total: "hi", @@ -153,7 +153,7 @@ describe("ASA parser", () => { ); }); - it("Should validate decimals", async () => { + it("Should validate decimals", async function () { const obj = { A1: { total: 1, @@ -169,7 +169,7 @@ describe("ASA parser", () => { ); }); - it("Should validate unitName; too long", async () => { + it("Should validate unitName; too long", async function () { const obj = { A1: { total: 1, @@ -185,7 +185,7 @@ describe("ASA parser", () => { ); }); - it("Should validate url; too long", async () => { + it("Should validate url; too long", async function () { const obj = { A1: { total: 1, @@ -203,7 +203,7 @@ describe("ASA parser", () => { ); }); - it("Should validate metadataHash", async () => { + it("Should validate metadataHash", async function () { /** negative paths **/ // check utf-8 strings @@ -282,7 +282,7 @@ describe("ASA parser", () => { ); }); - it("Should check existence of opt-in account name accounts; green path", async () => { + it("Should check existence of opt-in account name accounts; green path", async function () { const obj = { A1: { total: 1, @@ -295,7 +295,7 @@ describe("ASA parser", () => { validateASADefs(obj, new Map([["hi", namedAccount]]), ""); }); - it("Should check existence of opt-in account name accounts; empty", async () => { + it("Should check existence of opt-in account name accounts; empty", async function () { const obj = { A1: { total: 1, @@ -308,7 +308,7 @@ describe("ASA parser", () => { validateASADefs(obj, new Map([["hi", namedAccount]]), ""); }); - it("Should fail if opt-in account doesn't exist", async () => { + it("Should fail if opt-in account doesn't exist", async function () { const obj = { A1: { total: 1, diff --git a/packages/runtime/test/src/lib/math.ts b/packages/runtime/test/src/lib/math.ts index d6be97c0c..42bf07ad4 100644 --- a/packages/runtime/test/src/lib/math.ts +++ b/packages/runtime/test/src/lib/math.ts @@ -3,7 +3,7 @@ import { assert } from "chai"; import { bigintSqrt } from "../../../src/lib/math"; describe("Math package", function () { - it("sqrt function", () => { + it("sqrt function", function () { const inputs = [4n, 10n, 25n, BigInt(1e8), 1n << 64n, (1n << 64n) - 1n]; const outputs = [2n, 3n, 5n, BigInt(1e4), 1n << 32n, (1n << 32n) - 1n]; inputs.forEach((value, index) => { diff --git a/packages/runtime/test/src/lib/parsing.ts b/packages/runtime/test/src/lib/parsing.ts index a58925c9e..02da53763 100644 --- a/packages/runtime/test/src/lib/parsing.ts +++ b/packages/runtime/test/src/lib/parsing.ts @@ -10,7 +10,7 @@ import { convertToString, } from "../../../src/lib/parsing"; -describe("Convert integer to big endian", () => { +describe("Convert integer to big endian", function () { /** * Note: Expected results are derived from following go code * v := uint64(number) @@ -18,7 +18,7 @@ describe("Convert integer to big endian", () => { * binary.BigEndian.PutUint64(buf, v) * fmt.Println(buf) */ - it("should return correct big endian for 64 bit integer", () => { + it("should return correct big endian for 64 bit integer", function () { let res = parsing.uint64ToBigEndian(0); let expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); assert.deepEqual(res, expected); @@ -62,7 +62,7 @@ describe("Convert integer to big endian", () => { }); /* eslint-disable max-len */ - it("should return correct big endian bytes from bigint", () => { + it("should return correct big endian bytes from bigint", function () { let res = bigintToBigEndianBytes(MIN_UINT64); let expected = new Uint8Array([0]); // this is not "strict" uintN byte conversion, so 0 is parsed as new Uint8array([0]) assert.deepEqual(res, expected); @@ -103,7 +103,7 @@ describe("Convert integer to big endian", () => { assert.deepEqual(res, expected); }); - it("should return correct bigint value from big endian bytes", () => { + it("should return correct bigint value from big endian bytes", function () { let res = bigEndianBytesToBigInt(new Uint8Array([0])); let expected = 0n; assert.deepEqual(res, expected); @@ -130,7 +130,7 @@ describe("Convert integer to big endian", () => { assert.deepEqual(res, expected); }); - it("should throw error if value is not uint64", () => { + it("should throw error if value is not uint64", function () { let errMsg = "Invalid uint64 -5"; assert.throws(() => parsing.uint64ToBigEndian(MIN_UINT64 - 5n), errMsg); @@ -139,8 +139,8 @@ describe("Convert integer to big endian", () => { }); }); -describe("Parse string and integer, with bytes", () => { - it("string identity should be equal ", () => { +describe("Parse string and integer, with bytes", function () { + it("string identity should be equal ", function () { let initialString = "50"; let stringInBytes = parsing.stringToBytes(initialString); let backToString = convertToString(stringInBytes); @@ -155,19 +155,19 @@ describe("Parse string and integer, with bytes", () => { }); }); -describe("Parse appArgs to App to bytes", () => { - it("should return undefined if app Args are not defined", () => { +describe("Parse appArgs to App to bytes", function () { + it("should return undefined if app Args are not defined", function () { const res = parsing.parseAppArgs(undefined); assert.isUndefined(res); }); - it("should return same bytes if all bytes are passed", () => { + it("should return same bytes if all bytes are passed", function () { const res = parsing.parseAppArgs(["a", "b", "c"].map(parsing.stringToBytes)); const expected = [[97], [98], [99]].map((z) => new Uint8Array(z)); assert.deepEqual(res, expected); }); - it("should return correct bytes if args are passed similar to goal", () => { + it("should return correct bytes if args are passed similar to goal", function () { let res = parsing.parseAppArgs(["int:700000000", "int:3", `int:${MAX_UINT64}`]); let expected = [ [0, 0, 0, 0, 41, 185, 39, 0], @@ -199,7 +199,7 @@ describe("Parse appArgs to App to bytes", () => { assert.deepEqual(res, expected); }); - it("should throw error if passed args are invalid", () => { + it("should throw error if passed args are invalid", function () { const errMsg = (str: string): string => { return `Format of arguments passed to stateful smart is invalid for ${str}`; }; @@ -217,8 +217,8 @@ describe("Parse appArgs to App to bytes", () => { assert.throws(() => parsing.parseAppArgs([`int:${MAX_UINT64 + 10n}`]), errorMsg); }); }); -describe("utils", () => { - it("Should concat two arrays", () => { +describe("utils", function () { + it("Should concat two arrays", function () { const arr1 = new Uint8Array([1, 2]); const arr2 = new Uint8Array([3, 4]); const expectedResult = new Uint8Array([1, 2, 3, 4]); diff --git a/packages/runtime/test/src/lib/txn.ts b/packages/runtime/test/src/lib/txn.ts index c360b9b5a..d4839c9ea 100644 --- a/packages/runtime/test/src/lib/txn.ts +++ b/packages/runtime/test/src/lib/txn.ts @@ -16,7 +16,7 @@ describe("Convert encoded Txn to ExecParams", function () { let runtime: Runtime; let execParams: types.ExecParams; - this.beforeEach(() => { + this.beforeEach(function () { john = new AccountStore(1e9); smith = new AccountStore(1e9); @@ -66,7 +66,7 @@ describe("Convert encoded Txn to ExecParams", function () { } describe("Case pay transaction types", function () { - it("Should convert SDK Payment Txn(pay) to ExecParams(TransferAlgo)", () => { + it("Should convert SDK Payment Txn(pay) to ExecParams(TransferAlgo)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -87,7 +87,7 @@ describe("Convert encoded Txn to ExecParams", function () { describe("Case acfg,axfer,afrz transaction types", function () { useFixture("asa-check"); - it("Should convert SDK Deploy ASA Txn to ExecParams(DeployASA)", () => { + it("Should convert SDK Deploy ASA Txn to ExecParams(DeployASA)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -101,7 +101,7 @@ describe("Convert encoded Txn to ExecParams", function () { assertEncTxConvertedToExecParam(runtime, execParams); }); - it("Should convert SDK FreezeAsset ASA Txn to ExecParams(FreezeAsset)", () => { + it("Should convert SDK FreezeAsset ASA Txn to ExecParams(FreezeAsset)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -116,7 +116,7 @@ describe("Convert encoded Txn to ExecParams", function () { assertEncTxConvertedToExecParam(runtime, execParams); }); - it("Should convert SDK Transfer ASA Txn to ExecParams(TransferAsset)", () => { + it("Should convert SDK Transfer ASA Txn to ExecParams(TransferAsset)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -132,7 +132,7 @@ describe("Convert encoded Txn to ExecParams", function () { assertEncTxConvertedToExecParam(runtime, execParams); }); - it("Should convert SDK Destroy ASA Txn to ExecParams(DestroyAsset)", () => { + it("Should convert SDK Destroy ASA Txn to ExecParams(DestroyAsset)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -146,7 +146,7 @@ describe("Convert encoded Txn to ExecParams", function () { assertEncTxConvertedToExecParam(runtime, execParams); }); - it("Should convert SDK Modify ASA Txn to ExecParams(ModifyAsset)", () => { + it("Should convert SDK Modify ASA Txn to ExecParams(ModifyAsset)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -168,7 +168,7 @@ describe("Convert encoded Txn to ExecParams", function () { }); describe("Case keyreg transaction type", function () { - it("should convert SDK Keyreg Txn to ExecParams(KeyRegistration)", () => { + it("should convert SDK Keyreg Txn to ExecParams(KeyRegistration)", function () { execParams = { type: types.TransactionType.KeyRegistration, // payment sign: types.SignType.SecretKey, @@ -187,7 +187,7 @@ describe("Convert encoded Txn to ExecParams", function () { describe("Case appl transaction type", function () { useFixture("stateful"); - it("should convert SDK Deploy Application Txn to ExecParams(DeployApp)", () => { + it("should convert SDK Deploy Application Txn to ExecParams(DeployApp)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, @@ -210,7 +210,7 @@ describe("Convert encoded Txn to ExecParams", function () { assertEncTxConvertedToExecParam(runtime, execParams); }); - it("should convert SDK NoOpt Txn to ExecParams(CallApp)", () => { + it("should convert SDK NoOpt Txn to ExecParams(CallApp)", function () { execParams = { sign: types.SignType.SecretKey, fromAccount: john.account, diff --git a/packages/runtime/test/src/logicsig.ts b/packages/runtime/test/src/logicsig.ts index 12af4c070..9490820a4 100644 --- a/packages/runtime/test/src/logicsig.ts +++ b/packages/runtime/test/src/logicsig.ts @@ -13,7 +13,7 @@ const programName = "escrow.teal"; const multiSigProg = "sample-asc.teal"; const crowdFundEscrow = "crowdFundEscrow.teal"; -describe("Logic Signature", () => { +describe("Logic Signature", function () { useFixture("escrow-account"); let john: AccountStore; let bob: AccountStore; @@ -30,7 +30,7 @@ describe("Logic Signature", () => { let appDefinition: any; let applicationId: any; - before(() => { + before(function () { john = new AccountStore(10); bob = new AccountStore(10e6); runtime = new Runtime([john, bob]); @@ -64,14 +64,14 @@ describe("Logic Signature", () => { }; }); - it("john should be able to create a delegated signature", () => { + it("john should be able to create a delegated signature", function () { const lsig = runtime.loadLogic(programName); lsig.sign(john.account.sk); assert.isTrue(lsig.lsig.verify(johnPk)); }); - it("should fail to verify delegated signature signed by someone else", () => { + it("should fail to verify delegated signature signed by someone else", function () { const lsig = runtime.loadLogic(programName); lsig.sign(bob.account.sk); @@ -80,7 +80,7 @@ describe("Logic Signature", () => { assert.equal(result, false); }); - it("should handle contract lsig (escrow account) verification correctly", () => { + it("should handle contract lsig (escrow account) verification correctly", function () { const lsig = runtime.loadLogic(programName); let result = lsig.lsig.verify(decodeAddress(lsig.address()).publicKey); @@ -90,14 +90,14 @@ describe("Logic Signature", () => { assert.equal(result, false); }); - it("should fail if empty program is passed", () => { + it("should fail if empty program is passed", function () { expectRuntimeError( () => runtime.createLsigAccount("", []), RUNTIME_ERRORS.GENERAL.INVALID_PROGRAM ); }); - it("should return same address for same program", () => { + it("should return same address for same program", function () { let lsig = runtime.loadLogic(programName); const addr = lsig.address(); @@ -106,7 +106,7 @@ describe("Logic Signature", () => { assert.equal(lsig.address(), addr); }); - it("Should handle contract lsig (escrow account) verification correctly with empty smart contract params", () => { + it("Should handle contract lsig (escrow account) verification correctly with empty smart contract params", function () { // empty smart contract param with teal const lsig = runtime.loadLogic(programName, {}); @@ -117,7 +117,7 @@ describe("Logic Signature", () => { assert.equal(result, false); }); - it("Should handle contract lsig (crowd fund escrow account) verification correctly with non-empty smart contract params", () => { + it("Should handle contract lsig (crowd fund escrow account) verification correctly with non-empty smart contract params", function () { // create application applicationId = runtime.deployApp( bob.account, @@ -136,7 +136,7 @@ describe("Logic Signature", () => { }); }); -describe("Multi-Signature Test", () => { +describe("Multi-Signature Test", function () { useFixture("multi-signature"); let alice: AccountStore; let john: AccountStore; @@ -151,7 +151,7 @@ describe("Multi-Signature Test", () => { // initialized in these hooks // eg. during new Runtime([..]).loadASAFile, path(cwd) to fetch asa.yaml file // is correct. - before(() => { + before(function () { alice = new AccountStore(10); john = new AccountStore(100); bob = new AccountStore(1000); @@ -169,7 +169,7 @@ describe("Multi-Signature Test", () => { multisigAddr = multisigAddress(mparams); }); - it("should verify if threshold is verified and sender is multisigAddr", () => { + it("should verify if threshold is verified and sender is multisigAddr", function () { const lsig = runtime.loadLogic(multiSigProg); // lsig signed by alice lsig.signMultisig(mparams, alice.account.sk); @@ -180,7 +180,7 @@ describe("Multi-Signature Test", () => { assert.equal(result, true); }); - it("should not verify if threshold is achieved but sender is not multisigAddr", () => { + it("should not verify if threshold is achieved but sender is not multisigAddr", function () { const lsig = runtime.loadLogic(multiSigProg); // lsig signed by alice lsig.signMultisig(mparams, alice.account.sk); @@ -191,7 +191,7 @@ describe("Multi-Signature Test", () => { assert.equal(result, false); }); - it("should not verify if threshold is not achieved but sender is multisigAddr", () => { + it("should not verify if threshold is not achieved but sender is multisigAddr", function () { const lsig = runtime.loadLogic(multiSigProg); // lsig signed by alice lsig.signMultisig(mparams, alice.account.sk); diff --git a/packages/runtime/test/src/parser/parser.ts b/packages/runtime/test/src/parser/parser.ts index 08cff9471..d8e531a94 100644 --- a/packages/runtime/test/src/parser/parser.ts +++ b/packages/runtime/test/src/parser/parser.ts @@ -137,7 +137,7 @@ import { expectRuntimeError } from "../../helpers/runtime-errors"; // base64 case needs to be verified at the time of decoding describe("Parser", function () { - describe("Extract words from line", () => { + describe("Extract words from line", function () { it("should return correct words for addr", function () { let res = wordsFromLine("addr KAGKGFFKGKGFGLFFBSLFBJKSFB"); const expected = ["addr", "KAGKGFFKGKGFGLFFBSLFBJKSFB"]; @@ -157,7 +157,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct words for byte base64", () => { + it("should return correct words for byte base64", function () { let res = wordsFromLine("byte base64 BKBDKSKDK"); let expected = ["byte", "base64", "BKBDKSKDK"]; @@ -185,7 +185,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct words for byte base32", () => { + it("should return correct words for byte base32", function () { let res = wordsFromLine("byte base32 BKBDKSKDK//commenthere"); let expected = ["byte", "base32", "BKBDKSKDK"]; @@ -207,7 +207,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct words for byte string literal", () => { + it("should return correct words for byte string literal", function () { let res = wordsFromLine('byte "STRING LITERAL"'); let expected = ["byte", '"STRING LITERAL"']; @@ -219,7 +219,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct words for int", () => { + it("should return correct words for int", function () { let res = wordsFromLine("int 123"); const expected = ["int", "123"]; @@ -235,7 +235,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct words for operators", () => { + it("should return correct words for operators", function () { let res = wordsFromLine("+"); let expected = ["+"]; @@ -269,7 +269,7 @@ describe("Parser", function () { // more edge cases // space before parentheses, // space after base64: base64 (xxx ), base64( xxx) .. - it("should extract correct words from line", () => { + it("should extract correct words from line", function () { let res = wordsFromLine("base64 (abcd)"); let expected = ["base64", "(abcd)"]; @@ -296,7 +296,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should extract correct words from line", () => { + it("should extract correct words from line", function () { let res = wordsFromLine("arg 1//comment here"); let expected = ["arg", "1"]; @@ -353,7 +353,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should extract correct stateful words", () => { + it("should extract correct stateful words", function () { let res = wordsFromLine("app_opted_in//comment here"); let expected = ["app_opted_in"]; @@ -376,7 +376,7 @@ describe("Parser", function () { }); }); - describe("Opcode Objects from words", () => { + describe("Opcode Objects from words", function () { let interpreter: Interpreter; beforeEach(function () { interpreter = new Interpreter(); @@ -384,63 +384,63 @@ describe("Parser", function () { interpreter.runtime = new Runtime([]); }); - it("should return correct opcode object for '+'", () => { + it("should return correct opcode object for '+'", function () { const res = opcodeFromSentence(["+"], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Add([], 1); assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for '+'", () => { + it("should throw error for wrong field length for '+'", function () { expectRuntimeError( () => opcodeFromSentence(["+", "+"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should return correct opcode object for '-'", () => { + it("should return correct opcode object for '-'", function () { const res = opcodeFromSentence(["-"], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Sub([], 1); assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for '-'", () => { + it("should throw error for wrong field length for '-'", function () { expectRuntimeError( () => opcodeFromSentence(["-", "-"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should return correct opcode object for '/'", () => { + it("should return correct opcode object for '/'", function () { const res = opcodeFromSentence(["/"], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Div([], 1); assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for '/'", () => { + it("should throw error for wrong field length for '/'", function () { expectRuntimeError( () => opcodeFromSentence(["/", "/"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should return correct opcode object for '*'", () => { + it("should return correct opcode object for '*'", function () { const res = opcodeFromSentence(["*"], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Mul([], 1); assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for '*'", () => { + it("should throw error for wrong field length for '*'", function () { expectRuntimeError( () => opcodeFromSentence(["*", "*"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should return correct opcode object for 'addr'", () => { + it("should return correct opcode object for 'addr'", function () { const address = "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"; const res = opcodeFromSentence( ["addr", address], @@ -453,21 +453,21 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for 'addr'", () => { + it("should throw error for wrong field length for 'addr'", function () { expectRuntimeError( () => opcodeFromSentence(["addr"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should throw error for invalid address for 'addr'", () => { + it("should throw error for invalid address for 'addr'", function () { expectRuntimeError( () => opcodeFromSentence(["addr", "AKGH12"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.INVALID_ADDR ); }); - it("can use prefix 0x(hex) with 'int'", () => { + it("can use prefix 0x(hex) with 'int'", function () { const valueInHex = "0x02"; const res = opcodeFromSentence( ["int", valueInHex], @@ -479,7 +479,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("can use prefix 0(oct) with 'int'", () => { + it("can use prefix 0(oct) with 'int'", function () { const valueInHex = "010"; const res = opcodeFromSentence( ["int", valueInHex], @@ -491,7 +491,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode object for 'int'", () => { + it("should return correct opcode object for 'int'", function () { const value = "812546821"; const res = opcodeFromSentence(["int", value], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Int([value], 1); @@ -499,7 +499,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should work when int arg is zero", () => { + it("should work when int arg is zero", function () { const value = "0"; const res = opcodeFromSentence(["int", value], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Int([value], 1); @@ -507,14 +507,14 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should throw error for wrong field length for 'int'", () => { + it("should throw error for wrong field length for 'int'", function () { expectRuntimeError( () => opcodeFromSentence(["int"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH ); }); - it("should throw error for invalid number for 'int'", () => { + it("should throw error for invalid number for 'int'", function () { expectRuntimeError( () => opcodeFromSentence(["int", "123A12"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.INVALID_TYPE @@ -568,21 +568,21 @@ describe("Parser", function () { ); }); - it("should return correct label", () => { + it("should return correct label", function () { const res = opcodeFromSentence(["label:"], 1, interpreter, ExecutionMode.SIGNATURE); const expected = new Label(["label:"], 1); assert.deepEqual(res, expected); }); - it("should throw error if wrong label is used", () => { + it("should throw error if wrong label is used", function () { expectRuntimeError( () => opcodeFromSentence(["substring:"], 1, interpreter, ExecutionMode.SIGNATURE), RUNTIME_ERRORS.TEAL.INVALID_LABEL ); }); - it("should return correct objects for `txn`", () => { + it("should return correct objects for `txn`", function () { let res = opcodeFromSentence(["txn", "Fee"], 1, interpreter, ExecutionMode.SIGNATURE); let expected = new Txn(["Fee"], 1, interpreter); assert.deepEqual(res, expected); @@ -617,7 +617,7 @@ describe("Parser", function () { ); }); - it("should return correct object for `gtxn`", () => { + it("should return correct object for `gtxn`", function () { let res = opcodeFromSentence( ["gtxn", "0", "Fee"], 1, @@ -648,7 +648,7 @@ describe("Parser", function () { ); }); - it("should return correct object for `txna`", () => { + it("should return correct object for `txna`", function () { let res = opcodeFromSentence( ["txna", "Accounts", "0"], 1, @@ -683,7 +683,7 @@ describe("Parser", function () { ); }); - it("should return correct object for `gtxna`", () => { + it("should return correct object for `gtxna`", function () { let res = opcodeFromSentence( ["gtxna", "1", "Accounts", "1"], 1, @@ -736,7 +736,7 @@ describe("Parser", function () { ); }); - it("should return correct objects for `global`", () => { + it("should return correct objects for `global`", function () { let res = opcodeFromSentence( ["global", "MinTxnFee"], 1, @@ -856,7 +856,7 @@ describe("Parser", function () { ); }); - it("should return correct opcodes for `Balance` and `Asset` opcodes", () => { + it("should return correct opcodes for `Balance` and `Asset` opcodes", function () { let res = opcodeFromSentence(["balance"], 1, interpreter, ExecutionMode.APPLICATION); let expected = new Balance([], 1, interpreter); assert.deepEqual(res, expected); @@ -918,7 +918,7 @@ describe("Parser", function () { ); }); - it("TEALv5: should throw error for Asset Creator if LogicSigVersion < 5", () => { + it("TEALv5: should throw error for Asset Creator if LogicSigVersion < 5", function () { interpreter.tealVersion = 4; expectRuntimeError( () => @@ -932,7 +932,7 @@ describe("Parser", function () { ); }); - it("should return correct opcodes for Stateful opcodes", () => { + it("should return correct opcodes for Stateful opcodes", function () { let res = opcodeFromSentence(["app_opted_in"], 1, interpreter, ExecutionMode.APPLICATION); let expected = new AppOptedIn([], 1, interpreter); assert.deepEqual(res, expected); @@ -1069,8 +1069,8 @@ describe("Parser", function () { ); }); - describe("should return correct opcodes for tealv3 ops", () => { - it("assert", () => { + describe("should return correct opcodes for tealv3 ops", function () { + it("assert", function () { const res = opcodeFromSentence(["assert"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Assert([], 1); assert.deepEqual(res, expected); @@ -1082,7 +1082,7 @@ describe("Parser", function () { ); }); - it("pushint", () => { + it("pushint", function () { const res = opcodeFromSentence( ["pushint", "345"], 1, @@ -1122,7 +1122,7 @@ describe("Parser", function () { ); }); - it("pushbytes", () => { + it("pushbytes", function () { const res = opcodeFromSentence( ["pushbytes", `"Algorand"`], 1, @@ -1155,7 +1155,7 @@ describe("Parser", function () { ); }); - it("swap", () => { + it("swap", function () { const res = opcodeFromSentence(["swap"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Swap([], 1); assert.deepEqual(res, expected); @@ -1166,7 +1166,7 @@ describe("Parser", function () { ); }); - it("txn fields", () => { + it("txn fields", function () { let res = opcodeFromSentence( ["txn", "Assets", "1"], 1, @@ -1270,7 +1270,7 @@ describe("Parser", function () { ); }); - it("getbit", () => { + it("getbit", function () { const res = opcodeFromSentence(["getbit"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new GetBit([], 1); assert.deepEqual(res, expected); @@ -1282,7 +1282,7 @@ describe("Parser", function () { ); }); - it("setbit", () => { + it("setbit", function () { const res = opcodeFromSentence(["setbit"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new SetBit([], 1); assert.deepEqual(res, expected); @@ -1294,7 +1294,7 @@ describe("Parser", function () { ); }); - it("getbyte", () => { + it("getbyte", function () { const res = opcodeFromSentence(["getbyte"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new GetByte([], 1); assert.deepEqual(res, expected); @@ -1306,7 +1306,7 @@ describe("Parser", function () { ); }); - it("setbyte", () => { + it("setbyte", function () { const res = opcodeFromSentence(["setbyte"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new SetByte([], 1); assert.deepEqual(res, expected); @@ -1318,7 +1318,7 @@ describe("Parser", function () { ); }); - it("dig", () => { + it("dig", function () { const res = opcodeFromSentence(["dig", "2"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Dig(["2"], 1); assert.deepEqual(res, expected); @@ -1335,7 +1335,7 @@ describe("Parser", function () { ); }); - it("select", () => { + it("select", function () { const res = opcodeFromSentence(["select"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Select([], 1); assert.deepEqual(res, expected); @@ -1347,7 +1347,7 @@ describe("Parser", function () { ); }); - it("gtxns", () => { + it("gtxns", function () { const res = opcodeFromSentence( ["gtxns", "Amount"], 1, @@ -1376,7 +1376,7 @@ describe("Parser", function () { ); }); - it("gtxnsa", () => { + it("gtxnsa", function () { const res = opcodeFromSentence( ["gtxnsa", "ApplicationArgs", "0"], 1, @@ -1410,7 +1410,7 @@ describe("Parser", function () { ); }); - it("min_balance", () => { + it("min_balance", function () { const res = opcodeFromSentence( ["min_balance"], 1, @@ -1433,8 +1433,8 @@ describe("Parser", function () { }); }); - describe("should return correct opcodes for tealv4 ops", () => { - it("gload", () => { + describe("should return correct opcodes for tealv4 ops", function () { + it("gload", function () { const res = opcodeFromSentence( ["gload", "0", "1"], 1, @@ -1461,7 +1461,7 @@ describe("Parser", function () { ); }); - it("gloads", () => { + it("gloads", function () { const res = opcodeFromSentence( ["gloads", "0"], 1, @@ -1484,7 +1484,7 @@ describe("Parser", function () { ); }); - it("callsub", () => { + it("callsub", function () { const res = opcodeFromSentence( ["callsub", "label"], 1, @@ -1507,7 +1507,7 @@ describe("Parser", function () { ); }); - it("retsub", () => { + it("retsub", function () { const res = opcodeFromSentence(["retsub"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Retsub([], 1, interpreter); @@ -1519,7 +1519,7 @@ describe("Parser", function () { ); }); - it("gaid", () => { + it("gaid", function () { const res = opcodeFromSentence( ["gaid", "2"], 1, @@ -1537,7 +1537,7 @@ describe("Parser", function () { ); }); - it("gaids", () => { + it("gaids", function () { const res = opcodeFromSentence(["gaids"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Gaids([], 1, interpreter); @@ -1550,7 +1550,7 @@ describe("Parser", function () { ); }); - it("divmodw", () => { + it("divmodw", function () { const res = opcodeFromSentence(["divmodw"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new DivModw([], 1); @@ -1562,7 +1562,7 @@ describe("Parser", function () { ); }); - it("exp", () => { + it("exp", function () { const res = opcodeFromSentence(["exp"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Exp([], 1); @@ -1574,7 +1574,7 @@ describe("Parser", function () { ); }); - it("expw", () => { + it("expw", function () { const res = opcodeFromSentence(["expw"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Expw([], 1); @@ -1586,7 +1586,7 @@ describe("Parser", function () { ); }); - it("shl", () => { + it("shl", function () { const res = opcodeFromSentence(["shl"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Shl([], 1); @@ -1598,7 +1598,7 @@ describe("Parser", function () { ); }); - it("shr", () => { + it("shr", function () { const res = opcodeFromSentence(["shr"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Shr([], 1); @@ -1610,7 +1610,7 @@ describe("Parser", function () { ); }); - it("sqrt", () => { + it("sqrt", function () { const res = opcodeFromSentence(["sqrt"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Sqrt([], 1); @@ -1622,7 +1622,7 @@ describe("Parser", function () { ); }); - it("bitlen", () => { + it("bitlen", function () { const res = opcodeFromSentence(["bitlen"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new BitLen([], 1); assert.deepEqual(res, expected); @@ -1633,7 +1633,7 @@ describe("Parser", function () { ); }); - it("bsqrt", () => { + it("bsqrt", function () { const res = opcodeFromSentence(["bsqrt"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Sqrt([], 1); @@ -1646,8 +1646,8 @@ describe("Parser", function () { }); }); - describe("should return correct opcodes for tealv5 ops", () => { - it("extract", () => { + describe("should return correct opcodes for tealv5 ops", function () { + it("extract", function () { const res = opcodeFromSentence( ["extract", "1", "2"], 1, @@ -1664,7 +1664,7 @@ describe("Parser", function () { ); }); - it("extract3", () => { + it("extract3", function () { const res = opcodeFromSentence(["extract3"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Extract3([], 1); @@ -1677,7 +1677,7 @@ describe("Parser", function () { ); }); - it("extract_uint16", () => { + it("extract_uint16", function () { const res = opcodeFromSentence( ["extract_uint16"], 1, @@ -1700,7 +1700,7 @@ describe("Parser", function () { ); }); - it("extract_uint32", () => { + it("extract_uint32", function () { const res = opcodeFromSentence( ["extract_uint32"], 1, @@ -1723,7 +1723,7 @@ describe("Parser", function () { ); }); - it("extract_uint64", () => { + it("extract_uint64", function () { const res = opcodeFromSentence( ["extract_uint64"], 1, @@ -1747,8 +1747,8 @@ describe("Parser", function () { }); }); - describe("Tealv5: ECDSA opcodes", () => { - it("ecdsa_verify", () => { + describe("Tealv5: ECDSA opcodes", function () { + it("ecdsa_verify", function () { const res = opcodeFromSentence( ["ecdsa_verify", "0"], 1, @@ -1765,7 +1765,7 @@ describe("Parser", function () { ); }); - it("ecdsa_pk_decompress", () => { + it("ecdsa_pk_decompress", function () { const res = opcodeFromSentence( ["ecdsa_pk_decompress", "0"], 1, @@ -1788,7 +1788,7 @@ describe("Parser", function () { ); }); - it("ecdsa_pk_recover", () => { + it("ecdsa_pk_recover", function () { const res = opcodeFromSentence( ["ecdsa_pk_recover", "0"], 1, @@ -1807,8 +1807,8 @@ describe("Parser", function () { }); }); - describe("should return correct opcodes for tealv5 ops", () => { - it("loads", () => { + describe("should return correct opcodes for tealv5 ops", function () { + it("loads", function () { const res = opcodeFromSentence(["loads"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Loads([], 1, interpreter); @@ -1820,7 +1820,7 @@ describe("Parser", function () { ); }); - it("stores", () => { + it("stores", function () { const res = opcodeFromSentence(["stores"], 1, interpreter, ExecutionMode.APPLICATION); const expected = new Stores([], 1, interpreter); @@ -1832,7 +1832,7 @@ describe("Parser", function () { ); }); - it("cover", () => { + it("cover", function () { const res = opcodeFromSentence( ["cover", "1"], 1, @@ -1850,7 +1850,7 @@ describe("Parser", function () { ); }); - it("uncover", () => { + it("uncover", function () { const res = opcodeFromSentence( ["uncover", "1"], 1, @@ -1873,7 +1873,7 @@ describe("Parser", function () { ); }); - it("itxn_begin", () => { + it("itxn_begin", function () { const res = opcodeFromSentence( ["itxn_begin"], 1, @@ -1896,7 +1896,7 @@ describe("Parser", function () { ); }); - it("itxn_field f", () => { + it("itxn_field f", function () { let res = opcodeFromSentence( ["itxn_field", "Sender"], 1, @@ -1936,7 +1936,7 @@ describe("Parser", function () { ); }); - it("itxn_submit", () => { + it("itxn_submit", function () { const res = opcodeFromSentence( ["itxn_submit"], 1, @@ -1958,7 +1958,7 @@ describe("Parser", function () { ); }); - it("app_get_params i", () => { + it("app_get_params i", function () { const appParams = AppParamDefined[interpreter.tealVersion]; appParams.forEach((appParam: string) => { const res = opcodeFromSentence( @@ -1984,12 +1984,12 @@ describe("Parser", function () { }); describe("opcodes for tealv6 ops", function () { - this.beforeEach(() => { + this.beforeEach(function () { interpreter.tealVersion = 6; }); describe("gloadss opcode", function () { - it("should succeed create gloadss", () => { + it("should succeed create gloadss", function () { const res = opcodeFromSentence( ["gloadss"], 1, @@ -2000,7 +2000,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should fail: create opcode with invalid parameters", () => { + it("Should fail: create opcode with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence(["gloadss", "1"], 1, interpreter, ExecutionMode.APPLICATION), @@ -2015,7 +2015,7 @@ describe("Parser", function () { }); describe("acct_params_get Opcode", function () { - it("Should succeed: create new acct_params_get opcode", () => { + it("Should succeed: create new acct_params_get opcode", function () { Object.keys(AcctParamQueryFields).forEach((appParam: string) => { const res = opcodeFromSentence( ["acct_params_get", appParam], @@ -2027,7 +2027,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); }); - it("Should fail: create acct_params_get opcode with invalid parameter", () => { + it("Should fail: create acct_params_get opcode with invalid parameter", function () { expectRuntimeError( () => opcodeFromSentence( @@ -2041,8 +2041,8 @@ describe("Parser", function () { }); }); - describe("itxn_next opcode", () => { - it("Should succeed: create new itxn_next opcode", () => { + describe("itxn_next opcode", function () { + it("Should succeed: create new itxn_next opcode", function () { // can parse opcode const res = opcodeFromSentence( ["itxn_next"], @@ -2053,7 +2053,7 @@ describe("Parser", function () { const expected = new ITxnNext([], 1, interpreter); assert.deepEqual(res, expected); }); - it("Should fail: Create itxn_next with invalid parameters", () => { + it("Should fail: Create itxn_next with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence( @@ -2067,8 +2067,8 @@ describe("Parser", function () { }); }); - describe("gitxn Opcode", () => { - it("Should succeed: create new gitxn opcode", () => { + describe("gitxn Opcode", function () { + it("Should succeed: create new gitxn opcode", function () { let res = opcodeFromSentence( ["gitxn", "0", "Fee"], 1, @@ -2087,7 +2087,7 @@ describe("Parser", function () { expected = new Gitxn(["0", "ApplicationArgs", "0"], 1, interpreter); assert.deepEqual(res, expected); }); - it("Should fail: create gitxn opcode with invalid parameters", () => { + it("Should fail: create gitxn opcode with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence(["gitxn", "1"], 1, interpreter, ExecutionMode.APPLICATION), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH @@ -2106,8 +2106,8 @@ describe("Parser", function () { }); }); - describe("gitxna Opcode", () => { - it("Should succeed: create new gitxna opcode", () => { + describe("gitxna Opcode", function () { + it("Should succeed: create new gitxna opcode", function () { let res = opcodeFromSentence( ["gitxna", "1", "Accounts", "1"], 1, @@ -2127,7 +2127,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should fail: create gitxna with invalid parameters", () => { + it("Should fail: create gitxna with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence( @@ -2163,8 +2163,8 @@ describe("Parser", function () { }); }); - describe("gitxnas Opcode", () => { - it("Should succeed: create new gitxnas opcode", () => { + describe("gitxnas Opcode", function () { + it("Should succeed: create new gitxnas opcode", function () { let res = opcodeFromSentence( ["gitxnas", "1", "Accounts"], 1, @@ -2184,7 +2184,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should fail: create gitxnas with invalid parameters", () => { + it("Should fail: create gitxnas with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence( @@ -2220,8 +2220,8 @@ describe("Parser", function () { }); }); - describe("itxnas opcode", () => { - it("Should succeed: create new itxnas opcode", () => { + describe("itxnas opcode", function () { + it("Should succeed: create new itxnas opcode", function () { // can parse opcode const res = opcodeFromSentence( ["itxnas", "Accounts"], @@ -2233,7 +2233,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should fail: create opcode with invalid parameters", () => { + it("Should fail: create opcode with invalid parameters", function () { expectRuntimeError( () => opcodeFromSentence(["itxnas"], 1, interpreter, ExecutionMode.APPLICATION), RUNTIME_ERRORS.TEAL.ASSERT_LENGTH @@ -2250,7 +2250,7 @@ describe("Parser", function () { }); const cryptoFile = "test-crypto.teal"; - describe("Opcodes list from TEAL file", () => { + describe("Opcodes list from TEAL file", function () { useFixture("teal-files"); let interpreter: Interpreter; @@ -2260,21 +2260,21 @@ describe("Parser", function () { interpreter.tealVersion = 2; }); - it("Supported pragma version 6", () => { + it("Supported pragma version 6", function () { const fileWithPragmav6 = "test-pragma-v6.teal"; assert.doesNotThrow(() => parser(getProgram(fileWithPragmav6), ExecutionMode.SIGNATURE, interpreter) ); }); - it("Supported pragma version 7", () => { + it("Supported pragma version 7", function () { const fileWithPragmav7 = "test-pragma-v7.teal"; assert.doesNotThrow(() => parser(getProgram(fileWithPragmav7), ExecutionMode.SIGNATURE, interpreter) ); }); - it("Should fail if declare pragma greater than 7", () => { + it("Should fail if declare pragma greater than 7", function () { const fileWithPragmaInvalid = "test-pragma-invalid.teal"; expectRuntimeError( () => parser(getProgram(fileWithPragmaInvalid), ExecutionMode.SIGNATURE, interpreter), @@ -2282,7 +2282,7 @@ describe("Parser", function () { ); }); - it("Should return correct opcode list for '+'", async () => { + it("Should return correct opcode list for '+'", async function () { const file1 = "test-file-1.teal"; let res = parser(getProgram(file1), ExecutionMode.SIGNATURE, interpreter); const expected = [new Int(["1"], 1), new Int(["3"], 2), new Add([], 3)]; @@ -2300,7 +2300,7 @@ describe("Parser", function () { assert.deepEqual(res, expect); }); - it("Should throw error if #pragma is not on 1st line", async () => { + it("Should throw error if #pragma is not on 1st line", async function () { let file = "test-pragma-1.teal"; expectRuntimeError( () => parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter), @@ -2314,7 +2314,7 @@ describe("Parser", function () { ); }); - it("Should return correct opcode list for '-'", async () => { + it("Should return correct opcode list for '-'", async function () { const file = "test-file-3.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [ @@ -2327,7 +2327,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for '/'", async () => { + it("Should return correct opcode list for '/'", async function () { const file = "test-file-4.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [ @@ -2340,7 +2340,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for '*'", async () => { + it("Should return correct opcode list for '*'", async function () { const file = "test-file-5.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [ @@ -2353,7 +2353,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'addr'", async () => { + it("Should return correct opcode list for 'addr'", async function () { const file = "test-addr.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [ @@ -2364,7 +2364,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'byte'", async () => { + it("Should return correct opcode list for 'byte'", async function () { const file = "test-byte.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const byte64 = "QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc="; @@ -2384,7 +2384,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Len and Err'", async () => { + it("Should return correct opcode list for 'Len and Err'", async function () { const file = "test-len-err.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [new Len([], 1), new Err([], 2)]; @@ -2392,7 +2392,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Bitwise'", async () => { + it("Should return correct opcode list for 'Bitwise'", async function () { const file = "test-bitwise.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [ @@ -2405,7 +2405,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Mod'", async () => { + it("Should return correct opcode list for 'Mod'", async function () { const file = "test-mod.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); const expected = [new Int(["6"], 1), new Int(["3"], 2), new Mod([], 3)]; @@ -2413,7 +2413,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Arg'", async () => { + it("Should return correct opcode list for 'Arg'", async function () { const file = "test-arg.teal"; interpreter.runtime = new Runtime([]); interpreter.runtime.ctx.args = [new Uint8Array(0)]; @@ -2424,7 +2424,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Intc and Bytec'", async () => { + it("Should return correct opcode list for 'Intc and Bytec'", async function () { const file = "test-int-bytec.teal"; interpreter.intcblock = [1n]; interpreter.bytecblock = [new Uint8Array(0)]; @@ -2435,7 +2435,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Store and Load'", async () => { + it("Should return correct opcode list for 'Store and Load'", async function () { const file = "test-store-load.teal"; interpreter.scratch = [1n]; @@ -2445,7 +2445,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'Crypto opcodes'", async () => { + it("Should return correct opcode list for 'Crypto opcodes'", async function () { const res = parser(getProgram(cryptoFile), ExecutionMode.SIGNATURE, interpreter); const expected = [ new Sha256([], 1, interpreter), @@ -2456,7 +2456,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'comparsions'", async () => { + it("Should return correct opcode list for 'comparsions'", async function () { const file = "test-compare.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2475,7 +2475,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("Should return correct opcode list for 'all others'", async () => { + it("Should return correct opcode list for 'all others'", async function () { const file = "test-others.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2497,7 +2497,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for 'b, bz, bnz'", async () => { + it("should return correct opcode list for 'b, bz, bnz'", async function () { const file = "test-branch.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2510,7 +2510,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for 'return'", async () => { + it("should return correct opcode list for 'return'", async function () { const file = "test-return.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2519,7 +2519,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for 'Label'", async () => { + it("should return correct opcode list for 'Label'", async function () { const file = "test-label.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2528,7 +2528,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for 'global'", async () => { + it("should return correct opcode list for 'global'", async function () { const file = "test-global.teal"; const res = parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter); @@ -2547,7 +2547,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for `Stateful`", async () => { + it("should return correct opcode list for `Stateful`", async function () { const file = "test-stateful.teal"; const res = parser(getProgram(file), ExecutionMode.APPLICATION, interpreter); @@ -2572,7 +2572,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for `teal v6`", async () => { + it("should return correct opcode list for `teal v6`", async function () { const file = "teal-v6.teal"; const res = parser(getProgram(file), ExecutionMode.APPLICATION, interpreter); @@ -2592,7 +2592,7 @@ describe("Parser", function () { assert.deepEqual(res, expected); }); - it("should return correct opcode list for `teal v7`", async () => { + it("should return correct opcode list for `teal v7`", async function () { const file = "teal-v7.teal"; const res = parser(getProgram(file), ExecutionMode.APPLICATION, interpreter); const expected = [ @@ -2604,7 +2604,7 @@ describe("Parser", function () { }); }); - describe("Gas cost of Opcodes from TEAL file", () => { + describe("Gas cost of Opcodes from TEAL file", function () { useFixture("teal-files"); let interpreter: Interpreter; @@ -2612,7 +2612,7 @@ describe("Parser", function () { interpreter = new Interpreter(); }); - it("Should return correct gas cost for 'Crypto opcodes' for tealversion 1", async () => { + it("Should return correct gas cost for 'Crypto opcodes' for tealversion 1", async function () { interpreter.tealVersion = 1; // by default the version is also 1 let op = opcodeFromSentence(["sha256"], 1, interpreter, ExecutionMode.APPLICATION); @@ -2636,7 +2636,7 @@ describe("Parser", function () { assert.equal(interpreter.gas, 1942); // 7 + 26 + 9 + 1900 }); - it("Should return correct gas cost for 'Crypto opcodes' for tealversion 2", async () => { + it("Should return correct gas cost for 'Crypto opcodes' for tealversion 2", async function () { interpreter.tealVersion = 2; let op = opcodeFromSentence(["sha256"], 1, interpreter, ExecutionMode.APPLICATION); @@ -2661,7 +2661,7 @@ describe("Parser", function () { }); // note: cost for cryto ops for teal version 2, 3 are same - it("Should return correct gas cost for 'Crypto opcodes' for tealversion 3", async () => { + it("Should return correct gas cost for 'Crypto opcodes' for tealversion 3", async function () { interpreter.tealVersion = 3; let op = opcodeFromSentence(["sha256"], 1, interpreter, ExecutionMode.APPLICATION); @@ -2685,7 +2685,7 @@ describe("Parser", function () { assert.equal(interpreter.gas, 2110); // 35 + 130 + 45 + 1900 }); - it("Should return correct gas cost for mix opcodes from teal files", async () => { + it("Should return correct gas cost for mix opcodes from teal files", async function () { let file = "test-file-1.teal"; const mode = ExecutionMode.SIGNATURE; parser(getProgram(file), mode, interpreter); @@ -2717,7 +2717,7 @@ describe("Parser", function () { assert.equal(interpreter.gas, 14); }); - it("Should throw error if total cost exceeds 20000", async () => { + it("Should throw error if total cost exceeds 20000", async function () { const file = "test-max-opcost.teal"; // has cost 22800 expectRuntimeError( () => parser(getProgram(file), ExecutionMode.SIGNATURE, interpreter), diff --git a/packages/runtime/test/src/parser/parsing.ts b/packages/runtime/test/src/parser/parsing.ts index df43458a5..441c789e3 100644 --- a/packages/runtime/test/src/parser/parsing.ts +++ b/packages/runtime/test/src/parser/parsing.ts @@ -5,20 +5,20 @@ import { assertNumber, getEncoding, parseBinaryStrToBigInt } from "../../../src/ import { EncodingType } from "../../../src/types"; import { expectRuntimeError } from "../../helpers/runtime-errors"; -describe("Get Encoding for Byte Data", () => { - it("should return corrent Encoding type for string", () => { +describe("Get Encoding for Byte Data", function () { + it("should return corrent Encoding type for string", function () { const res = getEncoding(['"string literal"'], 1); assert.deepEqual(res, ["string literal", EncodingType.UTF8]); }); - it("should return corrent Encoding type for hex", () => { + it("should return corrent Encoding type for hex", function () { const res = getEncoding(["0xadkjka"], 1); assert.deepEqual(res, ["adkjka", EncodingType.HEX]); }); - it("should return corrent Encoding type for base64", () => { + it("should return corrent Encoding type for base64", function () { const str = "QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc="; let res = getEncoding(["base64", str], 1); @@ -34,7 +34,7 @@ describe("Get Encoding for Byte Data", () => { assert.deepEqual(res, [str, EncodingType.BASE64]); }); - it("should return corrent Encoding type for base32", () => { + it("should return corrent Encoding type for base32", function () { const str = "MFRGGZDFMY="; let res = getEncoding(["base32", str], 1); @@ -50,27 +50,27 @@ describe("Get Encoding for Byte Data", () => { assert.deepEqual(res, [str, EncodingType.BASE32]); }); - it("should throw error for wrong decoding data", () => { + it("should throw error for wrong decoding data", function () { expectRuntimeError(() => getEncoding(["base64(././"], 1), RUNTIME_ERRORS.TEAL.DECODE_ERROR); expectRuntimeError(() => getEncoding(["b32(././"], 1), RUNTIME_ERRORS.TEAL.DECODE_ERROR); }); - it("should throw error for unkown decoding type", () => { + it("should throw error for unkown decoding type", function () { expectRuntimeError( () => getEncoding(["base6", "(././"], 1), RUNTIME_ERRORS.TEAL.UNKOWN_DECODE_TYPE ); }); - it("should throw invalid base64 data error", () => { + it("should throw invalid base64 data error", function () { expectRuntimeError( () => getEncoding(["base64", "AJSHKJ-#"], 1), RUNTIME_ERRORS.TEAL.INVALID_BASE64 ); }); - it("should throw invalid base32 data error", () => { + it("should throw invalid base32 data error", function () { expectRuntimeError( () => getEncoding(["base32", "AJSHKJ-#"], 1), RUNTIME_ERRORS.TEAL.INVALID_BASE32 @@ -79,19 +79,19 @@ describe("Get Encoding for Byte Data", () => { }); describe("assertNumber test cases", function () { - it("should pass with hex and dec", () => { + it("should pass with hex and dec", function () { const hexValue = "0xaa3C3"; assert.equal(assertNumber(hexValue, 1), hexValue); const decValue = "343434"; assert.equal(assertNumber(decValue, 1), decValue); }); - it("should return right format for OCT", () => { + it("should return right format for OCT", function () { const oct = "01234"; assert.equal(assertNumber(oct, 1), "0o1234"); }); - it("should failed if input invalid", () => { + it("should failed if input invalid", function () { const failedDatas = ["0xg", "3e", "0e", "00x3", "gg", " ", "0999", "1234h3"]; failedDatas.forEach((data) => { expectRuntimeError(() => assertNumber(data, 1), RUNTIME_ERRORS.TEAL.INVALID_TYPE); @@ -99,8 +99,8 @@ describe("assertNumber test cases", function () { }); }); -describe("Parse Binary string to BigInt", () => { - it("should parse to bigint", () => { +describe("Parse Binary string to BigInt", function () { + it("should parse to bigint", function () { let res = parseBinaryStrToBigInt(["0"]); assert.equal(res, 0n); diff --git a/packages/runtime/test/src/runtime.ts b/packages/runtime/test/src/runtime.ts index 22367bca1..9d53d8f7b 100644 --- a/packages/runtime/test/src/runtime.ts +++ b/packages/runtime/test/src/runtime.ts @@ -35,14 +35,14 @@ describe("Transfer Algo Transaction", function () { alan = runtime.getAccount(alan.address); } - this.beforeEach(() => { + this.beforeEach(function () { alice = new AccountStore(minBalance * 10n); bob = new AccountStore(minBalance * 10n); alan = new AccountStore(minBalance * 10n); runtime = new Runtime([alice, bob, alan]); }); - it("Transfer ALGO from alice to bob", () => { + it("Transfer ALGO from alice to bob", function () { const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -64,7 +64,7 @@ describe("Transfer Algo Transaction", function () { assert.equal(initialBobBalance + BigInt(amount), bob.balance()); }); - it("close alice acount to bob", () => { + it("close alice acount to bob", function () { const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -87,7 +87,7 @@ describe("Transfer Algo Transaction", function () { assert.equal(initialAliceBalance + initialBobBalance - BigInt(fee), bob.balance()); }); - it("should ignore rekey when use with closeRemainderTo", () => { + it("should ignore rekey when use with closeRemainderTo", function () { const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -113,7 +113,7 @@ describe("Transfer Algo Transaction", function () { assert.equal(alice.getSpendAddress(), alice.address); }); - it("should throw error if closeRemainderTo is fromAccountAddr", () => { + it("should throw error if closeRemainderTo is fromAccountAddr", function () { // throw error because closeReaminderTo invalid. expectRuntimeError( () => @@ -156,11 +156,11 @@ describe("Transfer Algo Transaction", function () { externalRuntimeAccount = runtime.getAccount(externalAccount.addr); }); - it("Balance of toAccountAddr should updated", () => { + it("Balance of toAccountAddr should updated", function () { assert.equal(externalRuntimeAccount.amount, amount); }); - it("Should transfer algo to an external account", () => { + it("Should transfer algo to an external account", function () { const transferAlgoTx: types.AlgoTransferParam = { type: types.TransactionType.TransferAlgo, sign: types.SignType.SecretKey, @@ -200,7 +200,7 @@ describe("Logic Signature Transaction in Runtime", function () { }; }); - it("should execute the lsig and verify john(delegated signature)", () => { + it("should execute the lsig and verify john(delegated signature)", function () { lsig.sign(john.account.sk); runtime.executeTx([txParam]); @@ -209,7 +209,7 @@ describe("Logic Signature Transaction in Runtime", function () { assert.equal(bobAcc.balance(), minBalance + 1000n); }); - it("should not verify signature because alice sent it", () => { + it("should not verify signature because alice sent it", function () { const invalidParams: types.ExecParams = { ...txParam, sign: types.SignType.LogicSignature, @@ -224,7 +224,7 @@ describe("Logic Signature Transaction in Runtime", function () { ); }); - it("should verify signature but reject logic", async () => { + it("should verify signature but reject logic", async function () { const logicSig = runtime.loadLogic("reject.teal"); const txParams: types.ExecParams = { ...txParam, @@ -281,7 +281,7 @@ describe("Rounds Test", function () { bob = runtime.getAccount(bob.address); } - it("should succeed if current round is between first and last valid", () => { + it("should succeed if current round is between first and last valid", function () { txParams.payFlags = { totalFee: 1000, firstValid: 5, validRounds: 200 }; runtime.setRoundAndTimestamp(20, 20); @@ -293,7 +293,7 @@ describe("Rounds Test", function () { assert.equal(bob.balance(), minBalance + 100n); }); - it("should fail if current round is not between first and last valid", () => { + it("should fail if current round is not between first and last valid", function () { runtime.setRoundAndTimestamp(3, 20); expectRuntimeError( @@ -302,7 +302,7 @@ describe("Rounds Test", function () { ); }); - it("should succeeded by default (no round requirement is passed)", () => { + it("should succeeded by default (no round requirement is passed)", function () { txParams.payFlags = { totalFee: 1000 }; runtime.executeTx([txParams]); @@ -324,7 +324,7 @@ describe("Send duplicate transaction", function () { let runtime: Runtime; let paymentTxn: types.AlgoTransferParam; - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [alice, bob] = runtime.defaultAccounts(); paymentTxn = { @@ -339,7 +339,7 @@ describe("Send duplicate transaction", function () { }; }); - it("Should throw an error when sending duplicate tx in a group", () => { + it("Should throw an error when sending duplicate tx in a group", function () { const groupTx = [paymentTxn, { ...paymentTxn }]; expectRuntimeError( @@ -348,7 +348,7 @@ describe("Send duplicate transaction", function () { ); }); - it("Should not throw an error when add different note filed", () => { + it("Should not throw an error when add different note filed", function () { const groupTx = [paymentTxn, { ...paymentTxn, payFlags: { note: "salt" } }]; assert.doesNotThrow(() => runtime.executeTx(groupTx)); @@ -365,7 +365,7 @@ describe("Algorand Standard Assets", function () { let modFields: types.AssetModFields; let assetTransferParam: types.AssetTransferParam; let assetId: number; - this.beforeAll(() => { + this.beforeAll(function () { runtime = new Runtime([john, bob, alice, elon]); modFields = { manager: bob.address, @@ -384,7 +384,7 @@ describe("Algorand Standard Assets", function () { }; }); - this.beforeEach(() => { + this.beforeEach(function () { assetId = runtime.deployASA("gold", { creator: { ...john.account, name: "john" }, }).assetIndex; @@ -397,7 +397,7 @@ describe("Algorand Standard Assets", function () { alice = runtime.getAccount(alice.address); }; - it("should create asset using asa.yaml file and raise account minimum balance", () => { + it("should create asset using asa.yaml file and raise account minimum balance", function () { const initialMinBalance = john.minBalance; assetId = runtime.deployASA("gold", { creator: { ...john.account, name: "john" }, @@ -421,7 +421,7 @@ describe("Algorand Standard Assets", function () { assert.equal(john.minBalance, initialMinBalance + ASSET_CREATION_FEE); }); - it("should create asset without using asa.yaml file", () => { + it("should create asset without using asa.yaml file", function () { const expected = { name: "gold-1221", asaDef: { @@ -452,7 +452,7 @@ describe("Algorand Standard Assets", function () { assert.equal(res.url, "url"); }); - it("Should create asset with total = 2^64-1 (max value possible)", () => { + it("Should create asset with total = 2^64-1 (max value possible)", function () { const maxUint64 = 2n ** 64n - 1n; const execParams: types.ExecParams = { type: types.TransactionType.DeployASA, @@ -478,7 +478,7 @@ describe("Algorand Standard Assets", function () { assert.equal(res?.assetDef.total, maxUint64); }); - it("should create asset without using asa.yaml (execute transaction)", () => { + it("should create asset without using asa.yaml (execute transaction)", function () { const execParams: types.ExecParams = { type: types.TransactionType.DeployASA, sign: types.SignType.SecretKey, @@ -511,7 +511,7 @@ describe("Algorand Standard Assets", function () { assert.equal(res?.assetDef.url, "url"); }); - it("should opt-in to asset", () => { + it("should opt-in to asset", function () { const res = runtime.getAssetDef(assetId); assert.isDefined(res); @@ -526,7 +526,7 @@ describe("Algorand Standard Assets", function () { assert.equal(aliceAssetHolding?.amount, 0n); }); - it("should opt-in to asset using asset transfer transaction", () => { + it("should opt-in to asset using asset transfer transaction", function () { const res = runtime.getAssetDef(assetId); assert.isDefined(res); const prevAliceMinBal = alice.minBalance; @@ -550,14 +550,14 @@ describe("Algorand Standard Assets", function () { assert.equal(alice.minBalance, prevAliceMinBal + ASSET_CREATION_FEE); }); - it("should throw error on opt-in if asset does not exist", () => { + it("should throw error on opt-in if asset does not exist", function () { expectRuntimeError( () => runtime.optInToASA(1234, john.address, {}), RUNTIME_ERRORS.ASA.ASSET_NOT_FOUND ); }); - it("should warn if account already is already opted-into asset", () => { + it("should warn if account already is already opted-into asset", function () { // console is mocked in package.json mocha options const stub = console.warn as sinon.SinonStub; stub.reset(); @@ -570,7 +570,7 @@ describe("Algorand Standard Assets", function () { assert(stub.calledWith(`${john.address} is already opted in to asset ${assetId}`)); }); - it("should transfer asset between two accounts", () => { + it("should transfer asset between two accounts", function () { const res = runtime.getAssetDef(assetId); assert.isDefined(res); runtime.optInToASA(assetId, alice.address, {}); @@ -590,7 +590,7 @@ describe("Algorand Standard Assets", function () { } }); - it("should throw error on transfer asset if asset is frozen and amount > 0", () => { + it("should throw error on transfer asset if asset is frozen and amount > 0", function () { const freezeParam: types.FreezeAssetParam = { type: types.TransactionType.FreezeAsset, sign: types.SignType.SecretKey, @@ -619,7 +619,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should close alice account for transfer asset if close remainder to is specified", () => { + it("should close alice account for transfer asset if close remainder to is specified", function () { const initialAliceMinBalance = alice.minBalance; const res = runtime.getAssetDef(assetId); assert.isDefined(res); @@ -662,7 +662,7 @@ describe("Algorand Standard Assets", function () { } }); - it("should throw error if closeRemainderTo is fromAccountAddr", () => { + it("should throw error if closeRemainderTo is fromAccountAddr", function () { const res = runtime.getAssetDef(assetId); assert.isDefined(res); runtime.optInToASA(assetId, alice.address, {}); @@ -692,7 +692,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should throw error if trying to close asset holding of asset creator account", () => { + it("should throw error if trying to close asset holding of asset creator account", function () { const res = runtime.getAssetDef(assetId); assert.isDefined(res); runtime.optInToASA(assetId, alice.address, {}); @@ -709,7 +709,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should throw error if asset is not found while modifying", () => { + it("should throw error if asset is not found while modifying", function () { const modifyParam: types.ModifyAssetParam = { type: types.TransactionType.ModifyAsset, sign: types.SignType.SecretKey, @@ -724,7 +724,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should modify asset", () => { + it("should modify asset", function () { const modifyParam: types.ModifyAssetParam = { type: types.TransactionType.ModifyAsset, sign: types.SignType.SecretKey, @@ -742,7 +742,7 @@ describe("Algorand Standard Assets", function () { assert.equal(res.freeze, john.address); }); - it("Blank field test, should not modify asset because field is set to blank", () => { + it("Blank field test, should not modify asset because field is set to blank", function () { const assetId = runtime.deployASA("silver", { creator: { ...john.account, name: "john" }, }).assetIndex; @@ -768,7 +768,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should fail because only manager account can modify asset", () => { + it("should fail because only manager account can modify asset", function () { const modifyParam: types.ModifyAssetParam = { type: types.TransactionType.ModifyAsset, sign: types.SignType.SecretKey, @@ -783,7 +783,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should fail because only freeze account can freeze asset", () => { + it("should fail because only freeze account can freeze asset", function () { const freezeParam: types.FreezeAssetParam = { type: types.TransactionType.FreezeAsset, sign: types.SignType.SecretKey, @@ -797,7 +797,7 @@ describe("Algorand Standard Assets", function () { expectRuntimeError(() => runtime.executeTx([freezeParam]), RUNTIME_ERRORS.ASA.FREEZE_ERROR); }); - it("should freeze asset", () => { + it("should freeze asset", function () { const freezeParam: types.FreezeAssetParam = { type: types.TransactionType.FreezeAsset, sign: types.SignType.SecretKey, @@ -813,7 +813,7 @@ describe("Algorand Standard Assets", function () { assert.equal(johnAssetHolding["is-frozen"], true); }); - it("should fail because only clawback account can revoke assets", () => { + it("should fail because only clawback account can revoke assets", function () { const revokeParam: types.RevokeAssetParam = { type: types.TransactionType.RevokeAsset, sign: types.SignType.SecretKey, @@ -830,7 +830,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should revoke assets", () => { + it("should revoke assets", function () { const revokeParam: types.RevokeAssetParam = { type: types.TransactionType.RevokeAsset, sign: types.SignType.SecretKey, @@ -861,7 +861,7 @@ describe("Algorand Standard Assets", function () { assert.equal(bobHolding.amount, 5n); }); - it("should fail because only clawback account can revoke assets", () => { + it("should fail because only clawback account can revoke assets", function () { const revokeParam: types.RevokeAssetParam = { type: types.TransactionType.RevokeAsset, sign: types.SignType.SecretKey, @@ -878,7 +878,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should throw error if trying to close asset holding by clawback", () => { + it("should throw error if trying to close asset holding by clawback", function () { /* eslint sonarjs/no-identical-functions: "off" */ const closebyClawbackParam: types.RevokeAssetParam = { type: types.TransactionType.RevokeAsset, @@ -899,7 +899,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("should revoke if asset is frozen", () => { + it("should revoke if asset is frozen", function () { const freezeParam: types.FreezeAssetParam = { type: types.TransactionType.FreezeAsset, sign: types.SignType.SecretKey, @@ -938,7 +938,7 @@ describe("Algorand Standard Assets", function () { assert.equal(bobHolding.amount, 5n); }); - it("Should fail because only manager can destroy assets", () => { + it("Should fail because only manager can destroy assets", function () { const destroyParam: types.DestroyAssetParam = { type: types.TransactionType.DestroyAsset, sign: types.SignType.SecretKey, @@ -952,7 +952,7 @@ describe("Algorand Standard Assets", function () { ); }); - it("Should destroy asset", () => { + it("Should destroy asset", function () { const initialCreatorMinBalance = john.minBalance; const destroyParam: types.DestroyAssetParam = { type: types.TransactionType.DestroyAsset, @@ -970,7 +970,7 @@ describe("Algorand Standard Assets", function () { assert.equal(john.minBalance, initialCreatorMinBalance - ASSET_CREATION_FEE); }); - it("Should not destroy asset if total assets are not in creator's account", () => { + it("Should not destroy asset if total assets are not in creator's account", function () { const destroyParam: types.DestroyAssetParam = { type: types.TransactionType.DestroyAsset, sign: types.SignType.SecretKey, @@ -999,7 +999,7 @@ describe("Stateful Smart Contracts", function () { let approvalProgramFilename: string; let clearProgramFilename: string; let appDefinition: types.AppDefinitionFromFile; - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([john]); approvalProgramFilename = "counter-approval.teal"; clearProgramFilename = "clear.teal"; @@ -1016,7 +1016,7 @@ describe("Stateful Smart Contracts", function () { }; }); - it("Should not create application if approval program is empty", () => { + it("Should not create application if approval program is empty", function () { appDefinition.approvalProgramFilename = "empty-app.teal"; expectRuntimeError( @@ -1025,7 +1025,7 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should not create application if clear program is empty", () => { + it("Should not create application if clear program is empty", function () { appDefinition.clearProgramFilename = "empty-app.teal"; expectRuntimeError( @@ -1034,14 +1034,14 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should create application", () => { + it("Should create application", function () { const appID = runtime.deployApp(john.account, appDefinition, {}).appID; const app = runtime.getApp(appID); assert.isDefined(app); }); - it("Should throw error when deploy application if approval teal version and clear state teal version not match ", () => { + it("Should throw error when deploy application if approval teal version and clear state teal version not match ", function () { appDefinition.clearProgramFilename = "clearv6.teal"; expectRuntimeError( () => runtime.deployApp(john.account, appDefinition, {}), @@ -1049,7 +1049,7 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should not update application if approval or clear program is empty", () => { + it("Should not update application if approval or clear program is empty", function () { const appID = runtime.deployApp(john.account, appDefinition, {}).appID; expectRuntimeError( @@ -1087,7 +1087,7 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should not update application if approval and clear program not match", () => { + it("Should not update application if approval and clear program not match", function () { const appID = runtime.deployApp(john.account, appDefinition, {}).appID; clearProgramFilename = "clearv6.teal"; @@ -1109,7 +1109,7 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should throw and error when local schema entries exceeds the limit (AppDefinition)", () => { + it("Should throw and error when local schema entries exceeds the limit (AppDefinition)", function () { const incorrectCreationFlags = { globalBytes: 10, globalInts: 10, @@ -1133,7 +1133,7 @@ describe("Stateful Smart Contracts", function () { ); }); - it("Should throw and error when global schema entries exceeds the limit (AppDefinition)", () => { + it("Should throw and error when global schema entries exceeds the limit (AppDefinition)", function () { const incorrectCreationFlags = { globalBytes: 36, globalInts: 32, @@ -1170,12 +1170,12 @@ describe("Deafult Accounts", function () { [alice, bob] = runtime.defaultAccounts(); charlie = runtime.getAccount(charlie.address); } - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([charlie]); [alice, bob] = runtime.defaultAccounts(); }); - it("Should be properly initialized", () => { + it("Should be properly initialized", function () { assert.exists(alice.address); assert.equal( alice.balance(), @@ -1184,7 +1184,7 @@ describe("Deafult Accounts", function () { ); }); - it("Should update the state of the default accounts", () => { + it("Should update the state of the default accounts", function () { const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -1207,7 +1207,7 @@ describe("Deafult Accounts", function () { assert.equal(initialBobBalance + BigInt(amount), bob.balance()); }); - it("Should reset the state of the default accounts", () => { + it("Should reset the state of the default accounts", function () { const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -1230,7 +1230,7 @@ describe("Deafult Accounts", function () { assert.equal(initialBobBalance, bob.balance()); }); - it("Should not reset the state of the other accounts stored in runtime", () => { + it("Should not reset the state of the other accounts stored in runtime", function () { const initialCharlieBalance = charlie.balance(); const algoTransferTxParam: types.AlgoTransferParam = { type: types.TransactionType.TransferAlgo, @@ -1257,12 +1257,12 @@ describe("Algo transfer using sendSignedTransaction", function () { const amount = 1e6; const fee = 1000; - this.beforeEach(() => { + this.beforeEach(function () { runtime = new Runtime([]); [alice, bob] = runtime.defaultAccounts(); }); - it("Should send signedTransacion from one account to another", () => { + it("Should send signedTransacion from one account to another", function () { //Create transaction const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -1282,7 +1282,7 @@ describe("Algo transfer using sendSignedTransaction", function () { assert.equal(initialBobBalance + BigInt(amount), bob.balance()); //(got, expected) }); - it("Should close alice account and send all the balance to bob the account", () => { + it("Should close alice account and send all the balance to bob the account", function () { // Create transaction const initialAliceBalance = alice.balance(); const initialBobBalance = bob.balance(); @@ -1324,7 +1324,7 @@ describe.skip("Logic Signature Transaction in Runtime using sendSignedTransactio lsig.sign(john.account.sk); }); - it("should execute the lsig and verify john(delegated signature)", () => { + it("should execute the lsig and verify john(delegated signature)", function () { const initialJohnBalance = john.balance(); const initialBobBalance = bob.balance(); const suggestedParams = mockSuggestedParams({ totalFee: fee }, runtime.getRound()); @@ -1345,7 +1345,7 @@ describe.skip("Logic Signature Transaction in Runtime using sendSignedTransactio assert.equal(initialBobBalance + BigInt(amount), bob.balance()); }); - it("should not verify signature because alice sent it", () => { + it("should not verify signature because alice sent it", function () { const suggestedParams = mockSuggestedParams({ totalFee: fee }, runtime.getRound()); const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: john.address, diff --git a/packages/web/test/src/lib/web-mode.ts b/packages/web/test/src/lib/web-mode.ts index 9d09dfca2..e8ae2aa93 100644 --- a/packages/web/test/src/lib/web-mode.ts +++ b/packages/web/test/src/lib/web-mode.ts @@ -24,7 +24,7 @@ describe("Webmode - Algosigner test cases ", function () { amountMicroAlgos: 10000n, payFlags: {}, }; - assert.doesNotThrow(async () => { + assert.doesNotThrow(async function () { await webMode.executeTx([txnParams]); }); }); diff --git a/packages/web/test/src/types.ts b/packages/web/test/src/types.ts index c909651e2..98f43e84e 100644 --- a/packages/web/test/src/types.ts +++ b/packages/web/test/src/types.ts @@ -3,8 +3,8 @@ import { assert } from "chai"; import { isSDKTransactionAndSign, SignType } from "../../src/types"; import { txObject } from "../mocks/tx"; -describe("Transaction And Sign interface", () => { - it("should return false if transaction object is not SDK transaction", () => { +describe("Transaction And Sign interface", function () { + it("should return false if transaction object is not SDK transaction", function () { const param: unknown = { transaction: { name: "AA" }, sign: { sign: "sd" }, @@ -13,7 +13,7 @@ describe("Transaction And Sign interface", () => { assert.isFalse(isSDKTransactionAndSign(param)); }); - it("should return false if sign is not in transaction", () => { + it("should return false if sign is not in transaction", function () { const param: unknown = { transaction: txObject, }; @@ -21,7 +21,7 @@ describe("Transaction And Sign interface", () => { assert.isFalse(isSDKTransactionAndSign(param)); }); - it("should return true if sign and transaction is present", () => { + it("should return true if sign and transaction is present", function () { const param: unknown = { transaction: txObject, sign: { sign: SignType.SecretKey, fromAccount: [] },