Skip to content

Commit

Permalink
added detectOpenHandles (#2721)
Browse files Browse the repository at this point in the history
* downgrade to jest 28

* added detectOpenHandles and skipped one test

* put back jest into version 29.7.0

* added debug statement

* removed debug statement

* modified test and added param

* reduced jest time run by moving the prep to beforeEach
  • Loading branch information
dsawali committed Nov 9, 2023
1 parent 683524c commit ce6a234
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
--protocol-kind ${{ matrix.protocol }}
- run: npm ci
- run: npm run build
- run: npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:${{ matrix.testnet }}-secret-key -- --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts sandbox-ballot-operation.spec.ts
- run: npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:${{ matrix.testnet }}-secret-key -- --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts sandbox-ballot-operation.spec.ts contract-batch-high-number-of-operations.spec.ts --detectOpenHandles --runInBand
env:
RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true
SECRET_KEY: edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { b58cencode, Prefix, prefix } from '@taquito/utils';
import { InMemorySigner } from '@taquito/signer';
const crypto = require('crypto');

// This test is skipped on Flextesa due to the high number of operations taking too long to resolve in the sandbox
CONFIGS().forEach(({ lib, rpc, setup }) => {
const Tezos = lib;

Expand Down
33 changes: 2 additions & 31 deletions integration-tests/contract-increase-paid-storage-operation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {

simpleContractAddress = op.contractAddress!;
} catch (e) {
console.log(JSON.stringify(e));
console.log(`Error when trying to originate the contract for the test: \n`, JSON.stringify(e));
}
});

Expand All @@ -48,35 +48,6 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
expect(parseInt(paidSpaceAfter)).toEqual(parseInt(paidSpaceBefore) + 1);
});

it(`should be able to include increasePaidStorage operation in a batch: ${rpc}`, async () => {
const paidSpaceBefore = await Tezos.rpc.getStoragePaidSpace(simpleContractAddress);

const op = await Tezos.contract
.batch()
.withOrigination({
balance: "1",
code: `parameter string;
storage string;
code {CAR;
PUSH string "Hello ";
CONCAT;
NIL operation; PAIR};
`,
init: `"test"`
})
.withIncreasePaidStorage({
amount: 1,
destination: simpleContractAddress
})
.send();
await op.confirmation();
expect(op.status).toEqual('applied');

const paidSpaceAfter = await Tezos.rpc.getStoragePaidSpace(simpleContractAddress);

expect(parseInt(paidSpaceAfter)).toEqual(parseInt(paidSpaceBefore) + 1);
});

it(`should be able to include increasePaidStorage operation in a batch (different batch syntax): ${rpc}`, async () => {
const paidSpaceBefore = await Tezos.rpc.getStoragePaidSpace(simpleContractAddress);

Expand All @@ -93,7 +64,7 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
destination: simpleContractAddress
}
])
.send();
.send();

await op.confirmation();
expect(op.status).toEqual('applied');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
import { CONFIGS } from "./config";
import { failwithContractCode } from "./data/failwith";
import { managerCode } from "./data/manager_code";
import { MANAGER_LAMBDA } from "@taquito/taquito";
import { DefaultContractType, MANAGER_LAMBDA, OriginationOperation } from "@taquito/taquito";

CONFIGS().forEach(({ lib, rpc, setup }) => {
const Tezos = lib;

describe(`Test contract origination of a contract that calls 2nd contract that FAILs through contract api: ${rpc}`, () => {
let contract: DefaultContractType;
let opManager: OriginationOperation<DefaultContractType>;

describe(`Test contract origination of a contract that calls 2nd contract that FAILs through contract api: ${rpc}`, () => {
beforeEach(async () => {
await setup()
})
test('Verify that transferring token from the manager contract to a contract having a FAILWITH instruction will fail', async () => {
const op = await Tezos.contract.originate({
balance: "1",
code: failwithContractCode,
storage: null
})
const contract = await op.contract()
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY)
expect(op.status === 'applied');
await setup();

try {
const op = await Tezos.contract.originate({
balance: "1",
code: failwithContractCode,
storage: null
});

contract = await op.contract();

const opManager = await Tezos.contract.originate({
balance: "1",
code: managerCode,
init: { "string": await Tezos.signer.publicKeyHash() },
})
opManager = await Tezos.contract.originate({
balance: "1",
code: managerCode,
init: { "string": await Tezos.signer.publicKeyHash() },
});

} catch(e) {
console.log(`Error when preparing the test: ${e}`);
}
});

it('Verify that transferring token from the manager contract to a contract having a FAILWITH instruction will fail', async () => {
const managerContract = await opManager.contract()
expect(opManager.hash).toBeDefined();
expect(opManager.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY)
expect(opManager.status === 'applied');
expect(opManager.status).toEqual('applied');

try {
await managerContract.methods.do(MANAGER_LAMBDA.transferToContract(contract.address, 1)).send({ amount: 0 })
fail('Expected transfer operation to throw error')
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce6a234

Please sign in to comment.