Skip to content

Commit

Permalink
test(wallet-integration): up contract get payload works
Browse files Browse the repository at this point in the history
  • Loading branch information
al3mart committed Dec 12, 2024
1 parent 9f7f430 commit 1485dfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion crates/pop-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subxt.workspace = true
# cargo-contracts
contract-build.workspace = true
contract-extrinsics.workspace = true
contract-transcode.workspace = true
contract-transcode.workspace = true
scale-info.workspace = true
# pop
pop-common = { path = "../pop-common", version = "0.5.0" }
Expand All @@ -42,3 +42,4 @@ pop-common = { path = "../pop-common", version = "0.5.0" }
dirs.workspace = true
mockito.workspace = true
tokio-test.workspace = true
hex.workspace = true
22 changes: 13 additions & 9 deletions crates/pop-contracts/src/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,13 @@ mod tests {
run_contracts_node,
};
use anyhow::Result;
use reqwest::get;
use std::{env, fs, process::Command};
use hex::FromHex;
use pop_common::{find_free_port, set_executable_permission};
use std::{env, process::Command, time::Duration};
use subxt::{
config::{substrate::BlakeTwo256, Hasher},
utils::to_hex,
utils::{to_hex, H256},
};
use pop_common::{find_free_port, set_executable_permission};
use std::{env, process::Command, time::Duration};
use tokio::time::sleep;
use url::Url;

Expand Down Expand Up @@ -467,11 +466,16 @@ mod tests {
};
let contract_code = get_contract_code(up_opts.path.as_ref()).await?;
let call_data = get_upload_payload(contract_code, CONTRACTS_NETWORK_URL).await?;
let payload_hash = BlakeTwo256::hash(&call_data).to_string();
let payload_hash = BlakeTwo256::hash(&call_data);
// We know that for the above opts the payload hash should be:
// 0x4e4ff6ad411346d4cd6cf9bcc9101360e4657f776b0af3b46bfe780b0413e819
assert!(payload_hash.starts_with("0x4e4f"));
assert!(payload_hash.ends_with("e819"));
// 0x98c24584107b3a01d12e8e02c0bb634d15dc86123c44d186206813ede42f478d
let expected_hash: H256 = H256::from(
<[u8; 32]>::from_hex(
"98c24584107b3a01d12e8e02c0bb634d15dc86123c44d186206813ede42f478d",
)
.expect("Invalid hex string"),
);
assert_eq!(expected_hash, payload_hash);
Ok(())
}

Expand Down

0 comments on commit 1485dfa

Please sign in to comment.