Skip to content

Failing statement inside require error message has inconsistent quotation marks #312

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

Closed
rkalis opened this issue Jun 10, 2025 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@rkalis
Copy link
Member

rkalis commented Jun 10, 2025

We have this contract:

contract SiblingIntrospection(bytes expectedLockingBytecode) {
    function spend() {
        require(this.activeInputIndex == 0);

        bytes inputBytecode = tx.inputs[1].lockingBytecode;
        console.log("inputBytecode:", inputBytecode);
        require(inputBytecode == expectedLockingBytecode, "input bytecode should match");

        bytes outputBytecode = tx.outputs[1].lockingBytecode;
        console.log("outputBytecode:", outputBytecode);
        require(outputBytecode == expectedLockingBytecode, "output bytecode should match");
    }
}

And in the tests we have to do this to make it work (two different quotation marks)

it('should fail with correct error message when introspected input bytecode of a sibling UTXO does not match', () => {
        const tx = new TransactionBuilder({ provider })
          .addInput(siblingIntrospectionUtxo, siblingIntrospectionContract.unlock.spend())
          .addInput(incorrectContractUtxo, incorrectContract.unlock.spend(bobPub, bobSignatureTemplate))
          .addOutput({ to: siblingIntrospectionContract.address, amount: siblingIntrospectionUtxo.satoshis })
          .addOutput({ to: correctContract.address, amount: incorrectContractUtxo.satoshis - 2000n });

        expect(tx).toFailRequireWith('SiblingIntrospection.cash:7 Require statement failed at input 0 in contract SiblingIntrospection.cash at line 7 with the following message: input bytecode should match.');
        expect(tx).toFailRequireWith('Failing statement: require(inputBytecode == expectedLockingBytecode, \'input bytecode should match\')');
      });

      it('should fail with correct error message when introspected output bytecode of a sibling UTXO does not match', () => {
        const tx = new TransactionBuilder({ provider })
          .addInput(siblingIntrospectionUtxo, siblingIntrospectionContract.unlock.spend())
          .addInput(correctContractUtxo, correctContract.unlock.spend(alicePub, new SignatureTemplate(alicePriv)))
          .addOutput({ to: siblingIntrospectionContract.address, amount: siblingIntrospectionUtxo.satoshis })
          .addOutput({ to: incorrectContract.address, amount: correctContractUtxo.satoshis - 2000n });

        expect(tx).toFailRequireWith('SiblingIntrospection.cash:11 Require statement failed at input 0 in contract SiblingIntrospection.cash at line 11 with the following message: output bytecode should match.');
        expect(tx).toFailRequireWith('Failing statement: require(outputBytecode == expectedLockingBytecode, "output bytecode should match")');
      });
@rkalis rkalis added the bug Something isn't working label Jun 10, 2025
@mr-zwets mr-zwets modified the milestones: v0.12.0, v0.11 Jun 14, 2025
@rkalis
Copy link
Member Author

rkalis commented Jun 16, 2025

We fixed this bug.

@rkalis rkalis closed this as completed Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants