Skip to content
Snippets Groups Projects
Select Git revision
  • e1668f580900f8a7a483651aa94e1d5f0d827f86
  • master default protected
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • hugo/195-graphql-schema
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
  • v0.4.1 protected
41 results

mock.rs

Blame
  • mock.rs 3.62 KiB
    // Copyright 2023 Axiom-Team
    //
    // This file is part of Duniter-v2S.
    //
    // Duniter-v2S is free software: you can redistribute it and/or modify
    // it under the terms of the GNU Affero General Public License as published by
    // the Free Software Foundation, version 3 of the License.
    //
    // Duniter-v2S is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    // GNU Affero General Public License for more details.
    //
    // You should have received a copy of the GNU Affero General Public License
    // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
    
    use crate::runtime::runtime_types::{
        pallet_distance::median::MedianAcc, sp_arithmetic::per_things::Perbill,
    };
    
    use dubp_wot::{data::rusty::RustyWebOfTrust, WebOfTrust, WotId};
    use sp_core::H256;
    use std::collections::BTreeSet;
    
    pub struct Client {
        wot: RustyWebOfTrust,
        pub pool_len: usize,
    }
    pub type AccountId = subxt::ext::sp_runtime::AccountId32;
    pub type IdtyIndex = u32;
    
    pub struct EvaluationPool<AccountId: Ord, IdtyIndex> {
        pub evaluations: (Vec<(IdtyIndex, MedianAcc<Perbill>)>,),
        pub evaluators: BTreeSet<AccountId>,
    }
    
    pub async fn client(_rpc_url: String) -> Client {
        unimplemented!()
    }
    
    pub fn client_from_wot(wot: RustyWebOfTrust) -> Client {
        Client { wot, pool_len: 1 }
    }
    
    pub async fn parent_hash(_client: &Client) -> H256 {
        Default::default()
    }
    
    pub async fn current_pool_index(_client: &Client, _parent_hash: H256) -> u32 {
        0
    }
    
    pub async fn current_pool(
        client: &Client,
        _parent_hash: H256,
        _current_session: u32,
    ) -> Option<EvaluationPool<AccountId, IdtyIndex>> {
        Some(EvaluationPool {
            evaluations: (client
                .wot
                .get_enabled()
                .into_iter()
                .chain(client.wot.get_disabled().into_iter())
                .zip(0..client.pool_len)
                .map(|(wot_id, _)| {
                    (wot_id.0 as IdtyIndex, unsafe {
                        std::mem::transmute((Vec::<()>::new(), Option::<u32>::None, 0))
                    })
                })
                .collect(),),