MCPcopy Create free account
hub / github.com/CashScript/cashscript / toFailRequireWith

Function toFailRequireWith

packages/cashscript/src/test/TestExtensions.ts:80–102  ·  view source on GitHub ↗
(
    transaction: Debuggable,
    match: RegExp | string,
  )

Source from the content-addressed store, hash-verified

78 }
79 },
80 toFailRequireWith(
81 transaction: Debuggable,
82 match: RegExp | string,
83 ) {
84 try {
85 transaction.debug();
86 const matcherHint = this.utils.matcherHint('.toFailRequireWith', undefined, match.toString(), { isNot: this.isNot });
87 const message = (): string => `${matcherHint}\n\nContract function did not fail a require statement.`;
88 return { message, pass: false };
89 } catch (transactionError: any) {
90 const matcherHint = this.utils.matcherHint('toFailRequireWith', 'received', 'expected', { isNot: this.isNot });
91 const expectedText = `Expected pattern: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(match)}`;
92 const receivedText = `Received string: ${this.utils.printReceived(transactionError?.message ?? '')}`;
93 const message = (): string => `${matcherHint}\n\n${expectedText}\n${receivedText}`;
94
95 try {
96 expect(transactionError?.message ?? '').toMatch(match);
97 return { message, pass: true };
98 } catch {
99 return { message, pass: false };
100 }
101 }
102 },
103});
104
105export { };

Callers

nothing calls this directly

Calls 2

debugMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected