aleeusgr / potential-robot

minimal dApp testing suite
MIT License
3 stars 1 forks source link

write a how to on black box testing uplc #128

Open aleeusgr opened 1 year ago

aleeusgr commented 1 year ago

I would like to know if I can test a smart contract written in Plutus with the Helios library.

If you want to run automated tests on a validator using Helios Emulator, try my toolbox:

Hmm, I think I will need to look for something else. Unless I can find a way to port CBOR encoded Plutus script into Helios

cschmitz — 14/07/2023 12:01 That should be possible The tx builder only really cares about UplcProgram, which can be deserialized from cbor And the emulator only cares about the output of the tx builder No need to port anything to Helios

Implementation

omething like const uplcProgram = UplcProgram.fromCbor(""); // if it is a minting policy const mph = uplcProgram.mintingPolicyHash; tx.mintTokens(mph, [[, ], ...], ); tx.attachScript(uplcProgram); // if you want to send to a spending validator const vh = uplcProgram.validatorHash; const scriptAddress = Address.fromValidatorHash(vh); tx.addOutput(new TxOutput( scriptAddress, new Value(1000000) ); // if you want to spend from a validator tx.addInput(await network.getUtxos(scriptAddress)[0], ); tx.attachScript(uplcProgram); https://discord.com/channels/997177025972424815/997177026517676055/1129286387150106688