Skip to content

We should generate test template as wrappers #3287

@skywardboundd

Description

@skywardboundd

Goal

Standardize contract tests and automate test generation for message receivers using a unified FromInitContract type compatible with Contract.fromInit().

Requirements

  1. FromInitContract Type

FromInitContract should match the type of Contract.fromInit

  1. 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

No one assigned

    Labels

    kind: testingTests (*.spec.ts)scope: ts-wrappersImplementation of TypeScript wrappers generation for Sandbox tests (src/bindings)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions