Open locallycompact opened 1 year ago
Can anyone shed any light on this? It's very confusing.
Are there any negative test cases for this contract i.e. cases where the contract is expected to fail?
I had a look at it. The Vesting
test aren't unit test about the validators, but integration tests that test both the OffChain and the OnChain code at the same time. The retrieve
endpoint do an off chain of the avaible founds before we try and submit the Tx, so the too permissive enchain code isn't checked in the end.
We should have add a test on the enchain code itself though, you're right.
A negative test case would not be a test of the on-chain code directly but an adversarial action that expects the model not to change.
Both are valid test scenarios actually, you want to check the behaviour of the onchain code and to protect yourself against malicious transaction.
I really don't see how. The validator only makes sense in the context you intend it to form a functioning contract. A validator by itself is not correct or incorrect, it just is what it is.
The validator itself is a function, you can use test to specify it and validates that it behaves as specified by the tests. You can then check if this specification is correct in the context of a functioning contract by providing adversarial attacks.
Your validator can respect the specification and the specification can be too weak to ensure properties of a functioning contract, or it can be what is needed. Checking both allows you to know if the validator is incorrect or if your specifications are too weak.
The validator is just a content-addressed predicate. The same validator in different contexts can be used for completely different behaviour. There is nothing to say by testing the validator in isolation except to say that it is that predicate. Everything that is testable is defined by what actions you perform and what should the result be.
We're derailing out of the scope of the issue and it's probably the best place to talk about It (not that I wouldn't like to, but I prefer to keep the comments focused on the initial issue). The issue is tracked. We'll see when and how we'll be able to address it.
Summary
applying this diff
still makes all the tests for this use case pass
Steps to reproduce the behavior
apply the diff
Actual Result
doesn't work
Expected Result
should work
Describe the approach you would take to fix this
No response
System info
nixos