Skip to content

Commit 822d566

Browse files
committed
Fix tests
1 parent f9e7db3 commit 822d566

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

packages/cashc/test/generation/fixtures.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,10 @@ export const fixtures: Fixture[] = [
911911
contractName: 'Loopy',
912912
constructorInputs: [],
913913
abi: [{ name: 'doLoop', inputs: [] }],
914-
bytecode: 'OP_0 OP_0 OP_0 OP_0 OP_BEGIN OP_DUP OP_UTXOVALUE OP_4 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_DUP OP_1ADD OP_NIP OP_TXOUTPUTCOUNT OP_2DUP OP_LESSTHAN OP_DUP OP_IF OP_2 OP_PICK OP_OUTPUTTOKENCATEGORY OP_0 OP_EQUAL OP_NOT OP_NIP OP_DUP OP_IF OP_4 OP_PICK OP_3 OP_PICK OP_OUTPUTVALUE OP_ADD OP_5 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_FROMALTSTACK OP_ELSE OP_3 OP_PICK OP_1ADD OP_4 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_ENDIF OP_ENDIF OP_2DROP OP_DUP OP_TXINPUTCOUNT OP_GREATERTHANOREQUAL OP_UNTIL OP_2OVER OP_GREATERTHAN OP_VERIFY OP_OVER OP_0 OP_GREATERTHAN OP_VERIFY OP_2DROP OP_2DROP OP_1',
914+
bytecode: 'OP_0 OP_0 OP_0 OP_0 OP_BEGIN OP_DUP OP_UTXOVALUE OP_4 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_DUP OP_1ADD OP_NIP OP_TXOUTPUTCOUNT OP_2DUP OP_LESSTHAN OP_DUP OP_IF OP_2 OP_PICK OP_OUTPUTTOKENCATEGORY OP_0 OP_EQUAL OP_NOT OP_NIP OP_DUP OP_IF OP_4 OP_PICK OP_3 OP_PICK OP_OUTPUTVALUE OP_ADD OP_5 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_FROMALTSTACK OP_ELSE OP_3 OP_PICK OP_1ADD OP_4 OP_ROLL OP_DROP OP_SWAP OP_TOALTSTACK OP_SWAP OP_TOALTSTACK OP_SWAP OP_FROMALTSTACK OP_FROMALTSTACK OP_ENDIF OP_ENDIF OP_2DROP OP_DUP OP_TXINPUTCOUNT OP_GREATERTHANOREQUAL OP_UNTIL OP_2SWAP OP_GREATERTHAN OP_VERIFY OP_SWAP OP_0 OP_GREATERTHAN OP_NIP',
915915
debug: {
916-
bytecode: '000000006576c6547a757c6b7c6b7c6c6c768b77c46e9f76635279d100879177766354795379cc93557a757c6b7c6b7c6b7c6c6c6c6753798b547a757c6b7c6b7c6c6c68686d76c3a26670a0697800a0696d6d51',
917-
sourceMap: '3:23:3:24;4:24:4:25;5:25:5:26;6:16:6:17;8:8:26:39;9:33:9:34;:23::41:1;:12::42;;;;;;;;;;10:16:10:17:0;:::21:1;:12::22;12:20:12:37:0;13:21:13:26;::::1;15:16:15:17:0;:19:25:13;16:31:16:32;;:20::47:1;:51::53:0;:20:::1;;:16::54;18:20:18:21:0;:23:20:17;19:32:19:41;;:55::56;;:44::63:1;:32;:20::64;;;;;;;;;;;;;20:23:22:17:0;21:33:21:43;;:::47:1;:20::48;;;;;;;;;;20:23:22:17;15:19:25:13;8:11:26:9;26:17::18:0;:21::37;8:8::39:1;;28:16:28:36:0;::::1;:8::38;29:16:29:26:0;:29::30;:16:::1;:8::32;2:4:30:5;;',
916+
bytecode: '000000006576c6547a757c6b7c6b7c6c6c768b77c46e9f76635279d100879177766354795379cc93557a757c6b7c6b7c6b7c6c6c6c6753798b547a757c6b7c6b7c6c6c68686d76c3a26672a0697c00a077',
917+
sourceMap: '3:23:3:24;4:24:4:25;5:25:5:26;6:16:6:17;8:8:26:39;9:33:9:34;:23::41:1;:12::42;;;;;;;;;;10:16:10:17:0;:::21:1;:12::22;12:20:12:37:0;13:21:13:26;::::1;15:16:15:17:0;:19:25:13;16:31:16:32;;:20::47:1;:51::53:0;:20:::1;;:16::54;18:20:18:21:0;:23:20:17;19:32:19:41;;:55::56;;:44::63:1;:32;:20::64;;;;;;;;;;;;;20:23:22:17:0;21:33:21:43;;:::47:1;:20::48;;;;;;;;;;20:23:22:17;15:19:25:13;8:11:26:9;26:17::18:0;:21::37;8:8::39:1;;28:16:28:36:0;::::1;:8::38;29:16:29:26:0;:29::30;:8::32:1;2:4:30:5',
918918
logs: [
919919
{ ip: 68, line: 24, data: [{ stackIndex: 3, type: 'int', ip: 68 }] },
920920
],

packages/cashscript/test/debugging.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ describe('Debugging tests', () => {
164164

165165
it('should log inside a loop', async () => {
166166
const transaction = new TransactionBuilder({ provider })
167-
.addInput(contractUtxo, contractTestLogs.unlock.test_log_inside_loop())
168-
.addOutput({ to: contractTestLogs.address, amount: 10000n });
167+
.addInput(contractUtxo, contractTestLogInsideLoop.unlock.test_log_inside_loop())
168+
.addOutput({ to: contractTestLogInsideLoop.address, amount: 10000n });
169169

170-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 0$'));
171-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 1$'));
172-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 2$'));
173-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 3$'));
174-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 4$'));
175-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 5$'));
176-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 6$'));
177-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 7$'));
178-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 8$'));
179-
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:62 i: 9$'));
170+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 0$'));
171+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 1$'));
172+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 2$'));
173+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 3$'));
174+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 4$'));
175+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 5$'));
176+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 6$'));
177+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 7$'));
178+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 8$'));
179+
expect(transaction).toLog(new RegExp('^\\[Input #0] Test.cash:6 i: 9$'));
180180
});
181181

182182
it('should log inside a complex nested loop', async () => {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,19 @@ contract Test(pubkey owner) {
264264
require(tx.outputs[this.activeInputIndex].value == inputValue - 1000);
265265
}
266266
}
267+
}
267268
`;
268269

269270
const CONTRACT_TEST_LOG_INSIDE_LOOP = `
270271
contract Test() {
271272
function test_log_inside_loop() {
272-
int x = 0;
273+
int i = 0;
273274
do {
274-
console.log('x:', x);
275-
x = x + 1;
276-
} while (x < 10);
275+
console.log('i:', i);
276+
i = i + 1;
277+
} while (i < 10);
277278
278-
require(x == 10);
279+
require(i == 10);
279280
}
280281
281282
function test_log_inside_loop_complex() {

0 commit comments

Comments
 (0)