Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
c6517ba7
Unverified
Commit
c6517ba7
authored
Mar 31, 2020
by
Bastian Köcher
Committed by
GitHub
Mar 31, 2020
Browse files
Companion pr for substrate#5448 (#957)
* Companion pr for substrate#5448 * Update Substrate reference
parent
238016df
Pipeline
#85618
passed with stages
in 25 minutes and 51 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
c6517ba7
This diff is collapsed.
Click to expand it.
network/src/protocol/tests.rs
View file @
c6517ba7
...
...
@@ -16,7 +16,7 @@
use
super
::
*
;
use
parking_lot
::
Mutex
;
use
polkadot_primitives
::
{
Block
,
Header
,
BlockId
}
;
use
polkadot_primitives
::
Block
;
use
polkadot_primitives
::
parachain
::{
Id
as
ParaId
,
Chain
,
DutyRoster
,
ParachainHost
,
ValidatorId
,
Retriable
,
CollatorId
,
AbridgedCandidateReceipt
,
...
...
@@ -26,11 +26,9 @@ use polkadot_validation::SharedTable;
use
av_store
::{
Store
as
AvailabilityStore
,
ErasureNetworking
};
use
sc_network_gossip
::
TopicNotification
;
use
sp_blockchain
::
Result
as
ClientResult
;
use
sp_api
::{
ApiRef
,
Core
,
RuntimeVersion
,
StorageProof
,
ApiErrorExt
,
ApiExt
,
ProvideRuntimeApi
};
use
sp_runtime
::
traits
::{
Block
as
BlockT
,
HashFor
,
NumberFor
};
use
sp_state_machine
::
ChangesTrieState
;
use
sp_core
::{
crypto
::
Pair
,
NativeOrEncoded
,
ExecutionContext
};
use
sp_api
::{
ApiRef
,
ProvideRuntimeApi
};
use
sp_runtime
::
traits
::
Block
as
BlockT
;
use
sp_core
::
crypto
::
Pair
;
use
sp_keyring
::
Sr25519Keyring
;
use
futures
::
executor
::
LocalPool
;
...
...
@@ -112,19 +110,11 @@ impl crate::legacy::GossipService for MockGossip {
}
impl
GossipOps
for
MockGossip
{
fn
new_local_leaf
(
&
self
,
_validation_data
:
crate
::
legacy
::
gossip
::
MessageValidationData
,
)
->
crate
::
legacy
::
gossip
::
NewLeafActions
{
fn
new_local_leaf
(
&
self
,
_
:
crate
::
legacy
::
gossip
::
MessageValidationData
)
->
crate
::
legacy
::
gossip
::
NewLeafActions
{
crate
::
legacy
::
gossip
::
NewLeafActions
::
new
()
}
fn
register_availability_store
(
&
self
,
_store
:
av_store
::
Store
,
)
{
}
fn
register_availability_store
(
&
self
,
_store
:
av_store
::
Store
)
{}
}
#[derive(Default)]
...
...
@@ -152,162 +142,46 @@ impl ProvideRuntimeApi<Block> for TestApi {
}
}
impl
Core
<
Block
>
for
RuntimeApi
{
fn
Core_version_runtime_api_impl
(
&
self
,
_
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
RuntimeVersion
>>
{
unimplemented!
(
"Not required for testing!"
)
}
fn
Core_execute_block_runtime_api_impl
(
&
self
,
_
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
Block
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
()
>>
{
unimplemented!
(
"Not required for testing!"
)
}
fn
Core_initialize_block_runtime_api_impl
(
&
self
,
_
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<&
Header
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
()
>>
{
unimplemented!
(
"Not required for testing!"
)
}
}
impl
ApiErrorExt
for
RuntimeApi
{
type
Error
=
sp_blockchain
::
Error
;
}
impl
ApiExt
<
Block
>
for
RuntimeApi
{
type
StateBackend
=
sp_state_machine
::
InMemoryBackend
<
sp_api
::
HashFor
<
Block
>>
;
fn
map_api_result
<
F
:
FnOnce
(
&
Self
)
->
Result
<
R
,
E
>
,
R
,
E
>
(
&
self
,
_
:
F
)
->
Result
<
R
,
E
>
{
unimplemented!
(
"Not required for testing!"
)
}
fn
runtime_version_at
(
&
self
,
_
:
&
BlockId
)
->
ClientResult
<
RuntimeVersion
>
{
unimplemented!
(
"Not required for testing!"
)
}
fn
record_proof
(
&
mut
self
)
{
}
fn
extract_proof
(
&
mut
self
)
->
Option
<
StorageProof
>
{
None
}
fn
into_storage_changes
(
&
self
,
_
:
&
Self
::
StateBackend
,
_
:
Option
<&
ChangesTrieState
<
HashFor
<
Block
>
,
NumberFor
<
Block
>>>
,
_
:
<
Block
as
sp_api
::
BlockT
>
::
Hash
,
)
->
std
::
result
::
Result
<
sp_api
::
StorageChanges
<
Self
::
StateBackend
,
Block
>
,
String
>
where
Self
:
Sized
{
unimplemented!
(
"Not required for testing!"
)
}
}
sp_api
::
mock_impl_runtime_apis!
{
impl
ParachainHost
<
Block
>
for
RuntimeApi
{
type
Error
=
sp_blockchain
::
Error
;
impl
ParachainHost
<
Block
>
for
RuntimeApi
{
fn
ParachainHost_validators_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
Vec
<
ValidatorId
>>>
{
Ok
(
NativeOrEncoded
::
Native
(
self
.data
.lock
()
.validators
.clone
()))
}
fn
validators
(
&
self
)
->
Vec
<
ValidatorId
>
{
self
.data
.lock
()
.validators
.clone
()
}
fn
ParachainHost_duty_roster_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
DutyRoster
>>
{
Ok
(
NativeOrEncoded
::
Native
(
DutyRoster
{
validator_duty
:
self
.data
.lock
()
.duties
.clone
(),
}))
}
fn
duty_roster
(
&
self
)
->
DutyRoster
{
DutyRoster
{
validator_duty
:
self
.data
.lock
()
.duties
.clone
(),
}
}
fn
ParachainHost_active_parachains_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
Vec
<
(
ParaId
,
Option
<
(
CollatorId
,
Retriable
)
>
)
>>>
{
Ok
(
NativeOrEncoded
::
Native
(
self
.data
.lock
()
.active_parachains
.clone
()))
}
fn
active_parachains
(
&
self
)
->
Vec
<
(
ParaId
,
Option
<
(
CollatorId
,
Retriable
)
>
)
>
{
self
.data
.lock
()
.active_parachains
.clone
()
}
fn
ParachainHost_parachain_code_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
ParaId
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
Option
<
Vec
<
u8
>>>>
{
Ok
(
NativeOrEncoded
::
Native
(
Some
(
Vec
::
new
())))
}
fn
parachain_code
(
_
:
ParaId
)
->
Option
<
Vec
<
u8
>>
{
Some
(
Vec
::
new
())
}
fn
ParachainHost_global_validation_schedule_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
GlobalValidationSchedule
>>
{
Ok
(
NativeOrEncoded
::
Native
(
Default
::
default
()))
}
fn
global_validation_schedule
()
->
GlobalValidationSchedule
{
Default
::
default
()
}
fn
ParachainHost_local_validation_data_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
ParaId
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
Option
<
LocalValidationData
>>>
{
Ok
(
NativeOrEncoded
::
Native
(
Some
(
Default
::
default
())))
}
fn
local_validation_data
(
_
:
ParaId
)
->
Option
<
LocalValidationData
>
{
Some
(
Default
::
default
())
}
fn
ParachainHost_get_heads_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_extrinsics
:
Option
<
Vec
<<
Block
as
BlockT
>
::
Extrinsic
>>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
Option
<
Vec
<
AbridgedCandidateReceipt
>>>>
{
Ok
(
NativeOrEncoded
::
Native
(
Some
(
Vec
::
new
())))
}
fn
get_heads
(
_
:
Vec
<<
Block
as
BlockT
>
::
Extrinsic
>
)
->
Option
<
Vec
<
AbridgedCandidateReceipt
>>
{
Some
(
Vec
::
new
())
}
fn
ParachainHost_signing_context_runtime_api_impl
(
&
self
,
_at
:
&
BlockId
,
_
:
ExecutionContext
,
_
:
Option
<
()
>
,
_
:
Vec
<
u8
>
,
)
->
ClientResult
<
NativeOrEncoded
<
SigningContext
>>
{
Ok
(
NativeOrEncoded
::
Native
(
SigningContext
{
session_index
:
Default
::
default
(),
parent_hash
:
Default
::
default
(),
}
)
)
fn
signing_context
()
->
SigningContext
{
SigningContext
{
session_index
:
Default
::
default
(),
parent_hash
:
Default
::
default
(),
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment