diff --git a/src/test/e2e-emulated/__snapshots__/structs.spec.ts.snap b/src/test/e2e-emulated/__snapshots__/structs.spec.ts.snap index fa8082b0..537f41e2 100644 --- a/src/test/e2e-emulated/__snapshots__/structs.spec.ts.snap +++ b/src/test/e2e-emulated/__snapshots__/structs.spec.ts.snap @@ -281,3 +281,50 @@ exports[`structs should implement structs correctly 12`] = ` }, } `; + +exports[`structs should implement structs correctly 13`] = ` +[ + { + "$seq": 1, + "events": [ + { + "$type": "storage-charged", + "amount": "0.000000014", + }, + { + "$type": "received", + "message": { + "body": { + "text": "example", + "type": "text", + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQCrlBLOnYwuUVhoEd9stnroUM3J7rKXhQIS3FIYvrDLvXrj", + "type": "internal", + "value": "10", + }, + }, + { + "$type": "failed", + "errorCode": 9, + "errorMessage": "Cell underflow", + }, + { + "$type": "sent-bounced", + "message": { + "body": { + "cell": "x{FFFFFFFF000000006578616D706C65}", + "type": "cell", + }, + "bounce": false, + "from": "kQCrlBLOnYwuUVhoEd9stnroUM3J7rKXhQIS3FIYvrDLvXrj", + "to": "@treasure(treasure)", + "type": "internal", + "value": "9.993898", + }, + }, + ], + }, +] +`; diff --git a/src/test/e2e-emulated/contracts/structs.tact b/src/test/e2e-emulated/contracts/structs.tact index 31b79e3f..bdef6d06 100644 --- a/src/test/e2e-emulated/contracts/structs.tact +++ b/src/test/e2e-emulated/contracts/structs.tact @@ -30,6 +30,15 @@ message MyMessage1 { s: MyStruct2; } +struct Coin { + first: Int as coins; + second: Int as uint32; +} + +fun directParse(payload: Cell): Coin { + return Coin.fromCell(payload); +} + contract StructsTester { s1: S = S {a: false, b: 21 + 21}; s2: S; @@ -134,4 +143,15 @@ contract StructsTester { let s = globalConstStruct.s; return s; } + + receive("example") { + let coin = directParse( + beginCell() + .storeCoins(42) + .storeUint(35, 31) + .endCell() + ); + dump(coin.first); + dump(coin.second); + } } \ No newline at end of file diff --git a/src/test/e2e-emulated/structs.spec.ts b/src/test/e2e-emulated/structs.spec.ts index eb7e6334..e5ea02eb 100644 --- a/src/test/e2e-emulated/structs.spec.ts +++ b/src/test/e2e-emulated/structs.spec.ts @@ -26,6 +26,7 @@ describe("structs", () => { const contract = system.open(await StructsTester.fromInit()); await contract.send(treasure, { value: toNano("10") }, null); await system.run(); + const tracker = system.track(contract.address); expect(await contract.getStructInitializerTest()).toEqual(true); @@ -224,5 +225,11 @@ describe("structs", () => { expect( await contract.getGlobalConstStructConstantFieldViaVar(), ).toEqual(s6.s); + + // https://github.com/tact-lang/tact/issues/472 + + await contract.send(treasure, { value: toNano("10") }, "example"); + await system.run(); + expect(tracker.collect()).toMatchSnapshot(); }); }); diff --git a/tact.config.json b/tact.config.json index d67046a3..37b171ca 100644 --- a/tact.config.json +++ b/tact.config.json @@ -337,7 +337,10 @@ { "name": "structs", "path": "./src/test/e2e-emulated/contracts/structs.tact", - "output": "./src/test/e2e-emulated/contracts/output" + "output": "./src/test/e2e-emulated/contracts/output", + "options": { + "debug": true + } }, { "name": "initof",