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

Fix E2E tests by updating Weight type #1496

Merged
merged 6 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ examples-test:
- *start-substrate-contracts-node
- for example in examples/*/; do
if [ "$example" = "examples/upgradeable-contracts/" ]; then continue; fi;
cargo test --verbose --manifest-path ${example}/Cargo.toml;
if grep -q "e2e-tests = \[\]" "${example}/Cargo.toml"; then
cargo test --verbose --manifest-path ${example}/Cargo.toml --features e2e-tests;
else
cargo test --verbose --manifest-path ${example}/Cargo.toml;
fi;
done
- for contract in ${DELEGATOR_SUBCONTRACTS}; do
cargo test --verbose --manifest-path ./examples/delegator/${contract}/Cargo.toml;
Expand Down
13 changes: 7 additions & 6 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ ink_env = { version = "4.0.0-alpha.3", path = "../env" }
contract-metadata = { version = "2.0.0-alpha.4" }
impl-serde = { version = "0.3.1", default-features = false }
jsonrpsee = { version = "0.16.0", features = ["ws-client"] }
pallet-contracts-primitives = { version = "6.0.0" }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "pallet-contracts-primitives" }
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.81" }
tokio = { version = "1.18.2", features = ["rt-multi-thread"] }
log = { version = "0.4" }
env_logger = { version = "0.9" }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] }
# TODO we need to use `subxt` `master` until the next release 0.25 is published.
subxt = { git = "https://github.com/paritytech/subxt" }
subxt = { git = "https://github.com/paritytech/subxt", branch = "polkadot-v0.9.33", package = "subxt" }

# Substrate
sp-rpc = { version = "6.0.0" }
sp-core = { version = "6.0.0" }
sp-keyring = { version = "6.0.0" }
sp-runtime = { version = "6.0.0" }
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "sp-rpc" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "sp-core" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "sp-keyring" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "sp-runtime" }
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", package = "sp-weights" }

# TODO(#1421) `smart-bench_macro` needs to be forked.
smart-bench-macro = { git = "https://github.com/paritytech/smart-bench", branch = "cmichi-ink-e2e-test-mvp-cross-contract", package = "smart-bench-macro" }
Expand Down
Binary file modified crates/e2e/metadata/contracts-node.scale
Binary file not shown.
27 changes: 10 additions & 17 deletions crates/e2e/src/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ use super::{
Signer,
Verify,
};
use ink_env::{
Environment,
Gas,
};
use ink_env::Environment;

use core::marker::PhantomData;
use jsonrpsee::{
Expand All @@ -40,15 +37,13 @@ use sp_core::{
Bytes,
H256,
};
use sp_weights::Weight;
use subxt::{
blocks::ExtrinsicEvents,
tx::ExtrinsicParams,
OnlineClient,
};

/// The gas limit for contract instantiate and call dry runs.
const DRY_RUN_GAS_LIMIT: u64 = 500_000_000_000;

// TODO(#1422) Should be fetched automatically.
#[subxt::subxt(
crate = "crate::subxt",
Expand All @@ -61,8 +56,7 @@ pub(super) mod api {}
pub struct InstantiateWithCode<B> {
#[codec(compact)]
value: B,
#[codec(compact)]
gas_limit: Gas,
gas_limit: Weight,
storage_deposit_limit: Option<B>,
code: Vec<u8>,
data: Vec<u8>,
Expand All @@ -75,8 +69,7 @@ pub struct Call<C: subxt::Config, B> {
dest: sp_runtime::MultiAddress<C::AccountId, ()>,
#[codec(compact)]
value: B,
#[codec(compact)]
gas_limit: Gas,
gas_limit: Weight,
storage_deposit_limit: Option<B>,
data: Vec<u8>,
}
Expand All @@ -94,7 +87,7 @@ pub struct UploadCode<B> {
struct RpcInstantiateRequest<C: subxt::Config, E: Environment> {
origin: C::AccountId,
value: E::Balance,
gas_limit: Gas,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<E::Balance>,
code: Code,
data: Vec<u8>,
Expand Down Expand Up @@ -122,7 +115,7 @@ struct RpcCallRequest<C: subxt::Config, E: Environment> {
origin: C::AccountId,
dest: C::AccountId,
value: E::Balance,
gas_limit: Gas,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<E::Balance>,
input_data: Vec<u8>,
}
Expand Down Expand Up @@ -194,7 +187,7 @@ where
let call_request = RpcInstantiateRequest::<C, E> {
origin: signer.account_id().clone(),
value,
gas_limit: DRY_RUN_GAS_LIMIT,
gas_limit: None,
storage_deposit_limit,
code,
data,
Expand Down Expand Up @@ -222,7 +215,7 @@ where
pub async fn instantiate_with_code(
&self,
value: E::Balance,
gas_limit: Gas,
gas_limit: Weight,
storage_deposit_limit: Option<E::Balance>,
code: Vec<u8>,
data: Vec<u8>,
Expand Down Expand Up @@ -361,7 +354,7 @@ where
origin,
dest: contract,
value,
gas_limit: DRY_RUN_GAS_LIMIT,
gas_limit: None,
storage_deposit_limit,
input_data,
};
Expand All @@ -386,7 +379,7 @@ where
&self,
contract: sp_runtime::MultiAddress<C::AccountId, ()>,
value: E::Balance,
gas_limit: Gas,
gas_limit: Weight,
storage_deposit_limit: Option<E::Balance>,
data: Vec<u8>,
signer: &Signer<C>,
Expand Down