diff --git a/test-cases/code-hash/other_contract/Cargo.toml b/test-cases/code-hash/other_contract/Cargo.toml index 9a9d953..97519f3 100644 --- a/test-cases/code-hash/other_contract/Cargo.toml +++ b/test-cases/code-hash/other_contract/Cargo.toml @@ -19,7 +19,7 @@ e2e-tests = [] [dependencies] ink = { version = "4.2.1", default-features = false } -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale = { package = "parity-scale-codec", version = "=3.6.5", default-features = false, features = ["derive"] } scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } [dev-dependencies] diff --git a/test-cases/own-code-hash/README.md b/test-cases/own-code-hash/README.md new file mode 100644 index 0000000..e940c10 --- /dev/null +++ b/test-cases/own-code-hash/README.md @@ -0,0 +1,31 @@ +# Function `own_code_hash` + +```rust +pub fn own_code_hash() -> Result +``` + +## Description + +Retrieves the code hash of the currently executing contract. + +## Related ink! functions + +- [`own_code_hash`](https://paritytech.github.io/ink/ink_env/fn.own_code_hash.html) + +## Test case + +Test case intend to showcase how `own_code_hash` is working in both Integration and End-to-End scenarios. To check the retrieved code hash is correct, we compared it with the code obtained via [`code_hash`](https://paritytech.github.io/ink/ink_env/fn.code_hash.html) by providing the contract `account_id`. + +Note in Integration this last step it is not possible due to lack of [`code_hash`](https://paritytech.github.io/ink/ink_env/fn.code_hash.html) implementation, so it is just tested that [`own_code_hash`](https://paritytech.github.io/ink/ink_env/fn.own_code_hash.html) can be called. + +| \# | Test | Integration | E2E | +| --- | ------------------------------------------------------- | :---------: | :-: | +| 1 | Attempts to get the code hash of the executing contract | ❌ | ✅ | + +## Comparison Integration vs E2E + +Test 1 worked as expected in End-to-End but did not on Integration since it's [not implemented](https://github.com/paritytech/ink/blob/c2af39883aab48c71dc09dac5d06583f2e84dc54/crates/env/src/engine/off_chain/impls.rs#L535). + +## Result + +See estimate for code_hash().