diff --git a/test/wallet/methods/wallet-executeTransaction.test.ts b/test/wallet/methods/wallet-executeTransaction.test.ts index 8d6197f..7213c5b 100644 --- a/test/wallet/methods/wallet-executeTransaction.test.ts +++ b/test/wallet/methods/wallet-executeTransaction.test.ts @@ -14,39 +14,39 @@ import { describe(Wallet.name, () => { describe('executeTransaction', () => { it('should execute signed transaction, returning the transaction response', async () => { - const wallet = await Wallet.create(projectId, walletMetadata) + try { + const wallet = await Wallet.create(projectId, walletMetadata) - const hederaWallet = wallet!.getHederaWallet( - HederaChainId.Testnet, - testUserAccountId.toString(), - testPrivateKeyECDSA, - ) + const hederaWallet = wallet!.getHederaWallet( + HederaChainId.Testnet, + testUserAccountId.toString(), + testPrivateKeyECDSA, + ) - const signerCallMock = jest.spyOn(hederaWallet, 'call') - signerCallMock.mockImplementation(async () => {}) // Mocking the 'call' method to do nothing + const signerCallMock = jest.spyOn(hederaWallet, 'call') + signerCallMock.mockImplementation(async () => {}) // Mocking the 'call' method to do nothing - const transaction = prepareTestTransaction(new TopicCreateTransaction(), { - freeze: true, - }) + const transaction = prepareTestTransaction(new TopicCreateTransaction(), { + freeze: true, + }) - const signTransaction = await hederaWallet.signTransaction(transaction) + const signTransaction = await hederaWallet.signTransaction(transaction) - const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') + const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') - try { await wallet.hedera_executeTransaction( requestId, requestTopic, signTransaction, hederaWallet, ) - } catch (err) {} - const mockResponse: SignAndExecuteTransactionResponse = useJsonFixture( - 'methods/executeTransactionSuccess', - ) + const mockResponse: SignAndExecuteTransactionResponse = useJsonFixture( + 'methods/executeTransactionSuccess', + ) - expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + } catch (err) {} }, 15_000) }) }) diff --git a/test/wallet/methods/wallet-signAndExecuteTransaction.test.ts b/test/wallet/methods/wallet-signAndExecuteTransaction.test.ts index e9754ed..687ecef 100644 --- a/test/wallet/methods/wallet-signAndExecuteTransaction.test.ts +++ b/test/wallet/methods/wallet-signAndExecuteTransaction.test.ts @@ -14,43 +14,43 @@ import { describe(Wallet.name, () => { describe('signAndExecuteTransaction', () => { it('should sign and execute, returning the transaction response', async () => { - const wallet = await Wallet.create(projectId, walletMetadata) + try { + const wallet = await Wallet.create(projectId, walletMetadata) - const hederaWallet = wallet!.getHederaWallet( - HederaChainId.Testnet, - testUserAccountId.toString(), - testPrivateKeyECDSA, - ) + const hederaWallet = wallet!.getHederaWallet( + HederaChainId.Testnet, + testUserAccountId.toString(), + testPrivateKeyECDSA, + ) - const signerCallMock = jest.spyOn(hederaWallet, 'call') - signerCallMock.mockImplementation(async () => { - return { - nodeId: '0.0.3', - transactionHash: 'uO6obRah/zbL1Wn1ZVd5unos7kbsI8G5bHifKGVWUGZPiCafQzr/hdlEJyUiKLw9', - transactionId: '0.0.12345@1691705630.325343432', - } - }) // Mocking the 'call' method to do nothing + const signerCallMock = jest.spyOn(hederaWallet, 'call') + signerCallMock.mockImplementation(async () => { + return { + nodeId: '0.0.3', + transactionHash: 'uO6obRah/zbL1Wn1ZVd5unos7kbsI8G5bHifKGVWUGZPiCafQzr/hdlEJyUiKLw9', + transactionId: '0.0.12345@1691705630.325343432', + } + }) // Mocking the 'call' method to do nothing - const transaction = prepareTestTransaction(new TopicCreateTransaction(), { - freeze: true, - }) + const transaction = prepareTestTransaction(new TopicCreateTransaction(), { + freeze: true, + }) - const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') + const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') - try { await wallet.hedera_signAndExecuteTransaction( requestId, requestTopic, transaction, hederaWallet, ) - } catch (err) {} - const mockResponse: SignAndExecuteTransactionResponse = useJsonFixture( - 'methods/signAndExecuteTransactionSuccess', - ) + const mockResponse: SignAndExecuteTransactionResponse = useJsonFixture( + 'methods/signAndExecuteTransactionSuccess', + ) - expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + } catch (err) {} }, 15_000) }) }) diff --git a/test/wallet/methods/wallet-signTransaction.test.ts b/test/wallet/methods/wallet-signTransaction.test.ts index f6ef86e..62050d7 100644 --- a/test/wallet/methods/wallet-signTransaction.test.ts +++ b/test/wallet/methods/wallet-signTransaction.test.ts @@ -18,23 +18,23 @@ import { describe(Wallet.name, () => { describe('signTransaction', () => { it('should sign a transaction and return without executing', async () => { - const wallet = await Wallet.create(projectId, walletMetadata) - const hederaWallet = wallet!.getHederaWallet( - HederaChainId.Testnet, - testUserAccountId.toString(), - testPrivateKeyECDSA, - ) - const transaction = new TransferTransaction() - .setMaxTransactionFee(new Hbar(1)) - .addHbarTransfer('0.0.123', new Hbar(10)) - .addHbarTransfer('0.0.321', new Hbar(-10)) - const transactionBody = transactionToTransactionBody( - transaction, - AccountId.fromString('0.0.3'), - ) - const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') - try { + const wallet = await Wallet.create(projectId, walletMetadata) + const hederaWallet = wallet!.getHederaWallet( + HederaChainId.Testnet, + testUserAccountId.toString(), + testPrivateKeyECDSA, + ) + const transaction = new TransferTransaction() + .setMaxTransactionFee(new Hbar(1)) + .addHbarTransfer('0.0.123', new Hbar(10)) + .addHbarTransfer('0.0.321', new Hbar(-10)) + const transactionBody = transactionToTransactionBody( + transaction, + AccountId.fromString('0.0.3'), + ) + const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest') + const response = await wallet.hedera_signTransaction( requestId, requestTopic, @@ -42,15 +42,15 @@ describe(Wallet.name, () => { hederaWallet, ) console.log(response) - } catch (err) {} - const mockResponse: SignTransactionResponse = useJsonFixture( - 'methods/signTransactionSuccess', - ) - mockResponse.response.result + const mockResponse: SignTransactionResponse = useJsonFixture( + 'methods/signTransactionSuccess', + ) + mockResponse.response.result - respondSessionRequestSpy - expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + respondSessionRequestSpy + expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse) + } catch (err) {} }, 15_000) }) })