-
-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viper contract deploy and testing #459
Comments
Because what happens when you deploy a smart contract (in any language) is that you are deploying the bytecode generated by the compiler, the tools used are actually somewhat agnostic to which language you end up using (Solidity, Viper, LLL, etc.) Personally, I like using pyethereum for testing purposes because it's written in python, which is the same module we use for the majority of our testing here. If you install pyethereum ( from viper import compiler
from ethereum.tools import tester
# Get a new chain
chain = tester.Chain()
# Set the viper compiler to run when the viper language is requested
tester.languages['viper'] = compiler.Compiler()
# Compile and apply __init__ method (using init_args
contract = chain.contract(source_code, language="viper", init_args, sender=..., value=..., etc.)
contract.myMethod() # Executes myMethod on the tester "chain"
chain.mine() # Mines the above transaction (and any before it) into a block Now for deployment against a "real" blockchain, you have several options: you can use a tool that can deploy the bytecode for you (which doesn't get pretty), or you can create your own process via py-testrpc and web3.py (which is what I am doing) to connect to a running instance of geth, deploy your bytecode, and interact with your deployed contracts. This is definitely a much more advanced step, but realistically using the You're right we need to actually come up with real tools and examples of how to do this eventually, especially the testing aspect. Let us know if you need some further answers on gitter and we'll keep this issue for us to create documentation on how to setup your own test suite for contracts (using the same tools we use to test our own e.g. here) |
@fubuloubu awesome detailed answer. Thank you, I'll try it soon and text further answers on gitter |
@fubuloubu Would be good to have the above information as a section 'Testing your contract' (or similar) in the docs, could just copy paste most of your answer ;) |
Sure, if I get time tomorrow I might do that. For my personal development work I've been working on a set of compilation and deployment modules I would love to make into more of a general development utility module for Ethereum. I know there is Populus but it's based on an older pyethereum and I don't really get the way it searches for contracts. |
Plus it's not extendable to viper |
@DavidKnott assign me to this so I don't forget the above |
@fubuloubu Assigning to someone who's not a collaborator doesn't work on github. But I can remind you 👍 |
@fubuloubu Thanks for creating some docs for this, I'm closing this issue. |
What's your issue about?
I see many tutorials about solidity contracts deploying and testing (without using real ETH transactions), but there is not the same for viper
I wanna learn/test/debug my contract, wanna see how it works (in local blockchain if is it possible)
Where can I find this information?
Cute Animal Picture
The text was updated successfully, but these errors were encountered: