Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix frame tests
  • Loading branch information
davxy committed Aug 23, 2022
commit 61619eb8640d92eeebd556fd65e246271bda7c3c
25 changes: 9 additions & 16 deletions frame/sassafras/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,25 @@

//! Test utilities for Sassafras pallet.

// TODO-SASS-P2 remove
#![allow(unused_imports)]

use crate::{self as pallet_sassafras, Authorities, Config, SameAuthoritiesForever};
use crate::{self as pallet_sassafras, SameAuthoritiesForever};

use frame_support::{
parameter_types,
traits::{
ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize,
},
traits::{ConstU32, ConstU64, GenesisBuild, OnFinalize, OnInitialize},
};
use scale_codec::Encode;
use sp_consensus_sassafras::{
digests::PreDigest, AuthorityId, AuthorityIndex, AuthorityPair, Slot,
digests::PreDigest,
vrf::{self, VRFOutput, VRFProof},
AuthorityIndex, AuthorityPair, Slot,
};
use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof};
use sp_core::{
crypto::{IsWrappedBy, KeyTypeId, Pair},
crypto::{IsWrappedBy, Pair},
H256, U256,
};
use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::{Digest, DigestItem, Header, TestXt},
traits::{Header as _, IdentityLookup, OpaqueKeys},
Perbill,
traits::IdentityLookup,
};

const EPOCH_DURATION: u64 = 10;
Expand Down Expand Up @@ -156,7 +149,7 @@ fn make_ticket_vrf(slot: Slot, attempt: u32, pair: &AuthorityPair) -> (VRFOutput
randomness = crate::NextRandomness::<Test>::get();
}

let transcript = sp_consensus_sassafras::make_ticket_transcript(&randomness, attempt, epoch);
let transcript = vrf::make_ticket_transcript(&randomness, attempt, epoch);
let inout = pair.vrf_sign(transcript);
let output = VRFOutput(inout.0.to_output());
let proof = VRFProof(inout.1);
Expand Down Expand Up @@ -184,7 +177,7 @@ fn make_slot_vrf(slot: Slot, pair: &AuthorityPair) -> (VRFOutput, VRFProof) {
randomness = crate::NextRandomness::<Test>::get();
}

let transcript = sp_consensus_sassafras::make_slot_transcript(&randomness, slot, epoch);
let transcript = vrf::make_slot_transcript(&randomness, slot, epoch);
let inout = pair.vrf_sign(transcript);
let output = VRFOutput(inout.0.to_output());
let proof = VRFProof(inout.1);
Expand Down
18 changes: 3 additions & 15 deletions frame/sassafras/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,13 @@

//! Tests for Sassafras pallet.

// TODO-SASS-P2 remove
#![allow(unused_imports)]

use crate::*;
use mock::*;

use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::EncodeLike,
traits::{ConstU32, Currency, EstimateNextSessionRotation, OnFinalize, OnInitialize},
weights::{GetDispatchInfo, Pays},
BoundedBTreeSet,
};
use frame_support::traits::{OnFinalize, OnInitialize};
use hex_literal::hex;
use pallet_session::ShouldEndSession;
use sp_consensus_sassafras::{SassafrasEpochConfiguration, Slot};
use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof};
use sp_core::crypto::Pair;
use sp_consensus_sassafras::Slot;
use sp_runtime::traits::Get;
use std::collections::BTreeSet;

#[test]
fn slot_ticket_fetch() {
Expand Down Expand Up @@ -285,6 +272,7 @@ fn epoch_change_block() {
sp_consensus_sassafras::digests::NextEpochDescriptor {
authorities: NextAuthorities::<Test>::get().to_vec(),
randomness: NextRandomness::<Test>::get(),
config: None,
},
);
let consensus_digest = DigestItem::Consensus(SASSAFRAS_ENGINE_ID, consensus_log.encode());
Expand Down