-
Notifications
You must be signed in to change notification settings - Fork 203
Labels
kind: testingTests (*.spec.ts)Tests (*.spec.ts)scope: ts-wrappersImplementation of TypeScript wrappers generation for Sandbox tests (src/bindings)Implementation of TypeScript wrappers generation for Sandbox tests (src/bindings)
Description
Goal
Standardize contract tests and automate test generation for message receivers using a unified FromInitContract type compatible with Contract.fromInit().
Requirements
- FromInitContract Type
FromInitContract should match the type of Contract.fromInit
globalSetup
Function:
const globalSetup = async (
fromInitContract: FromInitContract: ,
) => {
const blockchain = await Blockchain.create();
const deployer = await blockchain.treasury("deployer");
const contract = blockchain.openContract(
await fromInitContracts(< some defaults >),
);
return { blockchain, owner, contract }
Receiver Test Generation
For each message receiver, generate
const test< Receive Message>(fromInitContract: FromInitContract) => {
const setup = async () => {
return await globalSetup(fromInitItem);
};
describe("<Receive Message>", () => { })
}
Contract Test Wrapper
For each contract, generate a wrapper that runs all receiver tests
export const test<ContractName> = (fromInitContract: FromInitContract) => {
test< Receive Message1>(fromInitItem);
...
test< Receive MessageX>(fromInitItem);
};
Usage example
test<ContractName>(Contract.fromInit.bind(Contract))
Metadata
Metadata
Assignees
Labels
kind: testingTests (*.spec.ts)Tests (*.spec.ts)scope: ts-wrappersImplementation of TypeScript wrappers generation for Sandbox tests (src/bindings)Implementation of TypeScript wrappers generation for Sandbox tests (src/bindings)