input-output-hk / plutus-apps

The Plutus application platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adversary Actions in ContractModel report a validation error.

locallycompact opened this issue · comments

Summary

Hi, in this paragraph in the documentation it reads:

https://playground.plutus.iohkdev.io/doc/plutus/tutorials/contract-testing.html#testing-only-via-contract-endpoints

One way to mitigate this problem is to add additional ‘attack’ endpoints to the contract under test, that carry out a 
variety of conceivable attacks. Our contract model would then model these attack actions as no-ops, to represent the fact that 
the attacks fail; our tests would then check that the attacks fail in all circumstances, and with all parameters.

I have tried to do this noop approach with a simple NFT contract where an adversary tries to mint more than one of the same TokenName here:

https://gitlab.homotopic.tech/plutus/contracts/nft/-/blob/18398d676c1082342a45fdfad1103f5edc827045/test/Plutus/ContractModel/NFT.hs

This doesn't work though, since the validation failure kills the contract instance and fails the test anyway.

Log here:

https://gitlab.homotopic.tech/plutus/contracts/nft/-/jobs/2929

Steps to reproduce the behavior

https://gitlab.homotopic.tech/plutus/contracts/nft

lc/adversary branch

Actual Result

Error

Expected Result

no error

Describe the approach you would take to fix this

No response

System info

NixOS

You need to catch the errors in the attacker Contract endpoint. The assumption is that crashing endpoints is bad.

Also, your properties appear to be failing because the slot numbers don't match between the model and the emulator - fixing this will help with some failures.

Closing. Reopen if the problem persists.

ezoic increase your site revenue