Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schimih committed Sep 12, 2022
1 parent 823115d commit 2bceb55
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/relayedTransactionV2Builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});

Expand Down
20 changes: 10 additions & 10 deletions src/smartcontracts/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});

Expand All @@ -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);
Expand Down Expand Up @@ -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}`);
});

Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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: [] });
Expand All @@ -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));
Expand Down
6 changes: 5 additions & 1 deletion src/transaction.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ 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);
let initialBalanceOfBob = new BigNumber(bob.account.balance.toString());

let transactionOne = new Transaction({
receiver: bob.address,
sender: alice.address,
value: TokenPayment.egldFromAmount(42),
gasLimit: network.MinGasLimit,
chainID: network.ChainID
});

let transactionTwo = new Transaction({
receiver: bob.address,
sender: alice.address,
value: TokenPayment.egldFromAmount(43),
gasLimit: network.MinGasLimit,
chainID: network.ChainID
Expand Down Expand Up @@ -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
});
Expand All @@ -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
});
Expand Down

0 comments on commit 2bceb55

Please sign in to comment.