-
Notifications
You must be signed in to change notification settings - Fork 19
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
Contract API tests #42
Conversation
@@ -21,5 +21,8 @@ parity-scale-codec = { workspace = true } | |||
scale-info = { workspace = true } | |||
thiserror = { workspace = true } | |||
|
|||
[dev-dependencies] | |||
wat = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wat is das?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can turn wat to a wasm blob 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you have to write a wat by hand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- pallet-contracts' unit tests also use wat instead of full Rust contract compiled to wasm
- no need for compiling contract to wasm / no need to keep obscure bytes
- kinda readable
- you don't have to encode any selectors or arguments:
data: vec![]
works well for calling the only method
drink/test-resources/transfer.wat
Outdated
(i32.store | ||
(i32.const 40) | ||
(call $seal_transfer | ||
(i32.const 0) ;; ptr to destination address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using zero-address is incorrect as the private key for it is well-known ;P
Doesn't matter in this context of course xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from Substrate :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good practices etc :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed transferring at all (it was silently failing due to insufficient contract's balance)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and tests were passing? How's that po(a)ssible? ie how was the event emitted if the txn failed? Or at this level the event emition is not yet affecting what ends up in the final block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, taking that back - I have no idea why it was passing
fn can_upload_code() { | ||
let mut sandbox = Sandbox::<MinimalRuntime>::new().unwrap(); | ||
let wasm_binary = compile_module("transfer"); | ||
let hash = <<MinimalRuntime as frame_system::Config>::Hashing>::hash(&wasm_binary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
Adding tests for ContractAPI. Also, bump version to 1.3 - it should be now ready to fill the gaps in ink!