Skip to content

Commit ffa4008

Browse files
committed
commit failing test case
1 parent 99ff71e commit ffa4008

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import {
2+
Contract,
3+
MockNetworkProvider,
4+
randomUtxo,
5+
SignatureTemplate,
6+
TransactionBuilder,
7+
} from './../src/index.js';
8+
import {
9+
bobAddress,
10+
bobPkh,
11+
bobPriv,
12+
bobPub,
13+
} from './fixture/vars.js';
14+
import p2pkhArtifact from './fixture/p2pkh.artifact.js';
15+
import bigintArtifact from './fixture/bigint.artifact.js';
16+
import '../src/test/JestExtensions.js';
17+
18+
const bobSignatureTemplate = new SignatureTemplate(bobPriv);
19+
20+
const provider = new MockNetworkProvider();
21+
22+
describe('Multi-Contract-Debugging tests', () => {
23+
describe('require statements', () => {
24+
it('it should only fail with correct error message when a final verify fails', async () => {
25+
const p2pkhContract = new Contract(p2pkhArtifact, [bobPkh], { provider });
26+
const bigintContract = new Contract(bigintArtifact, [], { provider });
27+
28+
const MAX_INT64 = BigInt('9223372036854775807');
29+
30+
(provider as any).addUtxo?.(p2pkhContract.address, randomUtxo());
31+
(provider as any).addUtxo?.(bigintContract.address, randomUtxo());
32+
(provider as any).addUtxo?.(bobAddress, randomUtxo());
33+
34+
const to = p2pkhContract.address;
35+
const amount = 10000n;
36+
const p2pkhContractUtxos = await p2pkhContract.getUtxos();
37+
const bigIntContractUtxos = await bigintContract.getUtxos();
38+
const bobAddressUtxos = await provider.getUtxos(bobAddress);
39+
40+
// when
41+
const transaction = new TransactionBuilder({ provider })
42+
.addInput(p2pkhContractUtxos[0], p2pkhContract.unlock.spend(bobPub, bobSignatureTemplate))
43+
.addInput(bigIntContractUtxos[0], bigintContract.unlock.proofOfBigInt(MAX_INT64 + 1n, -1n))
44+
.addInput(bobAddressUtxos[0], bobSignatureTemplate.unlockP2PKH())
45+
.addOutput({ to, amount });
46+
47+
console.warn(transaction.bitauthUri());
48+
49+
await expect(transaction).toFailRequire();
50+
});
51+
});
52+
});

0 commit comments

Comments
 (0)