Skip to content

Commit

Permalink
Enable calling multiple SUT functions per run
Browse files Browse the repository at this point in the history
  • Loading branch information
BowTiedRadone committed Jan 27, 2025
1 parent e19d170 commit cca2a33
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 149 deletions.
159 changes: 88 additions & 71 deletions heatstroke.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ describe("Custom reporter logging", () => {
numRuns: fc.nat(),
seed: fc.nat(),
contractName: fc.ascii(),
selectedFunction: fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
}),
functionArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
selectedFunctions: fc.array(
fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
})
),
selectedFunctionsArgsList: fc.tuple(
fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean()))
),
selectedInvariant: fc.record({
name: fc.ascii(),
access: fc.ascii(),
}),
invariantArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
),
invariantArgs: fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean())),
errorMessage: fc.ascii(),
sutCaller: fc.constantFrom(
...new Map(
Expand All @@ -49,17 +49,17 @@ describe("Custom reporter logging", () => {
numRuns: number;
seed: number;
contractName: string;
selectedFunction: {
selectedFunctions: {
name: string;
access: string;
outputs: string[];
};
functionArgsArb: (string | number | boolean)[];
}[];
selectedFunctionsArgsList: (string | number | boolean)[][];
selectedInvariant: {
name: string;
access: string;
};
invariantArgsArb: (string | number | boolean)[];
invariantArgs: (string | number | boolean)[];
errorMessage: string;
sutCaller: [string, string];
invariantCaller: [string, string];
Expand All @@ -79,17 +79,13 @@ describe("Custom reporter logging", () => {
counterexample: [
{
rendezvousContractId: rendezvousContractId,
selectedFunction: {
name: r.selectedFunction.name,
access: r.selectedFunction.access,
outputs: r.selectedFunction.outputs,
},
functionArgsArb: r.functionArgsArb,
selectedFunctions: r.selectedFunctions,
selectedFunctionsArgsList: r.selectedFunctionsArgsList,
selectedInvariant: {
name: r.selectedInvariant.name,
access: r.selectedInvariant.access,
},
invariantArgsArb: r.invariantArgsArb,
invariantArgs: r.invariantArgs,
sutCaller: r.sutCaller,
invariantCaller: r.invariantCaller,
},
Expand All @@ -108,12 +104,24 @@ describe("Custom reporter logging", () => {
`- Contract : ${getContractNameFromContractId(
rendezvousContractId
)}`,
`- Function : ${r.selectedFunction.name} (${r.selectedFunction.access})`,
`- Arguments: ${JSON.stringify(r.functionArgsArb)}`,
`- Functions: ${r.selectedFunctions
.map((selectedFunction) => selectedFunction.name)
.join(", ")} (${r.selectedFunctions
.map((selectedFunction) => selectedFunction.access)
.join(", ")})`,
`- Arguments: ${r.selectedFunctionsArgsList
.map((selectedFunctionArgs) =>
JSON.stringify(selectedFunctionArgs)
)
.join(", ")}`,
`- Caller : ${r.sutCaller[0]}`,
`- Outputs : ${JSON.stringify(r.selectedFunction.outputs)}`,
`- Outputs : ${r.selectedFunctions
.map((selectedFunction) =>
JSON.stringify(selectedFunction.outputs)
)
.join(", ")}`,
`- Invariant: ${r.selectedInvariant.name} (${r.selectedInvariant.access})`,
`- Arguments: ${JSON.stringify(r.invariantArgsArb)}`,
`- Arguments: ${JSON.stringify(r.invariantArgs)}`,
`- Caller : ${r.invariantCaller[0]}`,
`\nWhat happened? Rendezvous went on a rampage and found a weak spot:\n`,
`The invariant "${
Expand Down Expand Up @@ -144,21 +152,21 @@ describe("Custom reporter logging", () => {
numRuns: fc.nat(),
seed: fc.nat(),
contractName: fc.ascii(),
selectedFunction: fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
}),
functionArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
selectedFunctions: fc.array(
fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
})
),
selectedFunctionsArgsList: fc.tuple(
fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean()))
),
selectedInvariant: fc.record({
name: fc.ascii(),
access: fc.ascii(),
}),
invariantArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
),
invariantArgs: fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean())),
errorMessage: fc.ascii(),
sutCaller: fc.constantFrom(
...new Map(
Expand All @@ -177,17 +185,17 @@ describe("Custom reporter logging", () => {
numRuns: number;
seed: number;
contractName: string;
selectedFunction: {
selectedFunctions: {
name: string;
access: string;
outputs: string[];
};
functionArgsArb: (string | number | boolean)[];
}[];
selectedFunctionsArgsList: (string | number | boolean)[][];
selectedInvariant: {
name: string;
access: string;
};
invariantArgsArb: (string | number | boolean)[];
invariantArgs: (string | number | boolean)[];
errorMessage: string;
sutCaller: [string, string];
invariantCaller: [string, string];
Expand All @@ -208,17 +216,18 @@ describe("Custom reporter logging", () => {
counterexample: [
{
rendezvousContractId: rendezvousContractId,
selectedFunction: {
name: r.selectedFunction.name,
access: r.selectedFunction.access,
outputs: r.selectedFunction.outputs,
},
functionArgsArb: r.functionArgsArb,
selectedFunctions: r.selectedFunctions,
// {
// name: r.selectedFunction.name,
// access: r.selectedFunction.access,
// outputs: r.selectedFunction.outputs,
// },
selectedFunctionsArgsList: r.selectedFunctionsArgsList,
selectedInvariant: {
name: r.selectedInvariant.name,
access: r.selectedInvariant.access,
},
invariantArgsArb: r.invariantArgsArb,
invariantArgs: r.invariantArgs,
sutCaller: r.sutCaller,
invariantCaller: r.invariantCaller,
},
Expand All @@ -238,12 +247,24 @@ describe("Custom reporter logging", () => {
`- Contract : ${getContractNameFromContractId(
rendezvousContractId
)}`,
`- Function : ${r.selectedFunction.name} (${r.selectedFunction.access})`,
`- Arguments: ${JSON.stringify(r.functionArgsArb)}`,
`- Functions: ${r.selectedFunctions
.map((selectedFunction) => selectedFunction.name)
.join(", ")} (${r.selectedFunctions
.map((selectedFunction) => selectedFunction.access)
.join(", ")})`,
`- Arguments: ${r.selectedFunctionsArgsList
.map((selectedFunctionArgs) =>
JSON.stringify(selectedFunctionArgs)
)
.join(", ")}`,
`- Caller : ${r.sutCaller[0]}`,
`- Outputs : ${JSON.stringify(r.selectedFunction.outputs)}`,
`- Outputs : ${r.selectedFunctions
.map((selectedFunction) =>
JSON.stringify(selectedFunction.outputs)
)
.join(", ")}`,
`- Invariant: ${r.selectedInvariant.name} (${r.selectedInvariant.access})`,
`- Arguments: ${JSON.stringify(r.invariantArgsArb)}`,
`- Arguments: ${JSON.stringify(r.invariantArgs)}`,
`- Caller : ${r.invariantCaller[0]}`,
`\nWhat happened? Rendezvous went on a rampage and found a weak spot:\n`,
`The invariant "${
Expand Down Expand Up @@ -275,21 +296,21 @@ describe("Custom reporter logging", () => {
numRuns: fc.nat(),
seed: fc.nat(),
contractName: fc.ascii(),
selectedFunction: fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
}),
functionArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
selectedFunctions: fc.array(
fc.record({
name: fc.ascii(),
access: fc.ascii(),
outputs: fc.array(fc.ascii()),
})
),
selectedFunctionsArgsList: fc.tuple(
fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean()))
),
selectedInvariant: fc.record({
name: fc.ascii(),
access: fc.ascii(),
}),
invariantArgsArb: fc.array(
fc.oneof(fc.ascii(), fc.nat(), fc.boolean())
),
invariantArgs: fc.array(fc.oneof(fc.ascii(), fc.nat(), fc.boolean())),
errorMessage: fc.ascii(),
sutCaller: fc.constantFrom(
...new Map(
Expand All @@ -308,17 +329,17 @@ describe("Custom reporter logging", () => {
numRuns: number;
seed: number;
contractName: string;
selectedFunction: {
selectedFunctions: {
name: string;
access: string;
outputs: string[];
};
functionArgsArb: (string | number | boolean)[];
}[];
selectedFunctionsArgsList: (string | number | boolean)[][];
selectedInvariant: {
name: string;
access: string;
};
invariantArgsArb: (string | number | boolean)[];
invariantArgs: (string | number | boolean)[];
errorMessage: string;
sutCaller: [string, string];
invariantCaller: [string, string];
Expand All @@ -339,17 +360,13 @@ describe("Custom reporter logging", () => {
counterexample: [
{
rendezvousContractId: rendezvousContractId,
selectedFunction: {
name: r.selectedFunction.name,
access: r.selectedFunction.access,
outputs: r.selectedFunction.outputs,
},
functionArgsArb: r.functionArgsArb,
selectedFunction: r.selectedFunctions,
functionArgsArb: r.selectedFunctionsArgsList,
selectedInvariant: {
name: r.selectedInvariant.name,
access: r.selectedInvariant.access,
},
invariantArgsArb: r.invariantArgsArb,
invariantArgs: r.invariantArgs,
sutCaller: r.sutCaller,
invariantCaller: r.invariantCaller,
},
Expand Down
27 changes: 23 additions & 4 deletions heatstroke.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { green } from "ansicolor";
import { EventEmitter } from "events";
import { getContractNameFromContractId } from "./shared";
import { ContractInterfaceFunction } from "@hirosystems/clarinet-sdk-wasm";

/**
* Heatstrokes Reporter
Expand Down Expand Up @@ -49,24 +50,42 @@ export function reporter(
);
radio.emit(
"logFailure",
`- Function : ${r.selectedFunction.name} (${r.selectedFunction.access})`
`- Functions: ${r.selectedFunctions
.map(
(selectedFunction: ContractInterfaceFunction) =>
selectedFunction.name
)
.join(", ")} (${r.selectedFunctions
.map(
(selectedFunction: ContractInterfaceFunction) =>
selectedFunction.access
)
.join(", ")})`
);
radio.emit(
"logFailure",
`- Arguments: ${JSON.stringify(r.functionArgsArb)}`
`- Arguments: ${r.selectedFunctionsArgsList
.map((selectedFunctionArgs: any[]) =>
JSON.stringify(selectedFunctionArgs)
)
.join(", ")}`
);
radio.emit("logFailure", `- Caller : ${r.sutCaller[0]}`);
radio.emit(
"logFailure",
`- Outputs : ${JSON.stringify(r.selectedFunction.outputs)}`
`- Outputs : ${r.selectedFunctions
.map((selectedFunction: ContractInterfaceFunction) =>
JSON.stringify(selectedFunction.outputs)
)
.join(", ")}`
);
radio.emit(
"logFailure",
`- Invariant: ${r.selectedInvariant.name} (${r.selectedInvariant.access})`
);
radio.emit(
"logFailure",
`- Arguments: ${JSON.stringify(r.invariantArgsArb)}`
`- Arguments: ${JSON.stringify(r.invariantArgs)}`
);
radio.emit("logFailure", `- Caller : ${r.invariantCaller[0]}`);

Expand Down
Loading

0 comments on commit cca2a33

Please sign in to comment.