From 3efa324f5e693143c0970333be70d49242e5db2c Mon Sep 17 00:00:00 2001 From: olegnn Date: Thu, 29 Aug 2024 13:04:05 +0200 Subject: [PATCH 1/5] Introduce `dock-agreement` pallet --- Cargo.lock | 18 +++++++ Cargo.toml | 1 + pallets/agreement/Cargo.toml | 92 +++++++++++++++++++++++++++++++ pallets/agreement/src/lib.rs | 55 +++++++++++++++++++ pallets/agreement/src/mock.rs | 98 ++++++++++++++++++++++++++++++++++ pallets/agreement/src/tests.rs | 57 ++++++++++++++++++++ runtime/Cargo.toml | 77 ++++++++++++++++---------- runtime/src/lib.rs | 9 +++- 8 files changed, 376 insertions(+), 31 deletions(-) create mode 100644 pallets/agreement/Cargo.toml create mode 100644 pallets/agreement/src/lib.rs create mode 100644 pallets/agreement/src/mock.rs create mode 100644 pallets/agreement/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index fd1e00271..57becc173 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1482,6 +1482,23 @@ dependencies = [ "quick-error", ] +[[package]] +name = "dock-agreement" +version = "0.5.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "dock-core" version = "0.5.0" @@ -1770,6 +1787,7 @@ version = "0.29.0" dependencies = [ "beefy-merkle-tree", "beefy-primitives", + "dock-agreement", "dock-core", "dock-poa", "dock-price-feed", diff --git a/Cargo.toml b/Cargo.toml index 24dd932fe..09473bb43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "node", + "pallets/agreement", "pallets/poa", "pallets/poa/rpc", "pallets/token-migration", diff --git a/pallets/agreement/Cargo.toml b/pallets/agreement/Cargo.toml new file mode 100644 index 000000000..9306ce73f --- /dev/null +++ b/pallets/agreement/Cargo.toml @@ -0,0 +1,92 @@ +[package] +name = "dock-agreement" +version = "0.5.0" +authors = ["Dock.io"] +edition = "2021" +license = "Apache-2.0" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies.scale-info] +version = "2.1.2" +default-features = false +features = ["derive"] + +[dependencies.codec] +default-features = false +features = ["derive"] +package = "parity-scale-codec" +version = "3.1.5" + +[dependencies.serde] +features = ["derive"] +optional = true +version = "1.0.119" + +[dependencies.frame-support] +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dependencies.frame-system] +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dependencies.sp-std] +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dependencies.frame-benchmarking] +optional = true +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dependencies.frame-system-benchmarking] +optional = true +default-features = false +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dev-dependencies.sp-io] +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dev-dependencies.sp-core] +default-features = false +# version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[dev-dependencies.sp-runtime] +default-features = false +#version = "3.0.0" +git = "https://github.com/paritytech/substrate.git" +branch = "polkadot-v0.9.29" + +[features] +default = ["std"] +std = [ + "codec/std", + "serde", + "frame-support/std", + "frame-system/std", + "sp-std/std", + "sp-runtime/std", +] +test = ["std"] +runtime-benchmarks = [ + "frame-system-benchmarking", + "frame-benchmarking", + "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", +] diff --git a/pallets/agreement/src/lib.rs b/pallets/agreement/src/lib.rs new file mode 100644 index 000000000..2708dcd8d --- /dev/null +++ b/pallets/agreement/src/lib.rs @@ -0,0 +1,55 @@ +//! Provides the functionality to notify about the agreement concluded by majority of system participants. + +#![cfg_attr(not(feature = "std"), no_std)] + +use scale_info::prelude::string::String; + +#[cfg(test)] +mod mock; +#[cfg(test)] +mod tests; + +// Re-export pallet items so that they can be accessed from the crate namespace. +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// The overarching event type. + type Event: From + IsType<::Event>; + } + + #[pallet::error] + pub enum Error { + /// Attempting to emit an empty agreement. + Empty, + } + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::call] + impl Pallet { + /// Declares an agreement recognized by the majority of system participants. + #[pallet::weight(T::DbWeight::get().writes(1))] + pub fn agree(origin: OriginFor, on: String, _url: Option) -> DispatchResult { + ensure_root(origin)?; + ensure!(!on.is_empty(), Error::::Empty); + + Self::deposit_event(Event::Agreed { on }); + Ok(()) + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Defines an agreement concluded by majority of system participants. + Agreed { on: String }, + } +} diff --git a/pallets/agreement/src/mock.rs b/pallets/agreement/src/mock.rs new file mode 100644 index 000000000..e20f70975 --- /dev/null +++ b/pallets/agreement/src/mock.rs @@ -0,0 +1,98 @@ +use super::*; +use crate as dock_agreement; + +use codec::{Decode, Encode}; +use frame_support::{ + parameter_types, + sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, + }, + weights::{ + constants::{RocksDbWeight, WEIGHT_PER_SECOND}, + Weight, + }, +}; +use sp_core::H256; + +// Configure a mock runtime to test the pallet. +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Agreement: dock_agreement::{Pallet, Call, Event}, + } +); + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: Weight = WEIGHT_PER_SECOND.saturating_mul(2); + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + pub const TransactionByteFee: u64 = 1; + // Not accepting any uncles + pub const UncleGenerations: u32 = 0; + pub const MinimumPeriod: u64 = 1000; +} + +#[derive(Encode, Decode, scale_info::TypeInfo, Clone, PartialEq, Debug, Eq)] +pub enum TestEvent { + Agreement(dock_agreement::Event), +} + +impl From> for TestEvent { + fn from(_: frame_system::Event) -> Self { + unimplemented!() + } +} + +impl From for TestEvent { + fn from(event: dock_agreement::Event) -> Self { + Self::Agreement(event) + } +} + +impl frame_system::Config for Test { + type OnSetCode = (); + type MaxConsumers = sp_runtime::traits::ConstU32<10>; + type BaseCallFilter = frame_support::traits::Everything; + type Origin = Origin; + type Call = Call; + type Index = u64; + type BlockNumber = u64; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type Event = TestEvent; + type BlockHashCount = BlockHashCount; + type DbWeight = RocksDbWeight; + type BlockWeights = (); + type BlockLength = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); +} + +impl Config for Test { + type Event = TestEvent; +} + +// Build genesis storage according to the mock runtime. +pub fn new_test_ext() -> sp_io::TestExternalities { + frame_system::GenesisConfig::default() + .build_storage::() + .unwrap() + .into() +} diff --git a/pallets/agreement/src/tests.rs b/pallets/agreement/src/tests.rs new file mode 100644 index 000000000..d38f9baff --- /dev/null +++ b/pallets/agreement/src/tests.rs @@ -0,0 +1,57 @@ +use super::{Error, Event, Pallet as Remark}; +use crate::mock::*; +use frame_support::{assert_noop, assert_ok}; +use frame_system::RawOrigin; +use sp_runtime::DispatchError; + +#[test] +fn generates_event() { + new_test_ext().execute_with(|| { + let text = "Hello world".to_string(); + System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. + assert_ok!(Remark::::agree( + RawOrigin::Root.into(), + text.clone(), + None + )); + let events = System::events(); + // this one we create as we expect it + let system_event: ::Event = + Event::Agreed { on: text.clone() }.into(); + // this one we actually go into the system pallet and get the last event + // because we know its there from block +1 + let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; + assert_eq!(event, &system_event); + }); +} + +#[test] +fn does_not_agree_on_empty() { + new_test_ext().execute_with(|| { + let text = "".to_string(); + System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. + assert_noop!( + Remark::::agree(RawOrigin::Root.into(), text, None), + Error::::Empty + ); + assert!(System::events().is_empty()); + }); +} + +#[test] +fn cant_be_called_not_by_root() { + new_test_ext().execute_with(|| { + let caller = 1; + let text = "Invalid".to_string(); + System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. + assert_noop!( + Remark::::agree(RawOrigin::Signed(caller).into(), text.clone(), None), + DispatchError::BadOrigin + ); + assert_noop!( + Remark::::agree(RawOrigin::None.into(), text, None), + DispatchError::BadOrigin + ); + assert!(System::events().is_empty()); + }); +} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 3a5224381..9fd4b1e46 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -13,11 +13,22 @@ rustc-hex = { version = "2.1.0", default-features = false } ethabi = { git = "https://github.com/snowfork/ethabi-decode.git", package = "ethabi-decode", branch = "master", default-features = false } parity-bytes = { version = "0.1.2", default-features = false } ethbloom = { version = "0.12.1", default-features = false } -ethereum = { version = "0.12.0", default-features = false, features = ["with-codec"] } -ethereum-types = { version = "0.13.1", default-features = false, features = ["codec", "rlp", "serialize"] } -primitive-types = { version = "0.11.1", default-features = false, features = ["rlp", "byteorder"] } - -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } +ethereum = { version = "0.12.0", default-features = false, features = [ + "with-codec", +] } +ethereum-types = { version = "0.13.1", default-features = false, features = [ + "codec", + "rlp", + "serialize", +] } +primitive-types = { version = "0.11.1", default-features = false, features = [ + "rlp", + "byteorder", +] } + +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = [ + "with-codec", +] } evm-runtime = { version = "0.35", default-features = false, git = "https://github.com/rust-blockchain/evm.git", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" } evm-gasometer = { version = "0.35", default-features = false, git = "https://github.com/rust-blockchain/evm.git", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" } @@ -30,7 +41,9 @@ log = { version = "0.4", default-features = false } static_assertions = "1.1.0" pallet-base-fee = { git = "https://github.com/docknetwork/frontier.git", branch = "master", default_features = false } smallvec = "1.4.1" -scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.2", default-features = false, features = [ + "derive", +] } getrandom = { version = "0.2", features = ["js"] } hex = { version = "0.4", default-features = false } @@ -443,6 +456,10 @@ path = "../pallets/token-migration" default-features = false path = "../pallets/core" +[dependencies.dock-agreement] +default-features = false +path = "../pallets/agreement" + [dependencies.dock-price-feed] default-features = false git = "https://github.com/docknetwork/dock-substrate-common.git" @@ -528,13 +545,13 @@ std = [ "sp-consensus-babe/std", "sp-core/std", "sp-inherents/std", - "evm/std", + "evm/std", "evm/with-serde", "evm-runtime/std", "evm-gasometer/std", "rlp/std", "log/std", - "hex/std", + "hex/std", "sha3/std", "sp-runtime-interface/std", "sp-trie/std", @@ -603,33 +620,35 @@ std = [ "dock-poa/std", "dock-token-migration/std", "dock-core/std", + "dock-agreement/std", "dock-price-feed/std", "pallet-base-fee/std", "dock-staking-rewards/std", "frame-benchmarking/std", - "rustc-hex/std" + "rustc-hex/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "pallet-collective/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-babe/runtime-benchmarks", - "pallet-elections-phragmen/runtime-benchmarks", - "pallet-election-provider-multi-phase/runtime-benchmarks", - "grandpa/runtime-benchmarks", - "pallet-im-online/runtime-benchmarks", - - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "balances/runtime-benchmarks", - "frame-system-benchmarking", - "dock-token-migration/runtime-benchmarks", - "dock-core/runtime-benchmarks", - "pallet-staking/runtime-benchmarks" + "frame-benchmarking", + "pallet-collective/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-babe/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-election-provider-multi-phase/runtime-benchmarks", + "grandpa/runtime-benchmarks", + "pallet-im-online/runtime-benchmarks", + + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "balances/runtime-benchmarks", + "frame-system-benchmarking", + "dock-token-migration/runtime-benchmarks", + "dock-core/runtime-benchmarks", + "dock-agreement/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", ] # For building testnet, affects spec name and ss58 prefix diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 951b73e61..e4888fbd9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -200,7 +200,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("dock-pos-dev-runtime"), impl_name: create_runtime_str!("Dock"), authoring_version: 1, - spec_version: 60, + spec_version: 61, impl_version: 2, transaction_version: 2, apis: RUNTIME_API_VERSIONS, @@ -1744,6 +1744,10 @@ impl dock_price_feed::Config for Runtime { type Event = Event; } +impl dock_agreement::Config for Runtime { + type Event = Event; +} + parameter_types! { pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); } @@ -1798,7 +1802,8 @@ construct_runtime!( Accumulator: accumulator::{Pallet, Call, Storage, Event} = 40, BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config, Event} = 41, StatusListCredential: status_list_credential::{Pallet, Call, Storage, Event} = 42, - TrustRegistry: trust_registry::{Pallet, Call, Storage, Event} = 43 + TrustRegistry: trust_registry::{Pallet, Call, Storage, Event} = 43, + Agreement: dock_agreement::{Pallet, Call, Event} } ); From 31406193c431a629804db0a5975c8031f85b3bc2 Mon Sep 17 00:00:00 2001 From: olegnn Date: Thu, 29 Aug 2024 14:48:57 +0200 Subject: [PATCH 2/5] Add URL --- pallets/agreement/src/lib.rs | 11 +++++++---- pallets/agreement/src/tests.rs | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pallets/agreement/src/lib.rs b/pallets/agreement/src/lib.rs index 2708dcd8d..dfa8ed45b 100644 --- a/pallets/agreement/src/lib.rs +++ b/pallets/agreement/src/lib.rs @@ -37,11 +37,14 @@ pub mod pallet { impl Pallet { /// Declares an agreement recognized by the majority of system participants. #[pallet::weight(T::DbWeight::get().writes(1))] - pub fn agree(origin: OriginFor, on: String, _url: Option) -> DispatchResult { + pub fn agree(origin: OriginFor, on: String, url: Option) -> DispatchResult { ensure_root(origin)?; - ensure!(!on.is_empty(), Error::::Empty); + ensure!( + !on.is_empty() && !url.as_ref().map_or(false, String::is_empty), + Error::::Empty + ); - Self::deposit_event(Event::Agreed { on }); + Self::deposit_event(Event::Agreed { on, url }); Ok(()) } } @@ -50,6 +53,6 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Defines an agreement concluded by majority of system participants. - Agreed { on: String }, + Agreed { on: String, url: Option }, } } diff --git a/pallets/agreement/src/tests.rs b/pallets/agreement/src/tests.rs index d38f9baff..8707c21e2 100644 --- a/pallets/agreement/src/tests.rs +++ b/pallets/agreement/src/tests.rs @@ -8,16 +8,22 @@ use sp_runtime::DispatchError; fn generates_event() { new_test_ext().execute_with(|| { let text = "Hello world".to_string(); + let url = Some("Test url".to_string()); + System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. assert_ok!(Remark::::agree( RawOrigin::Root.into(), text.clone(), - None + url.clone() )); + let events = System::events(); // this one we create as we expect it - let system_event: ::Event = - Event::Agreed { on: text.clone() }.into(); + let system_event: ::Event = Event::Agreed { + on: text.clone(), + url, + } + .into(); // this one we actually go into the system pallet and get the last event // because we know its there from block +1 let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; @@ -31,7 +37,11 @@ fn does_not_agree_on_empty() { let text = "".to_string(); System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. assert_noop!( - Remark::::agree(RawOrigin::Root.into(), text, None), + Remark::::agree(RawOrigin::Root.into(), text.clone(), None), + Error::::Empty + ); + assert_noop!( + Remark::::agree(RawOrigin::Root.into(), text, Some("".to_string())), Error::::Empty ); assert!(System::events().is_empty()); From abbb4878e81265d3e6d2ca78a8c1121458708282 Mon Sep 17 00:00:00 2001 From: olegnn Date: Thu, 29 Aug 2024 14:56:42 +0200 Subject: [PATCH 3/5] Bump up versions --- Cargo.lock | 4 ++-- node/Cargo.toml | 4 ++-- runtime/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57becc173..e861d252d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1557,7 +1557,7 @@ dependencies = [ [[package]] name = "dock-node" -version = "0.29.0" +version = "0.30.0" dependencies = [ "async-trait", "beefy-gadget", @@ -1783,7 +1783,7 @@ dependencies = [ [[package]] name = "dock-runtime" -version = "0.29.0" +version = "0.30.0" dependencies = [ "beefy-merkle-tree", "beefy-primitives", diff --git a/node/Cargo.toml b/node/Cargo.toml index 3a1d01aff..a39c47040 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Dock.io"] build = "build.rs" edition = "2021" name = "dock-node" -version = "0.29.0" +version = "0.30.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -28,7 +28,7 @@ optional = true [dependencies.dock-runtime] path = "../runtime" -version = "0.29.0" +version = "0.30.0" [dependencies.beefy-primitives] git = "https://github.com/paritytech/substrate.git" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 9fd4b1e46..7eb5a2e47 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Dock.io"] edition = "2021" name = "dock-runtime" -version = "0.29.0" +version = "0.30.0" license = "Apache-2.0" [package.metadata.docs.rs] From 8ac119c63035752de18f9e867b4e264268c38617 Mon Sep 17 00:00:00 2001 From: olegnn Date: Thu, 29 Aug 2024 14:58:21 +0200 Subject: [PATCH 4/5] Improve errors --- pallets/agreement/src/lib.rs | 9 ++++++--- pallets/agreement/src/tests.rs | 13 ++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pallets/agreement/src/lib.rs b/pallets/agreement/src/lib.rs index dfa8ed45b..0878353ca 100644 --- a/pallets/agreement/src/lib.rs +++ b/pallets/agreement/src/lib.rs @@ -27,7 +27,9 @@ pub mod pallet { #[pallet::error] pub enum Error { /// Attempting to emit an empty agreement. - Empty, + EmptyAgreement, + /// Attempting to emit an agreement with an empty URL. + EmptyUrl, } #[pallet::pallet] @@ -39,9 +41,10 @@ pub mod pallet { #[pallet::weight(T::DbWeight::get().writes(1))] pub fn agree(origin: OriginFor, on: String, url: Option) -> DispatchResult { ensure_root(origin)?; + ensure!(!on.is_empty(), Error::::EmptyAgreement); ensure!( - !on.is_empty() && !url.as_ref().map_or(false, String::is_empty), - Error::::Empty + !url.as_ref().map_or(false, String::is_empty), + Error::::EmptyUrl ); Self::deposit_event(Event::Agreed { on, url }); diff --git a/pallets/agreement/src/tests.rs b/pallets/agreement/src/tests.rs index 8707c21e2..57a57fb42 100644 --- a/pallets/agreement/src/tests.rs +++ b/pallets/agreement/src/tests.rs @@ -34,15 +34,18 @@ fn generates_event() { #[test] fn does_not_agree_on_empty() { new_test_ext().execute_with(|| { - let text = "".to_string(); System::set_block_number(System::block_number() + 1); //otherwise event won't be registered. assert_noop!( - Remark::::agree(RawOrigin::Root.into(), text.clone(), None), - Error::::Empty + Remark::::agree(RawOrigin::Root.into(), "".to_string(), None), + Error::::EmptyAgreement ); assert_noop!( - Remark::::agree(RawOrigin::Root.into(), text, Some("".to_string())), - Error::::Empty + Remark::::agree( + RawOrigin::Root.into(), + "abc".to_string(), + Some("".to_string()) + ), + Error::::EmptyUrl ); assert!(System::events().is_empty()); }); From 538718762cc0312a3aaf8d672be0e66102794522 Mon Sep 17 00:00:00 2001 From: olegnn Date: Thu, 29 Aug 2024 19:53:13 +0200 Subject: [PATCH 5/5] Add index --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index e4888fbd9..a2901d2eb 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1803,7 +1803,7 @@ construct_runtime!( BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config, Event} = 41, StatusListCredential: status_list_credential::{Pallet, Call, Storage, Event} = 42, TrustRegistry: trust_registry::{Pallet, Call, Storage, Event} = 43, - Agreement: dock_agreement::{Pallet, Call, Event} + Agreement: dock_agreement::{Pallet, Call, Event} = 44 } );