Skip to content
Snippets Groups Projects
Commit 0c989e4a authored by Cédric Moreau's avatar Cédric Moreau
Browse files

fix(#134): add `gdev_build` job on build phase (!194)

* fix(#134): fix: `gdev_build` job should be always launched on MR or master

* fix(#134): fix: `tests` job should be always launched on MR or master

* fix(#134): fix warnings

* fix(#134): fix gtest error "missing quota config"

* fix(#134): add `gdev_build` job on build phase
parent 2ddae276
No related branches found
No related tags found
1 merge request!194Resolve "Add a ĞTest build job on build stage"
Pipeline #34250 waiting for manual action
......@@ -200,6 +200,25 @@ run_benchmarks:
IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA"
PODMAN_BUILD_OPTIONS: "--target build --build-arg benchmarks=1"
gdev_build:
stage: build
image: rust:1-bullseye
rules:
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
when: manual
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH =~ /^(release\/runtime-)[0-9].*/
when: never
- if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
- when: manual
variables:
DEBIAN_FRONTEND: noninteractive
script:
- apt-get update
- apt-get install -y clang cmake protobuf-compiler
- cargo build --no-default-features --features gtest
tests:
stage: tests
image: rust:1-bullseye
......@@ -211,8 +230,7 @@ tests:
- if: $CI_COMMIT_BRANCH =~ /^(release\/runtime-)[0-9].*/
when: never
- if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
when: manual
- when: always
- when: manual
variables:
DEBIAN_FRONTEND: noninteractive
script:
......
......@@ -24,15 +24,12 @@ pub mod gdev;
#[cfg(feature = "gtest")]
pub mod gtest;
use common_runtime::{AccountId, IdtyIndex, Signature};
use common_runtime::{AccountId, Signature};
use sp_core::{Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use std::collections::BTreeMap;
pub type AccountPublic = <Signature as Verify>::Signer;
pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"];
/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
......@@ -47,29 +44,3 @@ where
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
fn clique_wot(
initial_identities_len: usize,
) -> (
BTreeMap<IdtyIndex, BTreeMap<IdtyIndex, Option<common_runtime::BlockNumber>>>,
u32,
) {
let mut certs_by_issuer = BTreeMap::new();
let mut count: u32 = 0;
for i in 1..=initial_identities_len {
count += initial_identities_len as u32;
certs_by_issuer.insert(
i as IdtyIndex,
(1..=initial_identities_len)
.filter_map(|j| {
if i != j {
Some((j as IdtyIndex, None))
} else {
None
}
})
.collect(),
);
}
(certs_by_issuer, count)
}
......@@ -303,11 +303,7 @@ fn genesis_data_to_gdev_genesis_conf(
..Default::default()
},
quota: QuotaConfig {
identities: identities
.iter()
.enumerate()
.map(|(i, _)| i as u32 + 1)
.collect(),
identities: identities.iter().map(|i| i.idty_index).collect(),
},
identity: IdentityConfig {
identities: identities
......
......@@ -14,9 +14,7 @@
// 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::chain_spec::{
clique_wot, get_account_id_from_seed, get_from_seed, AccountPublic, NAMES,
};
use crate::chain_spec::{get_account_id_from_seed, get_from_seed, AccountPublic};
use common_runtime::constants::DAYS;
use common_runtime::*;
use log::{error, warn};
......@@ -1452,15 +1450,16 @@ where
let ud = 1_000;
let idty_index_start: u32 = 1;
let common_parameters = get_common_parameters(&parameters);
let names: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"];
let initial_smiths = (0..initial_smiths_len)
.map(|i| get_authority_keys_from_seed(NAMES[i]))
.map(|i| get_authority_keys_from_seed(names[i]))
.collect::<Vec<AuthorityKeys>>();
let initial_identities = (0..initial_identities_len)
.map(|i| {
(
IdtyName::from(NAMES[i]),
get_account_id_from_seed::<sr25519::Public>(NAMES[i]),
IdtyName::from(names[i]),
get_account_id_from_seed::<sr25519::Public>(names[i]),
)
})
.collect::<BTreeMap<IdtyName, AccountId>>();
......@@ -1588,6 +1587,33 @@ where
Ok(genesis_data)
}
#[cfg(feature = "gdev")]
fn clique_wot(
initial_identities_len: usize,
) -> (
BTreeMap<IdtyIndex, BTreeMap<IdtyIndex, Option<common_runtime::BlockNumber>>>,
u32,
) {
let mut certs_by_issuer = BTreeMap::new();
let mut count: u32 = 0;
for i in 1..=initial_identities_len {
count += initial_identities_len as u32;
certs_by_issuer.insert(
i as IdtyIndex,
(1..=initial_identities_len)
.filter_map(|j| {
if i != j {
Some((j as IdtyIndex, None))
} else {
None
}
})
.collect(),
);
}
(certs_by_issuer, count)
}
fn check_parameters_consistency(
wallets: &BTreeMap<PubkeyV1, u64>,
first_ud: &Option<u64>,
......
......@@ -22,8 +22,8 @@ use common_runtime::*;
use gtest_runtime::{
opaque::SessionKeys, parameters, AccountConfig, AccountId, AuthorityMembersConfig, BabeConfig,
BalancesConfig, CertConfig, GenesisConfig, IdentityConfig, ImOnlineId, MembershipConfig,
Perbill, SessionConfig, SmithCertConfig, SmithMembershipConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, UniversalDividendConfig, WASM_BINARY,
Perbill, QuotaConfig, SessionConfig, SmithCertConfig, SmithMembershipConfig, SudoConfig,
SystemConfig, TechnicalCommitteeConfig, UniversalDividendConfig, WASM_BINARY,
};
use jsonrpsee::core::JsonValue;
use sc_consensus_grandpa::AuthorityId as GrandpaId;
......@@ -209,8 +209,8 @@ fn genesis_data_to_gtest_genesis_conf(
initial_authorities,
initial_monetary_mass,
memberships,
parameters,
common_parameters,
parameters: _,
common_parameters: _,
session_keys_map,
smith_certs_by_receiver,
smith_memberships,
......@@ -253,21 +253,20 @@ fn genesis_data_to_gtest_genesis_conf(
members: technical_committee_members,
..Default::default()
},
quota: QuotaConfig {
identities: identities.iter().map(|i| i.idty_index).collect(),
},
identity: IdentityConfig {
identities: identities
.into_iter()
.enumerate()
.map(
|(
i,
GenesisIdentity {
idty_index,
name,
owner_key,
old_owner_key,
active,
},
)| GenesisIdty {
|GenesisIdentity {
idty_index,
name,
owner_key,
old_owner_key,
active,
}| GenesisIdty {
index: idty_index,
name: common_runtime::IdtyName::from(name.as_str()),
value: common_runtime::IdtyValue {
......
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