mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Custom RPC for Merkle Mountain Range pallet (#8137)
* Add MMR custom RPC.
* Change RuntimeApi to avoid hardcoding leaf type.
* Properly implement the new RuntimeAPI and wire up RPC.
* Extract Offchain DB as separate execution extension.
* Enable offchain DB access for offchain calls.
* Fix offchain_election tests.
* Skip block initialisation for proof generation.
* Fix integration test setup.
* Fix offchain tests. Not sure how I missed them earlier 🤷.
* Fix long line.
* One more test missing.
* Update mock for multi-phase.
* Address review grumbbles.
* Address review grumbles.
* Fix line width of a comment
This commit is contained in:
@@ -518,7 +518,7 @@ mod tests {
|
||||
use super::*;
|
||||
use sp_io::TestExternalities;
|
||||
use sp_core::offchain::{
|
||||
OffchainExt,
|
||||
OffchainWorkerExt,
|
||||
testing,
|
||||
};
|
||||
|
||||
@@ -526,7 +526,7 @@ mod tests {
|
||||
fn should_send_a_basic_request_and_get_response() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let request: Request = Request::get("http://localhost:1234");
|
||||
@@ -567,7 +567,7 @@ mod tests {
|
||||
fn should_send_a_post_request() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let pending = Request::default()
|
||||
|
||||
@@ -104,7 +104,7 @@ mod tests {
|
||||
use super::*;
|
||||
use sp_io::TestExternalities;
|
||||
use sp_core::offchain::{
|
||||
OffchainExt,
|
||||
OffchainDbExt,
|
||||
testing,
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ mod tests {
|
||||
fn should_set_and_get() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let val = StorageValue::persistent(b"testval");
|
||||
@@ -134,7 +134,7 @@ mod tests {
|
||||
fn should_mutate() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let val = StorageValue::persistent(b"testval");
|
||||
|
||||
@@ -453,7 +453,7 @@ pub trait BlockNumberProvider {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_core::offchain::{testing, OffchainExt};
|
||||
use sp_core::offchain::{testing, OffchainWorkerExt, OffchainDbExt};
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
const VAL_1: u32 = 0u32;
|
||||
@@ -463,7 +463,8 @@ mod tests {
|
||||
fn storage_lock_write_unlock_lock_read_unlock() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain.clone()));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let mut lock = StorageLock::<'_, Time>::new(b"lock_1");
|
||||
@@ -493,7 +494,8 @@ mod tests {
|
||||
fn storage_lock_and_forget() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain.clone()));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let mut lock = StorageLock::<'_, Time>::new(b"lock_2");
|
||||
@@ -517,7 +519,8 @@ mod tests {
|
||||
fn storage_lock_and_let_expire_and_lock_again() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain.clone()));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let sleep_until = offchain::timestamp().add(Duration::from_millis(500));
|
||||
@@ -549,7 +552,8 @@ mod tests {
|
||||
fn extend_active_lock() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
t.register_extension(OffchainDbExt::new(offchain.clone()));
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let lock_expiration = Duration::from_millis(300);
|
||||
|
||||
Reference in New Issue
Block a user