From 2bceb554e63b10b21ad7dcc6d0a4af24288b2760 Mon Sep 17 00:00:00 2001 From: schimih Date: Mon, 12 Sep 2022 13:34:27 +0300 Subject: [PATCH] fix tests --- src/relayedTransactionV2Builder.spec.ts | 2 +- src/smartcontracts/interaction.spec.ts | 20 ++++++++++---------- src/transaction.local.net.spec.ts | 6 +++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/relayedTransactionV2Builder.spec.ts b/src/relayedTransactionV2Builder.spec.ts index 7c4d2043..9e317590 100644 --- a/src/relayedTransactionV2Builder.spec.ts +++ b/src/relayedTransactionV2Builder.spec.ts @@ -73,7 +73,7 @@ describe("test relayed v2 transaction builder", function () { assert.equal( relayedTxV2.getData().toString(), - "relayedTxV2@000000000000000000010000000000000000000000000000000000000002ffff@0f@676574436f6e7472616374436f6e666967@b6c5262d9837853e2201de357c1cc4c9803988a42d7049d26b7785dd0ac2bd4c6a8804b6fd9cf845fe2c2a622774b1a2dbd0a417c9a0bc3f0563a85bd15e710a"); + "relayedTxV2@000000000000000000010000000000000000000000000000000000000002ffff@0f@676574436f6e7472616374436f6e666967@bcf4d4aa206c649855aced3168db9684c77bcc0a9a75793bf64fef462bea17afe51625acd11bb9dd84b068fec7661e4d63c2b787f7235f37c237775c9867c105"); }); }); diff --git a/src/smartcontracts/interaction.spec.ts b/src/smartcontracts/interaction.spec.ts index 6c401374..8bb952e6 100644 --- a/src/smartcontracts/interaction.spec.ts +++ b/src/smartcontracts/interaction.spec.ts @@ -19,12 +19,12 @@ import { BytesValue } from "./typesystem/bytes"; import { TokenPayment } from "../tokenPayment"; import { ContractQueryResponse } from "@elrondnetwork/erdjs-network-providers"; -describe("test smart contract interactor", function() { +describe("test smart contract interactor", function () { let dummyAddress = new Address("erd1qqqqqqqqqqqqqpgqak8zt22wl2ph4tswtyc39namqx6ysa2sd8ss4xmlj3"); let provider = new MockProvider(); let alice: TestWallet; - before(async function() { + before(async function () { ({ alice } = await loadTestWallets()); }); @@ -49,7 +49,7 @@ describe("test smart contract interactor", function() { let contract = new SmartContract({ address: dummyAddress }); let dummyFunction = new ContractFunction("dummy"); let alice = new Address("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); - + const TokenFoo = (amount: BigNumber.Value) => TokenPayment.fungibleFromAmount("FOO-6ce17b", amount, 0); const TokenBar = (amount: BigNumber.Value) => TokenPayment.fungibleFromAmount("BAR-5bc08f", amount, 3); const LKMEX = (nonce: number, amount: BigNumber.Value) => TokenPayment.metaEsdtFromAmount("LKMEX-aab910", nonce, amount, 18); @@ -94,7 +94,7 @@ describe("test smart contract interactor", function() { transaction = new Interaction(contract, dummyFunction, []) .withMultiESDTNFTTransfer([Strămoși(1), Strămoși(42)], alice) .buildTransaction(); - + assert.equal(transaction.getData().toString(), `MultiESDTNFTTransfer@${hexContractAddress}@02@${hexStrămoși}@01@01@${hexStrămoși}@2a@01@${hexDummyFunction}`); }); @@ -137,7 +137,7 @@ describe("test smart contract interactor", function() { assert.equal(transaction.getData().toString(), "getUltimateAnswer"); assert.equal( transaction.getHash().toString(), - "60d0956a8902c1179dce92d91bd9670e31b9a9cd07c1d620edb7754a315b4818" + "580056f13a82d1df9fed421be7ec3d1024c18fd8f4261c823c0fb3a8766d8561" ); transaction = interaction.withNonce(1).buildTransaction(); @@ -146,7 +146,7 @@ describe("test smart contract interactor", function() { assert.equal(transaction.getNonce().valueOf(), 1); assert.equal( transaction.getHash().toString(), - "acd207c38f6c3341b18d8ef331fa07ba49615fa12d7610aad5d8495293049f24" + "1ed7182a50302b061d833b772fa78460cb05f4c452ac01c7343d324ff58ad708" ); // Execute, and wait for execution @@ -160,7 +160,7 @@ describe("test smart contract interactor", function() { assert.isTrue(bundle.returnCode.equals(ReturnCode.Ok)); }); - it("should interact with 'counter'", async function() { + it("should interact with 'counter'", async function () { setupUnitTestWatcherTimeouts(); let abiRegistry = await loadAbiRegistry("src/testdata/counter.abi.json"); @@ -207,7 +207,7 @@ describe("test smart contract interactor", function() { assert.deepEqual(valueAfterDecrement!.valueOf(), new BigNumber(5)); }); - it("should interact with 'lottery-esdt'", async function() { + it("should interact with 'lottery-esdt'", async function () { setupUnitTestWatcherTimeouts(); let abiRegistry = await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"); @@ -256,7 +256,7 @@ describe("test smart contract interactor", function() { provider.mockGetTransactionWithAnyHashAsNotarizedWithOneResult("@6f6b@01"); let { bundle: { returnCode: statusReturnCode, values: statusReturnValues, firstValue: statusFirstValue } } = await controller.execute(statusInteraction, statusTransaction); - assert.equal(statusTransaction.getData().toString(),"status@6c75636b79"); + assert.equal(statusTransaction.getData().toString(), "status@6c75636b79"); assert.isTrue(statusReturnCode.equals(ReturnCode.Ok)); assert.lengthOf(statusReturnValues, 1); assert.deepEqual(statusFirstValue!.valueOf(), { name: "Running", fields: [] }); @@ -265,7 +265,7 @@ describe("test smart contract interactor", function() { let getLotteryInfoTransaction = getLotteryInfoInteraction.withNonce(15).buildTransaction(); await alice.signer.sign(getLotteryInfoTransaction); provider.mockGetTransactionWithAnyHashAsNotarizedWithOneResult("@6f6b@0000000b6c75636b792d746f6b656e000000010100000000000000005fc2b9dbffffffff00000001640000000a140ec80fa7ee88000000"); - let { bundle: { returnCode: infoReturnCode, values: infoReturnValues, firstValue: infoFirstValue} } = await controller.execute(getLotteryInfoInteraction, getLotteryInfoTransaction); + let { bundle: { returnCode: infoReturnCode, values: infoReturnValues, firstValue: infoFirstValue } } = await controller.execute(getLotteryInfoInteraction, getLotteryInfoTransaction); assert.equal(getLotteryInfoTransaction.getData().toString(), "getLotteryInfo@6c75636b79"); assert.isTrue(infoReturnCode.equals(ReturnCode.Ok)); diff --git a/src/transaction.local.net.spec.ts b/src/transaction.local.net.spec.ts index 403335ff..4c3b4314 100644 --- a/src/transaction.local.net.spec.ts +++ b/src/transaction.local.net.spec.ts @@ -21,7 +21,7 @@ describe("test transaction", function () { let provider = createLocalnetProvider(); let watcher = new TransactionWatcher(provider); let network = await provider.getNetworkConfig(); - + await alice.sync(provider); await bob.sync(provider); @@ -29,6 +29,7 @@ describe("test transaction", function () { let transactionOne = new Transaction({ receiver: bob.address, + sender: alice.address, value: TokenPayment.egldFromAmount(42), gasLimit: network.MinGasLimit, chainID: network.ChainID @@ -36,6 +37,7 @@ describe("test transaction", function () { let transactionTwo = new Transaction({ receiver: bob.address, + sender: alice.address, value: TokenPayment.egldFromAmount(43), gasLimit: network.MinGasLimit, chainID: network.ChainID @@ -71,6 +73,7 @@ describe("test transaction", function () { data: new TransactionPayload("helloWorld"), gasLimit: 70000, receiver: alice.address, + sender: alice.address, value: TokenPayment.egldFromAmount(1000), chainID: network.ChainID }); @@ -79,6 +82,7 @@ describe("test transaction", function () { data: new TransactionPayload("helloWorld"), gasLimit: 70000, receiver: alice.address, + sender: alice.address, value: TokenPayment.egldFromAmount(1000000), chainID: network.ChainID });