From 98c58f297f9ca2850ee69887025405c6de04487d Mon Sep 17 00:00:00 2001 From: ericsharma Date: Thu, 18 Aug 2022 12:35:34 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8Added=20close=20AlgoOrder=20to=20t?= =?UTF-8?q?ransaction=20generator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/GenerateTransactionTypes.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/order/__tests__/GenerateTransactionTypes.js b/lib/order/__tests__/GenerateTransactionTypes.js index 76062a60..97857200 100644 --- a/lib/order/__tests__/GenerateTransactionTypes.js +++ b/lib/order/__tests__/GenerateTransactionTypes.js @@ -1,6 +1,8 @@ const withPlaceAssetTxns = require('../txns/sell/withPlaceAssetTxns'); const withPlaceAlgoTxns = require('../txns/buy/withPlaceAlgoTxns'); const withCloseAssetTxns = require('../txns/close/withCloseAssetTxns'); +const withCloseAlgoTxns = require('../txns/close/withCloseAlgoTxns'); + const compile = require('../compile/compile'); const AlgodexApi = require('../../AlgodexApi'); @@ -82,6 +84,26 @@ const TransactionGenerator = { }) ); }, + getCloseAlgoEscrowOrderTxns: async function (order, optIn) { + return await withCloseAlgoTxns( + await compile({ + ...order, + appId: + typeof order.appId === 'undefined' + ? await algodexApi.getAppId(order) + : order.appId, + version: 6, + indexer: algodexApi.indexer, + contract: { + creator: order.address, + }, + wallet: { + ...order.wallet, + ...(await algodexApi.http.indexer.fetchAccountInfo(order.wallet)), + }, + }) + ); + }, }; module.exports = TransactionGenerator; From f02172bf22408864c7352e14a0cbaf6ed30851b8 Mon Sep 17 00:00:00 2001 From: ericsharma Date: Thu, 18 Aug 2022 12:36:19 -0400 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=85Updated=20closeAlgoEscrrowOrder=20?= =?UTF-8?q?to=20v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teal_tests/closeAlgoEscrowOrder.js | 129 +++++++++++++----- 1 file changed, 96 insertions(+), 33 deletions(-) diff --git a/lib/order/__tests__/teal_tests/closeAlgoEscrowOrder.js b/lib/order/__tests__/teal_tests/closeAlgoEscrowOrder.js index d39e0ece..817b1b65 100644 --- a/lib/order/__tests__/teal_tests/closeAlgoEscrowOrder.js +++ b/lib/order/__tests__/teal_tests/closeAlgoEscrowOrder.js @@ -1,36 +1,70 @@ /* eslint-disable */ const testHelper = require('../setup.js'); -const transactionGenerator = require('../../lib/teal/generate_transaction_types.js'); +const transactionGenerator = require('../GenerateTransactionTypes'); const algosdk = require('algosdk'); +const signer = require('../../../wallet/signers/AlgoSDK'); +const _sendTransactions = require('./sendTransactions'); const PRINT_TXNS = 0; const Test = { - runTest: async function(config, price, returnOuterTransactions = false) { - console.log('STARTING close algo escrow order test'); + runTest: async function ( + config, + price, + asaAmount, + returnOuterTransactions = false + ) { + console.log('STARTING placeASAEscrowOrder test'); const client = config.client; - const creatorAccount = config.creatorAccount; - const assetId = config.assetId; - const appId = config.appId; - console.log('creator account is: ' + creatorAccount.addr); - const outerTxns = await transactionGenerator.getCloseAlgoEscrowOrderTxns(client, creatorAccount, price, assetId, appId); + const creatorAccount = config.creatorAccount.addr; + const wallet = { + type: 'sdk', + address: config.creatorAccount.addr, + connector: { + ...config.connector, + sk: config.creatorAccount.sk, //Just in case we want to test signing and sending from the api and not from the tests. + connected: true, + }, + // mnemonic: config.creatorAccount.sk, + }; + + const order = { + asset: { + id: config.assetId, + decimals: 6, + }, + address: creatorAccount, + price: price, + amount: asaAmount, + total: price * asaAmount, + type: 'buy', + client: config.client, + execution: 'close', + wallet: wallet, + }; + + const closeASAEscrowOrder = + await transactionGenerator.getCloseAlgoEscrowOrderTxns(order); if (returnOuterTransactions) { return outerTxns; } - const signedTxns = testHelper.groupAndSignTransactions(outerTxns); + const signedTxns = await signer( + [closeASAEscrowOrder], + config.creatorAccount.sk + ); - await testHelper.sendAndCheckConfirmed(client, signedTxns); + const confirmation = await _sendTransactions(client, signedTxns); return true; }, - getOuterTransactions: async function(config) { + getOuterTransactions: async function (config) { const outerTxns = await this.runTest(config, 1.2, true); return outerTxns; }, - runGroupSizeWrongTest: async function(config) { + runGroupSizeWrongTest: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -41,9 +75,14 @@ const Test = { const lsig = outerTxns[0].lsig; - outerTxns.push( { - unsignedTxn: await transactionGenerator.getPayTxn(client, lsig.address(), maliciousAccount.addr, - 1000, false), + outerTxns.push({ + unsignedTxn: await transactionGenerator.getPayTxn( + client, + lsig.address(), + maliciousAccount.addr, + 1000, + false + ), lsig: lsig, }); @@ -58,7 +97,7 @@ const Test = { return false; }, - runGroupSizeWrongTest2: async function(config) { + runGroupSizeWrongTest2: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -69,9 +108,14 @@ const Test = { const lsig = outerTxns[0].lsig; - outerTxns.push( { - unsignedTxn: await transactionGenerator.getPayTxn(client, maliciousAccount.addr, maliciousAccount.addr, - 1000, false), + outerTxns.push({ + unsignedTxn: await transactionGenerator.getPayTxn( + client, + maliciousAccount.addr, + maliciousAccount.addr, + 1000, + false + ), senderAcct: maliciousAccount, }); @@ -86,7 +130,7 @@ const Test = { return false; }, - runAlgoWrongAddrCloseToTest: async function(config) { + runAlgoWrongAddrCloseToTest: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -95,7 +139,9 @@ const Test = { testHelper.printOuterTransactions(outerTxns); } - outerTxns[1].unsignedTxn.closeRemainderTo = algosdk.decodeAddress(maliciousAccount.addr); + outerTxns[1].unsignedTxn.closeRemainderTo = algosdk.decodeAddress( + maliciousAccount.addr + ); const signedTxns = testHelper.groupAndSignTransactions(outerTxns); try { @@ -108,7 +154,7 @@ const Test = { return false; }, - runCloseToTxnHasNonZeroAmount: async function(config) { + runCloseToTxnHasNonZeroAmount: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -130,7 +176,7 @@ const Test = { return false; }, - runAlgoWrongOwnerProofTest: async function(config) { + runAlgoWrongOwnerProofTest: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -139,7 +185,9 @@ const Test = { testHelper.printOuterTransactions(outerTxns); } - outerTxns[2].unsignedTxn.from = algosdk.decodeAddress(maliciousAccount.addr); + outerTxns[2].unsignedTxn.from = algosdk.decodeAddress( + maliciousAccount.addr + ); const signedTxns = testHelper.groupAndSignTransactions(outerTxns); try { @@ -152,7 +200,7 @@ const Test = { return false; }, - appCallMissing: async function(config) { + appCallMissing: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -162,8 +210,13 @@ const Test = { } outerTxns[0] = { - unsignedTxn: await transactionGenerator.getPayTxn(client, maliciousAccount.addr, maliciousAccount.addr, - 1000, false), + unsignedTxn: await transactionGenerator.getPayTxn( + client, + maliciousAccount.addr, + maliciousAccount.addr, + 1000, + false + ), senderAcct: maliciousAccount, }; @@ -178,7 +231,7 @@ const Test = { return false; }, - payTxnWrongType: async function(config) { + payTxnWrongType: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -188,8 +241,13 @@ const Test = { } outerTxns[1] = { - unsignedTxn: await transactionGenerator.getPayTxn(client, maliciousAccount.addr, maliciousAccount.addr, - 1000, false), + unsignedTxn: await transactionGenerator.getPayTxn( + client, + maliciousAccount.addr, + maliciousAccount.addr, + 1000, + false + ), senderAcct: maliciousAccount, }; @@ -204,7 +262,7 @@ const Test = { return false; }, - refundTxnWrongType: async function(config) { + refundTxnWrongType: async function (config) { const outerTxns = await this.getOuterTransactions(config); const client = config.client; const maliciousAccount = config.maliciousAccount; @@ -214,8 +272,13 @@ const Test = { } outerTxns[2] = { - unsignedTxn: await transactionGenerator.getPayTxn(client, maliciousAccount.addr, maliciousAccount.addr, - 1000, false), + unsignedTxn: await transactionGenerator.getPayTxn( + client, + maliciousAccount.addr, + maliciousAccount.addr, + 1000, + false + ), senderAcct: maliciousAccount, }; From 4b31a2e6fe173781f96672c223261446923b474d Mon Sep 17 00:00:00 2001 From: ericsharma Date: Thu, 18 Aug 2022 12:48:01 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=A8CleanUp=20for=20tealAlgoNoOptin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TealAlgoEscrowPlaceNoOptInTxn.spec.js | 126 +++--------------- lib/order/__tests__/accountCleanup.js | 9 +- lib/teal/test/initAccounts.js | 8 +- 3 files changed, 20 insertions(+), 123 deletions(-) diff --git a/lib/order/__tests__/TealAlgoEscrowPlaceNoOptInTxn.spec.js b/lib/order/__tests__/TealAlgoEscrowPlaceNoOptInTxn.spec.js index 9bef2051..a4e0a8cc 100644 --- a/lib/order/__tests__/TealAlgoEscrowPlaceNoOptInTxn.spec.js +++ b/lib/order/__tests__/TealAlgoEscrowPlaceNoOptInTxn.spec.js @@ -9,116 +9,28 @@ const accountSetup = require('./accountSetup.js'); const JEST_MINUTE_TIMEOUT = 60 * 1000; const config = require('./TealConfig'); const { timeout } = require('../../teal/utils'); -// const testHelper = require('./setup.js'); -// const transactionGenerator = require('../generate_transaction_types.js'); -// const createAppTest = require('./teal_tests/createAppTest.js'); -// const deleteAppTest = require('./teal_tests/deleteAppTest.js'); -// const placeOrderTest = require('./teal_tests/placeAlgoEscrowOrder.js'); -// const executeAlgoOrderTest = require('./teal_tests/executeAlgoEscrowOrder.js'); -// const executeAsaOrderTest = require('./teal_tests/executeASAEscrowOrder.js'); -// const placeASAOrderTest = require('./teal_tests/placeASAEscrowOrder.js'); -// const closeOrderTest = require('./teal_tests/closeAlgoEscrowOrder.js'); -// const closeASAOrderTest = require('./teal_tests/closeASAEscrowOrder.js'); -// const algosdk = require('algosdk'); -// -// -// const AlgodexApi = require('../algodex_api.js'); -// const constants = require('../constants.js'); -// const JEST_MINUTE_TIMEOUT = 60 * 1000; -// -// const config = { -// appId: -1, -// creatorAccount: testHelper.getRandomAccount(), -// executorAccount: testHelper.getRandomAccount(), -// openAccount: testHelper.getOpenAccount(), -// maliciousAccount: testHelper.getRandomAccount(), -// client: testHelper.getLocalClient(), -// assetId: 66711302, -// }; -// -// console.log('DEBUG_SMART_CONTRACT_SOURCE is: ' + constants.DEBUG_SMART_CONTRACT_SOURCE); -// -// const textEncoder = new TextEncoder(); -// -// // TODO: The negative tests need to be implemented. The commented ones out are examples but will not work with -// // this transaction type. -// const negTests = [ -// /* {txnNum: 0, field: 'from', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 0, field: 'appArgs', innerNum: 0, val: textEncoder.encode('execute') }, -// {txnNum: 0, field: 'appIndex', configKeyForVal: 'fakeAppId' }, -// {txnNum: 0, field: 'appOnComplete', val: 0}, -// {txnNum: 1, field: 'from', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 1, field: 'closeRemainderTo', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 1, negTxn: { -// unsignedTxnPromise: transactionGenerator.getAssetSendTxn(config.client, config.maliciousAccount.addr, config.maliciousAccount.addr, -// 1000, config.assetId, false), -// senderAcct: config.maliciousAccount -// } -// }, -// {txnNum: 2, field: 'from', txnKeyForVal: 'from', txnNumForVal: 1}, //set to from escrow -// {txnNum: 2, field: 'to', val: algosdk.decodeAddress(config.maliciousAccount.addr)}, -// {txnNum: 2, negTxn: { -// unsignedTxnPromise: transactionGenerator.getPayTxn(config.client, -// config.maliciousAccount.addr, config.maliciousAccount.addr, -// 1000, false), -// senderAcct: config.maliciousAccount -// } -// },*/ -// -// ]; -// -describe.skip('ALGO ESCROW ORDER BOOK (opt in test)', () => { +const closeAlgoOrderTest = require('./teal_tests/closeAlgoEscrowOrder.js'); +const accountCleanup = require('./accountCleanup.js'); + +describe('ALGO ESCROW ORDER BOOK (opt in test)', () => { + const amount = 0.8; + const price = 1.2; beforeAll(async () => { - // await accountSetup(config, 'buy', true); //optIn in the setUp phase to test sdk no optIn + await accountSetup(config, 'buy', true); //optIn in the setUp phase to test sdk no optIn await timeout(7000); // Eliminates race condition where future indexer calls occur before setUp step fully propogates but after it succeeds }, JEST_MINUTE_TIMEOUT); - // negTests.map((negTestTxnConfig) => { - // const testName = `Negative algo full execution order test: txnNum: ${negTestTxnConfig.txnNum} field: ${negTestTxnConfig.field} val: ${negTestTxnConfig.val}`; - // test( - // testName, - // async () => { - // if (negTestTxnConfig.negTxn) { - // negTestTxnConfig.negTxn.unsignedTxn = await negTestTxnConfig.negTxn - // .unsignedTxnPromise; - // } - // const outerTxns = await executeAlgoOrderTest.runFullExecTest( - // config, - // true - // ); - // outerTxns.map((txn) => { - // const unsignedTxn = txn.unsignedTxn; - // // console.log({unsignedTxn}); - // }); - // const result = await testHelper.runNegativeTest( - // config, - // config.client, - // outerTxns, - // negTestTxnConfig - // ); - // expect(result).toBeTruthy(); - // }, - // JEST_MINUTE_TIMEOUT - // ); - // }); + afterAll(async () => { + await timeout(4000); + await accountCleanup(config, 'buy', true); + }, JEST_MINUTE_TIMEOUT); test( 'Place algo escrow order', async () => { - // let asaBalance = await testHelper.getAssetBalance( - // config.creatorAccount.addr, - // config.assetId - // ); - // expect(asaBalance).toBeGreaterThan(0); // already opted in and has ASA - - const result = await placeAlgoOrderTest.runTest(config, 0.8, 1.2); + const result = await placeAlgoOrderTest.runTest(config, amount, price); expect(result).toBeTruthy(); - - // asaBalance = await testHelper.getAssetBalance( - // config.creatorAccount.addr, - // config.assetId - // ); - // expect(asaBalance).toBeGreaterThan(0); + await timeout(4000); }, JEST_MINUTE_TIMEOUT ); @@ -126,19 +38,11 @@ describe.skip('ALGO ESCROW ORDER BOOK (opt in test)', () => { test( 'Close algo escrow order', async () => { - const result = await closeOrderTest.runTest(config, 1.2); + await timeout(3000); + const result = await closeAlgoOrderTest.runTest(config, price, amount); expect(result).toBeTruthy(); }, JEST_MINUTE_TIMEOUT ); - - // test( - // 'Delete algo escrow order book', - // async () => { - // const result = await deleteAppTest.runTest(config); - // expect(result).toBeTruthy(); - // }, - // JEST_MINUTE_TIMEOUT - // ); }); // diff --git a/lib/order/__tests__/accountCleanup.js b/lib/order/__tests__/accountCleanup.js index 9df5f248..b7d3b057 100644 --- a/lib/order/__tests__/accountCleanup.js +++ b/lib/order/__tests__/accountCleanup.js @@ -29,12 +29,9 @@ async function cleanupAccounts( await transferFunds(client, creatorAccount, openAccount, 1500000); //transfer original algo } - // if (type === "buy") { - // await transferFunds(client, openAccount, creatorAccount, 5000000); //enough funds to facilitate an escrow place - // if (optIn) { - // await transferASA(client, creatorAccount, creatorAccount, 0, assetId); // opt in transaction - // } - // } + if (type === 'buy') { + await transferFunds(client, creatorAccount, openAccount, 1750000); //transfer original algo + } // if (optIn) { // await transferASA(client, executorAccount, executorAccount, 0, config.assetIndex); // opt in transaction diff --git a/lib/teal/test/initAccounts.js b/lib/teal/test/initAccounts.js index f3ffdb3c..babeea99 100644 --- a/lib/teal/test/initAccounts.js +++ b/lib/teal/test/initAccounts.js @@ -35,11 +35,7 @@ const algodexApi = new AlgodexApi(tesnet); */ async function initAccounts(config, type, optIn = false, newCreator = false) { // If we are overriding the default creator account - if (newCreator) { - // This creates the config.oldCreatorAccount key - // and overrides the current creator account - config.setCreatorAccount(algosdk.generateAccount()); - } + const { client, openAccount, @@ -58,7 +54,7 @@ async function initAccounts(config, type, optIn = false, newCreator = false) { } if (type === 'buy') { - await transferFunds(client, openAccount, creatorAccount, 5000000); //enough funds to facilitate an escrow place + // await transferFunds(client, openAccount, creatorAccount, 5000000); //enough funds to facilitate an escrow place if (optIn) { await transferASA(client, creatorAccount, creatorAccount, 0, assetId); // opt in transaction } From fb92a1db902fde5e6ed881660246884ff0e703f3 Mon Sep 17 00:00:00 2001 From: ericsharma Date: Thu, 18 Aug 2022 12:54:59 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=E2=9C=A8Cancelling=20orders=20and=20cleanu?= =?UTF-8?q?p=20step=20complete=20for=20algo=20with=20optin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TealAlgoEscrowPlaceWithOptInTxn.spec.js | 109 +++--------------- 1 file changed, 18 insertions(+), 91 deletions(-) diff --git a/lib/order/__tests__/TealAlgoEscrowPlaceWithOptInTxn.spec.js b/lib/order/__tests__/TealAlgoEscrowPlaceWithOptInTxn.spec.js index 4cc4d8ad..b7cc4290 100644 --- a/lib/order/__tests__/TealAlgoEscrowPlaceWithOptInTxn.spec.js +++ b/lib/order/__tests__/TealAlgoEscrowPlaceWithOptInTxn.spec.js @@ -9,110 +9,37 @@ const accountSetup = require('./accountSetup.js'); const JEST_MINUTE_TIMEOUT = 60 * 1000; const config = require('./TealConfig'); const { timeout } = require('../../teal/utils'); +const closeAlgoOrderTest = require('./teal_tests/closeAlgoEscrowOrder.js'); +const accountCleanup = require('./accountCleanup.js'); -// -// // TODO: The negative tests need to be implemented. The commented ones out are examples but will not work with -// // this transaction type. -// const negTests = [ -// /* {txnNum: 0, field: 'from', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 0, field: 'appArgs', innerNum: 0, val: textEncoder.encode('execute') }, -// {txnNum: 0, field: 'appIndex', configKeyForVal: 'fakeAppId' }, -// {txnNum: 0, field: 'appOnComplete', val: 0}, -// {txnNum: 1, field: 'from', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 1, field: 'closeRemainderTo', val: algosdk.decodeAddress(config.maliciousAccount.addr) }, -// {txnNum: 1, negTxn: { -// unsignedTxnPromise: transactionGenerator.getAssetSendTxn(config.client, config.maliciousAccount.addr, config.maliciousAccount.addr, -// 1000, config.assetId, false), -// senderAcct: config.maliciousAccount -// } -// }, -// {txnNum: 2, field: 'from', txnKeyForVal: 'from', txnNumForVal: 1}, //set to from escrow -// {txnNum: 2, field: 'to', val: algosdk.decodeAddress(config.maliciousAccount.addr)}, -// {txnNum: 2, negTxn: { -// unsignedTxnPromise: transactionGenerator.getPayTxn(config.client, -// config.maliciousAccount.addr, config.maliciousAccount.addr, -// 1000, false), -// senderAcct: config.maliciousAccount -// } -// },*/ -// -// ]; -// -describe.skip('ALGO ESCROW ORDER BOOK (opt in test)', () => { +describe('ALGO ESCROW ORDER BOOK (opt in test)', () => { + const amount = 0.8; + const price = 1.2; beforeAll(async () => { await accountSetup(config, 'buy', false); await timeout(7000); // Eliminates race condition where future indexer calls occur before setUp step fully propogates but after it succeeds }, JEST_MINUTE_TIMEOUT); - // test('Create algo escrow order book', async () => { - // config.appId = await createAppTest.runTest(config, true); - // config.fakeAppId = await createAppTest.createFakeApp(config); - // global.ALGO_ESCROW_APP_ID = config.appId; - // expect(config.appId).toBeGreaterThan(0); - // config.oldCreatorAccount = config.creatorAccount; - // // make a new creatorAccount that hasn't been opted into any ASA - // config.creatorAccount = testHelper.getRandomAccount(); - // testHelper.transferFunds(config.client, config.openAccount, config.creatorAccount, 2000000); - // testHelper.transferFunds(config.client, config.openAccount, config.maliciousAccount, 2000000); - // }, JEST_MINUTE_TIMEOUT); - // negTests.map( (negTestTxnConfig) => { - // const testName = `Negative algo full execution order test: txnNum: ${negTestTxnConfig.txnNum} field: ${negTestTxnConfig.field} val: ${negTestTxnConfig.val}`; - // test(testName, async () => { - // if (negTestTxnConfig.negTxn) { - // negTestTxnConfig.negTxn.unsignedTxn = await negTestTxnConfig.negTxn.unsignedTxnPromise; - // } - // const outerTxns = await executeAlgoOrderTest.runFullExecTest(config, true); - // outerTxns.map( (txn) => { - // const unsignedTxn = txn.unsignedTxn; - // // console.log({unsignedTxn}); - // }); - // const result = await testHelper.runNegativeTest(config, config.client, outerTxns, negTestTxnConfig); - // expect(result).toBeTruthy(); - // }, JEST_MINUTE_TIMEOUT); - // }); + afterAll(async () => { + await timeout(4000); + await accountCleanup(config, 'buy', false); + }, JEST_MINUTE_TIMEOUT); test( 'Place algo escrow order', async () => { - // let asaBalance = await testHelper.getAssetBalance( - // config.creatorAccount.addr, - // config.assetId - // ); - // expect(asaBalance).toBeNull(); - - const result = await placeAlgoOrderTest.runTest(config, 0.8, 1.2); + const result = await placeAlgoOrderTest.runTest(config, amount, price); expect(result).toBeTruthy(); - - // asaBalance = await testHelper.getAssetBalance( - // config.creatorAccount.addr, - // config.assetId - // ); - // expect(asaBalance).toEqual(0); }, JEST_MINUTE_TIMEOUT ); - // test( - // 'Close algo escrow order', - // async () => { - // const result = await closeOrderTest.runTest(config, 1.2); - // expect(result).toBeTruthy(); - // }, - // JEST_MINUTE_TIMEOUT - // ); - - // test( - // 'Delete algo escrow order book', - // async () => { - // await testHelper.closeAccount( - // config.client, - // config.creatorAccount, - // config.openAccount - // ); - // config.creatorAccount = config.oldCreatorAccount; - // const result = await deleteAppTest.runTest(config); - // expect(result).toBeTruthy(); - // }, - // JEST_MINUTE_TIMEOUT - // ); + test( + 'Close algo escrow order', + async () => { + const result = await closeAlgoOrderTest.runTest(config, price, amount); + expect(result).toBeTruthy(); + }, + JEST_MINUTE_TIMEOUT + ); });