Comments (8)
One cool hack that was presented at EthLondon last weekend is Lurch, which allows evaluating arbitrary bytecode given some calldata.
We could implement the predicate as bytecode and pass it in to the MockContract. Then when the mock contract matches the method-name it could evaluate the bytecode given the calldata in lurch and if it returns true execute the given expectation.
I'm not sure how practical it will be to compile predicates into bytecode and if it could be done nicely in JS.
from mock-contract.
My two cents in case anyone cares: I feel like solidity needs some extra features before something like this can be implemented, unless you do something like deploying ad-hoc contracts, like @fleupold suggested.
More specifically, I think for doing this you should need to store information about how to decode a given calldata, but AFAIK you can't store a tuple of types, which is the type of the second parameter of abi.decode
:
abi.decode(someBytes, (uint, string))
I mean, someone calling a givenPredicateCalldata*
method should also provide info about how to decode this. If this is possible, I think #14 becomes much easier too.
from mock-contract.
@bh2smith Yeah, they are exercises, which will be posted in gitcoin. It is not specifically for trufflecon
from mock-contract.
This one is a little more tricky than the previous one. I was thinking that we could actually allow people to write the predicate as a boolean expression in solidity (with a somehow defined naming scheme for variables).
E.g. GREATER_THAN(10) could be implemented as
contract.method.givenConditionReturn("arg0 > 10", true)
which under the hood (in js) could be implemented by deploying a new contract instance (using something like this) which inherits MockContract, and implements the method something like:
function method(arg0, arg1, ...) returns (bool) {
if ($condition) {
return $returnValue
} else {
super.method(arg0, arg1, ...)
}
}
Of course there is still some more fine technical detail which has to be ironed out, which is why this task is definitely more involved than #14
But I'm also happy leaving it open like this to see if someone comes up with a better idea.
from mock-contract.
Don't forget to update this!
The MockContract allows for all of that without having to write a separate test contract each time.
with
The MockContract facilitates these features without requiring any separate test contracts.
from mock-contract.
Are these exercises to be given out for prizes at the trufflecon?
from mock-contract.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
This issue now has a funding of 0.75 ETH (159.1 USD @ $212.14/ETH) attached to it as part of the Gnosis fund.
- If you would like to work on this issue you can 'start work' on the Gitcoin Issue Details page.
- Want to chip in? Add your own contribution here.
- Questions? Checkout Gitcoin Help or the Gitcoin Slack
- $142,366.64 more funded OSS Work available on the Gitcoin Issue Explorer
from mock-contract.
Issue Status: 1. Open 2. Cancelled
The funding of 0.75 ETH (100.64 USD @ $134.18/ETH) attached to this issue has been cancelled by the bounty submitter
- Questions? Checkout Gitcoin Help or the Gitcoin Slack
- $80,006.89 more funded OSS Work available on the Gitcoin Issue Explorer
from mock-contract.
Related Issues (13)
- Usage of .getData() no longer works HOT 2
- Partially matching call arguments HOT 8
- Error: Could not find artifacts for .\MockContract.sol from any sources HOT 5
- Solidity 0.6 support
- Update NPM package HOT 1
- Returning array of values HOT 2
- Make it possible that the mock can call other contracts
- Mock return tuple with arrays HOT 1
- Publish latest version to NPM HOT 2
- Wierd behaviour with encodeABI
- View functions revert when mocked HOT 1
- Can't invoke mocked view functions more than 2 times in a single transaction HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mock-contract.