feat: initialize Kurdistan SDK - independent fork of Polkadot SDK
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(&self);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `self` as argument not supported.
|
||||
--> tests/ui/adding_self_parameter.rs:20:11
|
||||
|
|
||||
20 | fn test(&self);
|
||||
| ^
|
||||
@@ -0,0 +1,30 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
#[changed_in(2)]
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,6 @@
|
||||
error: There is no 'default' method with this name (without `changed_in` attribute).
|
||||
The 'default' method is used to call into the latest implementation.
|
||||
--> tests/ui/changed_in_no_default_method.rs:26:6
|
||||
|
|
||||
26 | fn test(data: u64);
|
||||
| ^^^^
|
||||
@@ -0,0 +1,30 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
#[changed_in(2)]
|
||||
fn test(data: u64);
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `changed_in` version can not be greater than the `api_version`
|
||||
--> tests/ui/changed_in_unknown_version.rs:25:3
|
||||
|
|
||||
25 | fn test(data: u64);
|
||||
| ^^
|
||||
@@ -0,0 +1,24 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api<Block: BlockT> {
|
||||
fn test();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro! If you try to use a different trait than the substrate `Block` trait, please rename it locally.
|
||||
--> tests/ui/declaring_old_block.rs:19:23
|
||||
|
|
||||
19 | pub trait Api<Block: BlockT> {
|
||||
| ^^^^^^
|
||||
|
||||
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro!
|
||||
--> tests/ui/declaring_old_block.rs:19:16
|
||||
|
|
||||
19 | pub trait Api<Block: BlockT> {
|
||||
| ^^^^^
|
||||
@@ -0,0 +1,24 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api<B: BlockT> {
|
||||
fn test();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro! If you try to use a different trait than the substrate `Block` trait, please rename it locally.
|
||||
--> tests/ui/declaring_own_block_with_different_name.rs:19:19
|
||||
|
|
||||
19 | pub trait Api<B: BlockT> {
|
||||
| ^^^^^^
|
||||
@@ -0,0 +1,29 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
#[deprecated(unknown_kw = "test")]
|
||||
fn test();
|
||||
#[deprecated(since = 5)]
|
||||
fn test2();
|
||||
#[deprecated = 5]
|
||||
fn test3();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,43 @@
|
||||
error: Invalid deprecation attribute: missing `note`
|
||||
help: the following are the possible correct uses
|
||||
|
|
||||
| #[deprecated = "reason"]
|
||||
|
|
||||
| #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")]
|
||||
|
|
||||
| #[deprecated]
|
||||
|
|
||||
--> tests/ui/deprecation_info.rs:20:3
|
||||
|
|
||||
20 | #[deprecated(unknown_kw = "test")]
|
||||
| ^
|
||||
|
||||
error: malformed `deprecated` attribute input
|
||||
--> tests/ui/deprecation_info.rs:24:3
|
||||
|
|
||||
24 | #[deprecated = 5]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: the following are the possible correct uses
|
||||
|
|
||||
24 - #[deprecated = 5]
|
||||
24 + #[deprecated = "reason"]
|
||||
|
|
||||
24 - #[deprecated = 5]
|
||||
24 + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")]
|
||||
|
|
||||
24 - #[deprecated = 5]
|
||||
24 + #[deprecated]
|
||||
|
|
||||
|
||||
error[E0541]: unknown meta item 'unknown_kw'
|
||||
--> tests/ui/deprecation_info.rs:20:16
|
||||
|
|
||||
20 | #[deprecated(unknown_kw = "test")]
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected one of `since`, `note`
|
||||
|
||||
error[E0565]: literal in `deprecated` value must be a string
|
||||
--> tests/ui/deprecation_info.rs:22:24
|
||||
|
|
||||
22 | #[deprecated(since = 5)]
|
||||
| ^
|
||||
@@ -0,0 +1,30 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: No api implementation given!
|
||||
--> tests/ui/empty_impl_runtime_apis_call.rs:28:1
|
||||
|
|
||||
28 | sp_api::impl_runtime_apis! {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the macro `sp_api::impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,49 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test(data: String) {}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_api::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,66 @@
|
||||
error[E0603]: struct `RuntimeVersion` is private
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:37:27
|
||||
|
|
||||
37 | fn version() -> sp_api::RuntimeVersion {
|
||||
| ^^^^^^^^^^^^^^ private struct
|
||||
|
|
||||
note: the struct `RuntimeVersion` is defined here
|
||||
--> $WORKSPACE/substrate/primitives/api/src/lib.rs
|
||||
|
|
||||
| use sp_version::RuntimeVersion;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider importing this struct instead
|
||||
|
|
||||
37 - fn version() -> sp_api::RuntimeVersion {
|
||||
37 + fn version() -> sp_version::RuntimeVersion {
|
||||
|
|
||||
help: import `RuntimeVersion` directly
|
||||
|
|
||||
37 - fn version() -> sp_api::RuntimeVersion {
|
||||
37 + fn version() -> sp_version::RuntimeVersion {
|
||||
|
|
||||
|
||||
error[E0053]: method `test` has an incompatible type for trait
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:33:17
|
||||
|
|
||||
33 | fn test(data: String) {}
|
||||
| ^^^^^^ expected `u64`, found `std::string::String`
|
||||
|
|
||||
note: type in trait
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:27:17
|
||||
|
|
||||
27 | fn test(data: u64);
|
||||
| ^^^
|
||||
= note: expected signature `fn(u64)`
|
||||
found signature `fn(std::string::String)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
33 - fn test(data: String) {}
|
||||
33 + fn test(data: u64) {}
|
||||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:33:11
|
||||
|
|
||||
31 | / sp_api::impl_runtime_apis! {
|
||||
32 | | impl self::Api<Block> for Runtime {
|
||||
33 | | fn test(data: String) {}
|
||||
| | ^^^^ expected `u64`, found `String`
|
||||
... |
|
||||
47 | | }
|
||||
| |_- arguments to this function are incorrect
|
||||
|
|
||||
note: associated function defined here
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:27:6
|
||||
|
|
||||
27 | fn test(data: u64);
|
||||
| ^^^^ ----
|
||||
|
||||
error: unused variable: `data`
|
||||
--> tests/ui/impl_incorrect_method_signature.rs:33:11
|
||||
|
|
||||
33 | fn test(data: String) {}
|
||||
| ^^^^ help: if this is intentional, prefix it with an underscore: `_data`
|
||||
|
|
||||
= note: `-D unused-variables` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(unused_variables)]`
|
||||
@@ -0,0 +1,54 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
fn test1();
|
||||
fn test2();
|
||||
#[api_version(3)]
|
||||
fn test3();
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
#[api_version(4)]
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test1() {}
|
||||
fn test2() {}
|
||||
fn test3() {}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
error[E0405]: cannot find trait `ApiV4` in module `self::runtime_decl_for_api`
|
||||
--> tests/ui/impl_missing_version.rs:35:13
|
||||
|
|
||||
25 | pub trait Api {
|
||||
| ------------- similarly named trait `ApiV2` defined here
|
||||
...
|
||||
35 | impl self::Api<Block> for Runtime {
|
||||
| ^^^ help: a trait with a similar name exists: `ApiV2`
|
||||
@@ -0,0 +1,47 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
mod second {
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test2(data: u64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test(data: u64) {}
|
||||
}
|
||||
|
||||
impl second::Api<Block> for Runtime {
|
||||
fn test2(data: u64) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: Two traits with the same name detected! The trait name is used to generate its ID. Please rename one trait at the declaration!
|
||||
--> tests/ui/impl_two_traits_with_same_name.rs:42:15
|
||||
|
|
||||
42 | impl second::Api<Block> for Runtime {
|
||||
| ^^^
|
||||
|
||||
error: First trait implementation.
|
||||
--> tests/ui/impl_two_traits_with_same_name.rs:38:13
|
||||
|
|
||||
38 | impl self::Api<Block> for Runtime {
|
||||
| ^^^
|
||||
@@ -0,0 +1,25 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version]
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||
--> tests/ui/invalid_api_version_1.rs:19:2
|
||||
|
|
||||
19 | #[api_version]
|
||||
| ^
|
||||
@@ -0,0 +1,25 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version("1")]
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||
--> tests/ui/invalid_api_version_2.rs:19:2
|
||||
|
|
||||
19 | #[api_version("1")]
|
||||
| ^
|
||||
@@ -0,0 +1,25 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version()]
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||
--> tests/ui/invalid_api_version_3.rs:19:2
|
||||
|
|
||||
19 | #[api_version()]
|
||||
| ^
|
||||
@@ -0,0 +1,25 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
#[api_version("1")]
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||
--> tests/ui/invalid_api_version_4.rs:20:3
|
||||
|
|
||||
20 | #[api_version("1")]
|
||||
| ^
|
||||
@@ -0,0 +1,26 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
#[api_version(1)]
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: Method version `1` is older than (or equal to) trait version `2`.Methods can't define versions older than the trait version.
|
||||
--> tests/ui/method_ver_lower_than_trait_ver.rs:21:3
|
||||
|
|
||||
21 | #[api_version(1)]
|
||||
| ^
|
||||
|
||||
error: Trait version is set here.
|
||||
--> tests/ui/method_ver_lower_than_trait_ver.rs:19:2
|
||||
|
|
||||
19 | #[api_version(2)]
|
||||
| ^
|
||||
@@ -0,0 +1,36 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl self::Api for Runtime {
|
||||
fn test(data: u64) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Missing `Block` generic parameter.
|
||||
--> tests/ui/missing_block_generic_parameter.rs:29:13
|
||||
|
|
||||
29 | impl self::Api for Runtime {
|
||||
| ^^^
|
||||
@@ -0,0 +1,36 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl Api<Block> for Runtime {
|
||||
fn test(data: u64) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: The implemented trait has to be referenced with a path, e.g. `impl client::Core for Runtime`.
|
||||
--> tests/ui/missing_path_for_trait.rs:29:7
|
||||
|
|
||||
29 | impl Api<Block> for Runtime {
|
||||
| ^^^
|
||||
@@ -0,0 +1,53 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
fn test1();
|
||||
fn test2();
|
||||
#[api_version(3)]
|
||||
fn test3();
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
#[api_version(3)]
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test1() {}
|
||||
fn test2() {}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
error[E0046]: not all trait items implemented, missing: `test3`
|
||||
--> tests/ui/missing_versioned_method.rs:35:2
|
||||
|
|
||||
29 | fn test3();
|
||||
| ----------- `test3` from trait
|
||||
...
|
||||
35 | impl self::Api<Block> for Runtime {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `test3` in implementation
|
||||
@@ -0,0 +1,56 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
fn test1();
|
||||
fn test2();
|
||||
#[api_version(3)]
|
||||
fn test3();
|
||||
#[api_version(4)]
|
||||
fn test4();
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
#[api_version(4)]
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test1() {}
|
||||
fn test2() {}
|
||||
fn test4() {}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
error[E0046]: not all trait items implemented, missing: `test3`
|
||||
--> tests/ui/missing_versioned_method_multiple_vers.rs:37:2
|
||||
|
|
||||
29 | fn test3();
|
||||
| ----------- `test3` from trait
|
||||
...
|
||||
37 | impl self::Api<Block> for Runtime {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `test3` in implementation
|
||||
@@ -0,0 +1,38 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
use sp_api::ApiError;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test();
|
||||
}
|
||||
}
|
||||
|
||||
struct MockApi;
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
#[advanced]
|
||||
fn test(&self, _: &Hash) -> Result<(), ApiError> {
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,12 @@
|
||||
error: `Hash` needs to be taken by value and not by reference!
|
||||
--> tests/ui/mock_advanced_hash_by_reference.rs:29:1
|
||||
|
|
||||
29 | / sp_api::mock_impl_runtime_apis! {
|
||||
30 | | impl Api<Block> for MockApi {
|
||||
31 | | #[advanced]
|
||||
32 | | fn test(&self, _: &Hash) -> Result<(), ApiError> {
|
||||
... |
|
||||
36 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: this error originates in the macro `sp_api::mock_impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,38 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
use sp_api::ApiError;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test();
|
||||
}
|
||||
}
|
||||
|
||||
struct MockApi;
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
#[advanced]
|
||||
fn test(&self) -> Result<(), ApiError> {
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: If using the `advanced` attribute, it is required that the function takes at least one argument, the `Hash`.
|
||||
--> tests/ui/mock_advanced_missing_hash.rs:32:3
|
||||
|
|
||||
32 | fn test(&self) -> Result<(), ApiError> {
|
||||
| ^^
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
struct Block2;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
|
||||
pub trait Api2 {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
struct MockApi;
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
fn test(data: u64) {}
|
||||
}
|
||||
|
||||
impl Api2<Block2> for MockApi {
|
||||
fn test(data: u64) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: Block type should be the same between all runtime apis.
|
||||
--> tests/ui/mock_only_one_block_type.rs:37:12
|
||||
|
|
||||
37 | impl Api2<Block2> for MockApi {
|
||||
| ^^^^^^
|
||||
|
||||
error: First block type found here
|
||||
--> tests/ui/mock_only_one_block_type.rs:33:11
|
||||
|
|
||||
33 | impl Api<Block> for MockApi {
|
||||
| ^^^^^
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
|
||||
pub trait Api2 {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
struct MockApi;
|
||||
struct MockApi2;
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
fn test(data: u64) {}
|
||||
}
|
||||
|
||||
impl Api2<Block> for MockApi2 {
|
||||
fn test(data: u64) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: Self type should not change between runtime apis
|
||||
--> tests/ui/mock_only_one_self_type.rs:36:23
|
||||
|
|
||||
36 | impl Api2<Block> for MockApi2 {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: First self type found here
|
||||
--> tests/ui/mock_only_one_self_type.rs:32:22
|
||||
|
|
||||
32 | impl Api<Block> for MockApi {
|
||||
| ^^^^^^^
|
||||
@@ -0,0 +1,37 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
fn test2(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
struct MockApi;
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
fn test(self, data: u64) {}
|
||||
|
||||
fn test2(&mut self, data: u64) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,46 @@
|
||||
error: Only `&self` is supported!
|
||||
--> tests/ui/mock_only_self_reference.rs:31:11
|
||||
|
|
||||
31 | fn test(self, data: u64) {}
|
||||
| ^^^^
|
||||
|
||||
error: Only `&self` is supported!
|
||||
--> tests/ui/mock_only_self_reference.rs:33:12
|
||||
|
|
||||
33 | fn test2(&mut self, data: u64) {}
|
||||
| ^
|
||||
|
||||
error[E0050]: method `test` has 2 parameters but the declaration in trait `Api::test` has 3
|
||||
--> tests/ui/mock_only_self_reference.rs:29:1
|
||||
|
|
||||
20 | / sp_api::decl_runtime_apis! {
|
||||
21 | | pub trait Api {
|
||||
22 | | fn test(data: u64);
|
||||
| |_________________________- trait requires 3 parameters
|
||||
...
|
||||
29 | / sp_api::mock_impl_runtime_apis! {
|
||||
30 | | impl Api<Block> for MockApi {
|
||||
31 | | fn test(self, data: u64) {}
|
||||
... |
|
||||
35 | | }
|
||||
| |_^ expected 3 parameters, found 2
|
||||
|
|
||||
= note: this error originates in the macro `sp_api::mock_impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0050]: method `test2` has 2 parameters but the declaration in trait `Api::test2` has 3
|
||||
--> tests/ui/mock_only_self_reference.rs:29:1
|
||||
|
|
||||
20 | / sp_api::decl_runtime_apis! {
|
||||
21 | | pub trait Api {
|
||||
22 | | fn test(data: u64);
|
||||
23 | | fn test2(data: u64);
|
||||
| |__________________________- trait requires 3 parameters
|
||||
...
|
||||
29 | / sp_api::mock_impl_runtime_apis! {
|
||||
30 | | impl Api<Block> for MockApi {
|
||||
31 | | fn test(self, data: u64) {}
|
||||
... |
|
||||
35 | | }
|
||||
| |_^ expected 3 parameters, found 2
|
||||
|
|
||||
= note: this error originates in the macro `sp_api::mock_impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,26 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test() {
|
||||
println!("Hey, I'm a default implementation!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
error: A runtime API function cannot have a default implementation!
|
||||
--> tests/ui/no_default_implementation.rs:20:13
|
||||
|
|
||||
20 | fn test() {
|
||||
| ___________________^
|
||||
21 | | println!("Hey, I'm a default implementation!");
|
||||
22 | | }
|
||||
| |_________^
|
||||
@@ -0,0 +1,60 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
struct Runtime {}
|
||||
|
||||
pub trait CustomTrait: Encode + Decode + TypeInfo {}
|
||||
|
||||
#[derive(Encode, Decode, TypeInfo)]
|
||||
pub struct SomeImpl;
|
||||
impl CustomTrait for SomeImpl {}
|
||||
|
||||
#[derive(Encode, Decode, TypeInfo)]
|
||||
pub struct SomeOtherType<C: CustomTrait>(C);
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api<A> where A: CustomTrait {
|
||||
fn test() -> A;
|
||||
fn test2() -> SomeOtherType<A>;
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl self::Api<Block, SomeImpl> for Runtime {
|
||||
fn test() -> SomeImpl { SomeImpl }
|
||||
fn test2() -> SomeOtherType<SomeImpl> { SomeOtherType(SomeImpl) }
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,55 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
pub trait Api {
|
||||
fn test1();
|
||||
fn test2();
|
||||
#[api_version(3)]
|
||||
fn test3();
|
||||
#[api_version(4)]
|
||||
fn test4();
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
#[api_version(2)]
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test1() {}
|
||||
fn test2() {}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,51 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type is done by the `construct_runtime!` macro in a real
|
||||
/// runtime.
|
||||
struct Runtime {}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Api {
|
||||
fn test(data: u64);
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl self::Api<Block> for Runtime {
|
||||
fn test(data: &u64) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_api::RuntimeVersion {
|
||||
unimplemented!()
|
||||
}
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
error[E0603]: struct `RuntimeVersion` is private
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:39:27
|
||||
|
|
||||
39 | fn version() -> sp_api::RuntimeVersion {
|
||||
| ^^^^^^^^^^^^^^ private struct
|
||||
|
|
||||
note: the struct `RuntimeVersion` is defined here
|
||||
--> $WORKSPACE/substrate/primitives/api/src/lib.rs
|
||||
|
|
||||
| use sp_version::RuntimeVersion;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider importing this struct instead
|
||||
|
|
||||
39 - fn version() -> sp_api::RuntimeVersion {
|
||||
39 + fn version() -> sp_version::RuntimeVersion {
|
||||
|
|
||||
help: import `RuntimeVersion` directly
|
||||
|
|
||||
39 - fn version() -> sp_api::RuntimeVersion {
|
||||
39 + fn version() -> sp_version::RuntimeVersion {
|
||||
|
|
||||
|
||||
error[E0053]: method `test` has an incompatible type for trait
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:33:17
|
||||
|
|
||||
33 | fn test(data: &u64) {
|
||||
| ^^^^ expected `u64`, found `&u64`
|
||||
|
|
||||
note: type in trait
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:27:17
|
||||
|
|
||||
27 | fn test(data: u64);
|
||||
| ^^^
|
||||
= note: expected signature `fn(_)`
|
||||
found signature `fn(&_)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
33 - fn test(data: &u64) {
|
||||
33 + fn test(data: u64) {
|
||||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:33:11
|
||||
|
|
||||
31 | / sp_api::impl_runtime_apis! {
|
||||
32 | | impl self::Api<Block> for Runtime {
|
||||
33 | | fn test(data: &u64) {
|
||||
| | ^^^^^^^ expected `u64`, found `&u64`
|
||||
34 | | unimplemented!()
|
||||
... |
|
||||
49 | | }
|
||||
| |_- arguments to this function are incorrect
|
||||
|
|
||||
note: associated function defined here
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:27:6
|
||||
|
|
||||
27 | fn test(data: u64);
|
||||
| ^^^^ ----
|
||||
|
||||
error: unused variable: `data`
|
||||
--> tests/ui/type_reference_in_impl_runtime_apis_call.rs:33:11
|
||||
|
|
||||
33 | fn test(data: &u64) {
|
||||
| ^^^^ help: if this is intentional, prefix it with an underscore: `_data`
|
||||
|
|
||||
= note: `-D unused-variables` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(unused_variables)]`
|
||||
Reference in New Issue
Block a user