Refactors the offchain worker api (#3150)

* Update offchain primitives.

* Update offchain worker.

* Update im-online.

* Update service.

* Update node and node-template.

* Update runtime version.

* Fix build.

* Fix offchain worker tests.

* Generalize authority_pubkey.

* Add test.

* Update lib.rs
This commit is contained in:
David Craven
2019-07-22 11:20:57 +02:00
committed by Gavin Wood
parent 2edeef5825
commit a3d19baea3
17 changed files with 509 additions and 327 deletions
+7 -12
View File
@@ -29,7 +29,7 @@ use primitives::offchain::{
HttpRequestStatus as RequestStatus,
Timestamp,
CryptoKind,
CryptoKeyId,
CryptoKey,
StorageKind,
OpaqueNetworkState,
};
@@ -144,18 +144,17 @@ impl offchain::Externalities for TestOffchainExt {
unimplemented!("not needed in tests so far")
}
fn authority_pubkey(&self, _kind: CryptoKind) -> Result<Vec<u8>, ()> {
fn pubkey(&self, _key: CryptoKey) -> Result<Vec<u8>, ()> {
unimplemented!("not needed in tests so far")
}
fn new_crypto_key(&mut self, _crypto: CryptoKind) -> Result<CryptoKeyId, ()> {
fn new_crypto_key(&mut self, _crypto: CryptoKind) -> Result<CryptoKey, ()> {
unimplemented!("not needed in tests so far")
}
fn encrypt(
&mut self,
_key: Option<CryptoKeyId>,
_kind: CryptoKind,
_key: CryptoKey,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unimplemented!("not needed in tests so far")
@@ -163,8 +162,7 @@ impl offchain::Externalities for TestOffchainExt {
fn decrypt(
&mut self,
_key: Option<CryptoKeyId>,
_kind: CryptoKind,
_key: CryptoKey,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unimplemented!("not needed in tests so far")
@@ -172,8 +170,7 @@ impl offchain::Externalities for TestOffchainExt {
fn sign(
&mut self,
_key: Option<CryptoKeyId>,
_kind: CryptoKind,
_key: CryptoKey,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unimplemented!("not needed in tests so far")
@@ -181,8 +178,7 @@ impl offchain::Externalities for TestOffchainExt {
fn verify(
&mut self,
_key: Option<CryptoKeyId>,
_kind: CryptoKind,
_key: CryptoKey,
_msg: &[u8],
_signature: &[u8],
) -> Result<bool, ()> {
@@ -332,4 +328,3 @@ impl offchain::Externalities for TestOffchainExt {
}
}
}