-
Notifications
You must be signed in to change notification settings - Fork 117
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
added detectOpenHandles #2721
Changes from all commits
ca9f9d9
c0f31dc
f5fbb54
04b22a7
e672d75
9748225
7732c2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
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') | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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 thespec.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 theREADME
file, vs what happens in the CI.