-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add contract test CLI #716
Comments
Tagging @andrewvious again to see if that causes him to appear in the assignee list. |
Tagging myself to see if I can appear for the assignee list. |
Hey @andrewvious I just pushed some changes to the feat-test-cli branch. I was trying to get clever with clap, but apparently I'm not as clever as I thought, so I took the easy path for now 🙂 .
I may rename those subcommands to make them more consistent with each other... What we'll end up with is a set of command line subcommands that will allow a developer to script the testing of their smart contract locally, including the state. We'll tie it to ERC20 for now, but make it generic later. Here's a skeleton of what such as test script might look like once we've filled in the above: versatus-wasm init-test-db --dbpath ./test-state --default-balance 1000 || die "Test failed"
versatus-wasm assertbalance --dbpath ./test-state --address "0xdeadbeef" --value "1000" || die "Test failed"
versatus-wasm test --dbpath ./test-state --wasm ./contract.wasm --function "transfer" --inputs '{ "address": "0xdeadbeef", "value": "100" }' || die "Test failed"
versatus-wasm assertbalance --dbpath ./test-state --address "0xdeadbeef" --value "1100" || die "Test failed" The first two are probably the easiest to implement, and the third will likely be a little more fiddly. You'll likely import the versatus-rust crate from github for the data structures. We can go through the details of any of this as needed. I'll also try and copy/paste this message into github for posterity. How does that sound? |
This work was done to spec, but other forces mean work to be done to have this in main. Moving out of alphanet milestone and we'll come up with a plan for integrating the new stuff. |
Hey @andrewvious and @eureka-cpu . Here's another bit of code we can play with.
I'll put together a pull request for some changes to the wasm_cli crate to parse some new command line subcommands and options to aid developers in testing their smart contracts in isolation. I'll just create the CLI stubs and fill those in with specific details around what I want the code to do for each command. This'll be a change from previous tasks because you'll largely be writing new code rather than just modifying existing code, which I thought might be fun (and very helpful).
Essentially, the bits of code you'll be adding will manipulate some local state. I was thinking a simple sqlite3 database, but I'm open to anything. It'll just be a couple of tables -- one containing some fake accounts (addresses and balances) and one with some other metadata. The other thing we'll do use the wasm_runtime crate to execute a smart contract similar to the way that the
execute
subcommand works today (with some differences).I'll include very specific details in the code for what we need in each case. That should make it easy to find (I'll take it with the bug number) and easy to fill in.
The text was updated successfully, but these errors were encountered: