Skip to content

Commit

Permalink
Allow to turn on and off detailed gas tracing of main cases in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Skydev0h committed Oct 12, 2023
1 parent 5e9bfa0 commit c11545f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
6 changes: 6 additions & 0 deletions tests/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config: any = {
// Inspect per-instruction execution in primary (contest) test cases
microscope: false
}

export default config;
7 changes: 5 additions & 2 deletions tests/wallet-v5-extensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { TransactionDescriptionGeneric } from 'ton-core/src/types/TransactionDescription';
import { TransactionComputeVm } from 'ton-core/src/types/TransactionComputePhase';
import { buildBlockchainLibraries, LibraryDeployer } from '../wrappers/library-deployer';
import { default as config } from './config';

const WALLET_ID = new WalletId({ networkGlobalId: -239, workChain: 0, subwalletNumber: 0 });

Expand Down Expand Up @@ -104,14 +105,16 @@ describe('Wallet V5 extensions auth', () => {

const actions = packActionsList([new ActionSendMsg(SendMode.PAY_GAS_SEPARATELY, msg)]);

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }

const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
value: toNano('0.1'),
body: actions
});

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }

expect(receipt.transactions.length).toEqual(3);
accountForGas(receipt.transactions);
Expand Down
8 changes: 6 additions & 2 deletions tests/wallet-v5-external.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { WalletV4 } from '../wrappers/wallet-v4';
import { TransactionDescriptionGeneric } from 'ton-core/src/types/TransactionDescription';
import { TransactionComputeVm } from 'ton-core/src/types/TransactionComputePhase';
import { buildBlockchainLibraries, LibraryDeployer } from '../wrappers/library-deployer';
import { default as config } from './config';
import * as fs from "fs";

const WALLET_ID = new WalletId({ networkGlobalId: -239, workChain: -1, subwalletNumber: 0 });

Expand Down Expand Up @@ -153,11 +155,13 @@ describe('Wallet V5 sign auth external', () => {
)
.endCell();

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }

const receipt = await walletV5.sendExternalSignedMessage(createBody(actionsList));

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }

expect(receipt.transactions.length).toEqual(2);
accountForGas(receipt.transactions);
Expand Down
7 changes: 5 additions & 2 deletions tests/wallet-v5-internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { WalletV4 } from '../wrappers/wallet-v4';
import { TransactionDescriptionGeneric } from 'ton-core/src/types/TransactionDescription';
import { TransactionComputeVm } from 'ton-core/src/types/TransactionComputePhase';
import { buildBlockchainLibraries, LibraryDeployer } from '../wrappers/library-deployer';
import { default as config } from './config';

const WALLET_ID = new WalletId({ networkGlobalId: -239, workChain: 0, subwalletNumber: 0 });

Expand Down Expand Up @@ -147,14 +148,16 @@ describe('Wallet V5 sign auth internal', () => {
)
.endCell();

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: true, vmLogs: 'vm_logs_gas', debugLogs: true, print: true }

const receipt = await walletV5.sendInternalSignedMessage(sender, {
value: toNano(0.1),
body: createBody(actionsList)
});

blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }
if (config.microscope)
blockchain.verbosity = { ...blockchain.verbosity, blockchainLogs: false, vmLogs: 'none', debugLogs: false, print: false }

expect(receipt.transactions.length).toEqual(3);
accountForGas(receipt.transactions);
Expand Down

0 comments on commit c11545f

Please sign in to comment.