Skip to content
Snippets Groups Projects
Unverified Commit 57882bd5 authored by bgallois's avatar bgallois
Browse files

optimize end2end test

parent d53e2154
No related branches found
No related tags found
No related merge requests found
Pipeline #35709 waiting for manual action
......@@ -20,17 +20,13 @@ use super::*;
use sp_keyring::AccountKeyring;
use subxt::{tx::PairSigner, utils::MultiAddress};
pub async fn certify(
rpc_client: &RpcClient,
from: AccountKeyring,
to: AccountKeyring,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
pub async fn certify(client: &FullClient, from: AccountKeyring, to: AccountKeyring) -> Result<()> {
let signer = PairSigner::new(from.pair());
let from = from.to_account_id();
let to = to.to_account_id();
let issuer_index = client
.client
.storage()
.at_latest()
.await
......@@ -43,6 +39,7 @@ pub async fn certify(
.await?
.unwrap_or_else(|| panic!("{} issuer must exist", from));
let receiver_index = client
.client
.storage()
.at_latest()
.await
......@@ -52,8 +49,9 @@ pub async fn certify(
.unwrap_or_else(|| panic!("{} issuer must exist", from));
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx()
......
......@@ -23,13 +23,13 @@ use subxt::backend::rpc::RpcClient;
use subxt::tx::{PairSigner, Signer};
use subxt::utils::AccountId32;
pub async fn request_evaluation(rpc_client: &RpcClient, origin: AccountKeyring) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
pub async fn request_evaluation(client: &FullClient, origin: AccountKeyring) -> Result<()> {
let origin = PairSigner::new(origin.pair());
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx().distance().request_distance_evaluation(),
......@@ -44,11 +44,10 @@ pub async fn request_evaluation(rpc_client: &RpcClient, origin: AccountKeyring)
}
pub async fn run_oracle(
rpc_client: &RpcClient,
client: &FullClient,
origin: AccountKeyring,
rpc_url: String,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let origin = PairSigner::new(origin.pair());
let account_id: &AccountId32 = origin.account_id();
......@@ -63,12 +62,12 @@ pub async fn run_oracle(
.await
{
for _ in 0..30 {
super::create_empty_block(rpc_client).await?;
super::create_empty_block(&client.rpc).await?;
}
let _events = create_block_with_extrinsic(
rpc_client,
client
&client.rpc,
client.client
.tx()
.create_signed(
&gdev::tx().sudo().sudo(gdev::runtime_types::gdev_runtime::RuntimeCall::Distance(
......
......@@ -31,17 +31,17 @@ type IdtyValue =
// submit extrinsics
pub async fn create_identity(
rpc_client: &RpcClient,
client: &FullClient,
from: AccountKeyring,
to: AccountKeyring,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx().identity().create_identity(to.into()),
......@@ -56,17 +56,17 @@ pub async fn create_identity(
}
pub async fn confirm_identity(
rpc_client: &RpcClient,
client: &FullClient,
from: AccountKeyring,
pseudo: String,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let from = PairSigner::new(from.pair());
let pseudo: IdtyName = IdtyName(pseudo.as_bytes().to_vec());
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx().identity().confirm_identity(pseudo),
......
......@@ -43,18 +43,18 @@ impl Account {
}
pub async fn create_oneshot_account(
rpc_client: &RpcClient,
client: &FullClient,
from: AccountKeyring,
amount: u64,
to: AccountKeyring,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx()
......@@ -71,17 +71,17 @@ pub async fn create_oneshot_account(
}
pub async fn consume_oneshot_account(
rpc_client: &RpcClient,
client: &FullClient,
from: AccountKeyring,
to: Account,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx().oneshot_account().consume_oneshot_account(0, to),
......@@ -97,20 +97,20 @@ pub async fn consume_oneshot_account(
#[allow(clippy::too_many_arguments)]
pub async fn consume_oneshot_account_with_remaining(
rpc_client: &RpcClient,
client: &FullClient,
from: AccountKeyring,
amount: u64,
to: Account,
remaining_to: Account,
) -> Result<()> {
let client = Client::from_rpc_client(rpc_client.clone()).await.unwrap();
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let remaining_to = remaining_to.to_account_id();
let _events = create_block_with_extrinsic(
rpc_client,
&client.rpc,
client
.client
.tx()
.create_signed(
&gdev::tx()
......
......@@ -254,7 +254,7 @@ async fn create_oneshot_account(
assert!(!is_ud);
common::oneshot::create_oneshot_account(world.rpc_client(), from, amount, to).await
common::oneshot::create_oneshot_account(world.full_client(), from, amount, to).await
}
#[allow(clippy::needless_pass_by_ref_mut)]
......@@ -274,7 +274,7 @@ async fn consume_oneshot_account(
_ => unreachable!(),
};
common::oneshot::consume_oneshot_account(world.rpc_client(), from, to).await
common::oneshot::consume_oneshot_account(world.full_client(), from, to).await
}
#[when(
......@@ -311,7 +311,7 @@ async fn consume_oneshot_account_with_remaining(
assert!(!is_ud);
common::oneshot::consume_oneshot_account_with_remaining(
world.rpc_client(),
world.full_client(),
from,
amount,
to,
......@@ -337,7 +337,7 @@ async fn certifies(world: &mut DuniterWorld, from: String, to: String) -> Result
let from = AccountKeyring::from_str(&from).expect("unknown from");
let to = AccountKeyring::from_str(&to).expect("unknown to");
common::cert::certify(world.rpc_client(), from, to).await
common::cert::certify(world.full_client(), from, to).await
}
#[allow(clippy::needless_pass_by_ref_mut)]
......@@ -347,7 +347,7 @@ async fn creates_identity(world: &mut DuniterWorld, from: String, to: String) ->
let from = AccountKeyring::from_str(&from).expect("unknown from");
let to = AccountKeyring::from_str(&to).expect("unknown to");
common::identity::create_identity(world.rpc_client(), from, to).await
common::identity::create_identity(world.full_client(), from, to).await
}
#[allow(clippy::needless_pass_by_ref_mut)]
......@@ -355,7 +355,7 @@ async fn creates_identity(world: &mut DuniterWorld, from: String, to: String) ->
async fn confirm_identity(world: &mut DuniterWorld, from: String, pseudo: String) -> Result<()> {
let from = AccountKeyring::from_str(&from).expect("unknown from");
common::identity::confirm_identity(world.rpc_client(), from, pseudo).await
common::identity::confirm_identity(world.full_client(), from, pseudo).await
}
#[allow(clippy::needless_pass_by_ref_mut)]
......@@ -363,7 +363,7 @@ async fn confirm_identity(world: &mut DuniterWorld, from: String, pseudo: String
async fn request_distance_evaluation(world: &mut DuniterWorld, who: String) -> Result<()> {
let who = AccountKeyring::from_str(&who).expect("unknown origin");
common::distance::request_evaluation(world.rpc_client(), who).await
common::distance::request_evaluation(world.full_client(), who).await
}
#[allow(clippy::needless_pass_by_ref_mut)]
......@@ -372,7 +372,7 @@ async fn run_distance_oracle(world: &mut DuniterWorld, who: String) -> Result<()
let who = AccountKeyring::from_str(&who).expect("unknown origin");
common::distance::run_oracle(
world.rpc_client(),
world.full_client(),
who,
format!("ws://127.0.0.1:{}", world.inner.as_ref().unwrap().ws_port),
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment