Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added detectOpenHandles #2721

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion for future: we can have a helper function isSandbox and skip tests in the spec.ts files. This will make it explicit that the test is skipped in sandbox, in the test file. Also, currently different tests will be run if we run tests according to the README file, vs what happens in the CI.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for future, when some data is needed in a test, we can create a function that's called in the it and returns the needed data. It's functionally not important, as tests inside one file are run in series and not in parallel,

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.