From c089a05fb621b2197ea25f9ab2929a7e5463cddf Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Fri, 15 Mar 2024 17:01:52 +0200 Subject: [PATCH] fix tests --- src/smartcontracts/interaction.local.net.spec.ts | 3 ++- .../smartContractResults.local.net.spec.ts | 2 +- src/testutils/contractController.ts | 13 +++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/smartcontracts/interaction.local.net.spec.ts b/src/smartcontracts/interaction.local.net.spec.ts index 6650e9075..292814b40 100644 --- a/src/smartcontracts/interaction.local.net.spec.ts +++ b/src/smartcontracts/interaction.local.net.spec.ts @@ -3,7 +3,8 @@ import { assert } from "chai"; import { loadAbiRegistry, loadTestWallets, prepareDeployment, TestWallet } from "../testutils"; import { ContractController } from "../testutils/contractController"; import { createLocalnetProvider } from "../testutils/networkProviders"; -import { Transaction, TransactionComputer } from "../transaction"; +import { Transaction } from "../transaction"; +import { TransactionComputer } from "../transactionComputer"; import { Interaction } from "./interaction"; import { ReturnCode } from "./returnCode"; import { SmartContract } from "./smartContract"; diff --git a/src/smartcontracts/smartContractResults.local.net.spec.ts b/src/smartcontracts/smartContractResults.local.net.spec.ts index f465fc7c7..731c0b185 100644 --- a/src/smartcontracts/smartContractResults.local.net.spec.ts +++ b/src/smartcontracts/smartContractResults.local.net.spec.ts @@ -9,7 +9,7 @@ import { TransactionsFactoryConfig } from "../transactionsFactories/transactions import { SmartContractTransactionsFactory } from "../transactionsFactories/smartContractTransactionsFactory"; import { TokenComputer } from "../tokens"; import { promises } from "fs"; -import { TransactionComputer } from "../transaction"; +import { TransactionComputer } from "../transactionComputer"; describe("fetch transactions from local testnet", function () { let alice: TestWallet; diff --git a/src/testutils/contractController.ts b/src/testutils/contractController.ts index 0e1bcd071..8df126fb5 100644 --- a/src/testutils/contractController.ts +++ b/src/testutils/contractController.ts @@ -3,7 +3,8 @@ import { Logger } from "../logger"; import { Interaction } from "../smartcontracts/interaction"; import { TypedOutcomeBundle, UntypedOutcomeBundle } from "../smartcontracts/interface"; import { ResultsParser } from "../smartcontracts/resultsParser"; -import { Transaction, TransactionComputer, TransactionNext } from "../transaction"; +import { Transaction } from "../transaction"; +import { TransactionComputer } from "../transactionComputer"; import { TransactionWatcher } from "../transactionWatcher"; import { INetworkProvider } from "./networkProviders"; @@ -20,7 +21,7 @@ export class ContractController { }); } - async deploy(transaction: Transaction | TransactionNext): Promise<{ transactionOnNetwork: ITransactionOnNetwork, bundle: UntypedOutcomeBundle }> { + async deploy(transaction: Transaction): Promise<{ transactionOnNetwork: ITransactionOnNetwork, bundle: UntypedOutcomeBundle }> { const txHash = this.getTransactionHash(transaction); Logger.info(`ContractController.deploy [begin]: transaction = ${txHash}`); @@ -32,7 +33,7 @@ export class ContractController { return { transactionOnNetwork, bundle }; } - async execute(interaction: Interaction, transaction: Transaction | TransactionNext): Promise<{ transactionOnNetwork: ITransactionOnNetwork, bundle: TypedOutcomeBundle }> { + async execute(interaction: Interaction, transaction: Transaction): Promise<{ transactionOnNetwork: ITransactionOnNetwork, bundle: TypedOutcomeBundle }> { const txHash = this.getTransactionHash(transaction); Logger.info(`ContractController.execute [begin]: function = ${interaction.getFunction()}, transaction = ${txHash}`); @@ -58,11 +59,7 @@ export class ContractController { return bundle; } - private getTransactionHash(transaction: Transaction | TransactionNext): string { - if ("toSendable" in transaction){ - return transaction.getHash().hex(); - } - + private getTransactionHash(transaction: Transaction): string { const transactionComputer = new TransactionComputer(); const txHash = transactionComputer.computeTransactionHash(transaction); return Buffer.from(txHash).toString("hex");