Skip to content
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

WIP: fix withdraw reduce balance and add initial tests #37

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ltfschoen
Copy link
Collaborator

@ltfschoen ltfschoen commented Oct 17, 2024

Why is this error called Result::unwrap()on anErr value: GenericErr { msg: "Invalid hash format" } occuring when i use Rust Nightly and run cd ./packages/secret-contracts/nunya-contract && cargo test

The error is occuring on this Line 829 of code https://github.com/svub/nunya/pull/37/files#diff-d6a7ac3c294e496b72f7d1f5bdecff8f47d478f755c2ae3c04e695690020e950R829, and i believe the cause is because i haven't used the right format for the input_hash or signature property values of the PrivContractHandleMsg struct on Line 824-825. But even in this example https://github.com/SecretSaturn/SecretPath/blob/main/TNLS-Samples/Storage/src/contract.rs#L399 they also use the same format for those values.

I tried changing the hash value to Region::from_slice("message_hash".as_bytes()) by using use cosmwasm_vm::memory::{Region};, but it wouldn't let me import that since use cosmwasm_vm::memory is a "private module".

733 |     use cosmwasm_vm::memory::{Region};
    |                      ^^^^^^ private module

Error

---- contract::tests::withdraw_reduces_withdrawal_amount_from_payment_ref_storage_balances stdout ----
thread 'contract::tests::withdraw_reduces_withdrawal_amount_from_payment_ref_storage_balances' panicked at src/contract.rs:829:75:
called `Result::unwrap()` on an `Err` value: GenericErr { msg: "Invalid hash format" }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/798fb83f7d24e31b16acca113496f39ff168c143/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/798fb83f7d24e31b16acca113496f39ff168c143/library/core/src/panicking.rs:74:14
   2: core::result::unwrap_failed
             at /rustc/798fb83f7d24e31b16acca113496f39ff168c143/library/core/src/result.rs:1698:5
   3: core::result::Result<T,E>::unwrap
             at /Users/luke/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:1103:23
   4: nunya::contract::tests::withdraw_reduces_withdrawal_amount_from_payment_ref_storage_balances
             at ./src/contract.rs:829:13
   5: nunya::contract::tests::withdraw_reduces_withdrawal_amount_from_payment_ref_storage_balances::{{closure}}
             at ./src/contract.rs:805:78
   6: core::ops::function::FnOnce::call_once
             at /Users/luke/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/798fb83f7d24e31b16acca113496f39ff168c143/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Note that I've also been using this codebase for reference https://github.com/CosmWasm/cosmwasm/blob/main/contracts/hackatom/src/contract.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant