Skip to content

Commit 735fefa

Browse files
committed
Add more multicontract debugging tests
1 parent 81602c3 commit 735fefa

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/cashscript/test/fixture/debugging/multicontract_debugging_contracts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const SAME_NAME_DIFFERENT_PATH = `
44
contract SameNameDifferentPath(int a) {
55
function function_1(int b) {
66
if (a == 0) {
7+
console.log("a is 0");
78
require(b == 0, "b should be 0");
89
} else {
10+
console.log("a is not 0");
911
require(b != 0, "b should not be 0");
1012
}
1113
}

packages/cashscript/test/multi-contract-debugging.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,24 @@ describe('Multi-Contract-Debugging tests', () => {
7272
});
7373
});
7474

75-
it.todo('should not log statements that are not executed'); // Maybe this is already included in tests above
76-
it.todo('should still work with different instances of the same contract, with different paths due to different contract parameter values');
75+
it('should still work with different instances of the same contract, with different paths due to different contract parameter values', () => {
76+
const sameNameDifferentPathContract1 = new Contract(ARTIFACT_SAME_NAME_DIFFERENT_PATH, [0n], { provider });
77+
const sameNameDifferentPathContract2 = new Contract(ARTIFACT_SAME_NAME_DIFFERENT_PATH, [1n], { provider });
78+
79+
const sameNameDifferentPathContract1Utxo = randomUtxo();
80+
const sameNameDifferentPathContract2Utxo = randomUtxo();
81+
82+
(provider as any)?.addUtxo(sameNameDifferentPathContract1.address, sameNameDifferentPathContract1Utxo);
83+
(provider as any)?.addUtxo(sameNameDifferentPathContract2.address, sameNameDifferentPathContract2Utxo);
84+
85+
const tx = new TransactionBuilder({ provider })
86+
.addInput(sameNameDifferentPathContract1Utxo, sameNameDifferentPathContract1.unlock.function_1(0n))
87+
.addInput(sameNameDifferentPathContract2Utxo, sameNameDifferentPathContract2.unlock.function_1(1n))
88+
.addOutput({ to: sameNameDifferentPathContract1.address, amount: sameNameDifferentPathContract1Utxo.satoshis })
89+
.addOutput({ to: sameNameDifferentPathContract2.address, amount: sameNameDifferentPathContract2Utxo.satoshis });
90+
91+
expect(tx).toLog('SameNameDifferentPath.cash:5 a is 0\nSameNameDifferentPath.cash:8 a is not 0');
92+
});
7793
});
7894

7995
describe('require statements', () => {

0 commit comments

Comments
 (0)