-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
- Loading branch information
Showing
7 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
client/tests/integration/smartcontracts/executor_remove_token/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "executor_remove_token" | ||
|
||
edition.workspace = true | ||
version.workspace = true | ||
authors.workspace = true | ||
|
||
license.workspace = true | ||
|
||
[lib] | ||
crate-type = ['cdylib'] | ||
|
||
[dependencies] | ||
iroha_executor.workspace = true | ||
iroha_schema.workspace = true | ||
|
||
parity-scale-codec.workspace = true | ||
anyhow.workspace = true | ||
serde_json.workspace = true | ||
serde.workspace = true | ||
|
||
panic-halt.workspace = true | ||
lol_alloc.workspace = true | ||
getrandom.workspace = true |
37 changes: 37 additions & 0 deletions
37
client/tests/integration/smartcontracts/executor_remove_token/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Runtime Executor which removes [`token::CanControlDomainLives`] permission token. | ||
//! Needed for tests. | ||
|
||
#![no_std] | ||
|
||
extern crate alloc; | ||
#[cfg(not(test))] | ||
extern crate panic_halt; | ||
|
||
use iroha_executor::{default::default_permission_token_schema, prelude::*}; | ||
use lol_alloc::{FreeListAllocator, LockedAllocator}; | ||
|
||
#[global_allocator] | ||
static ALLOC: LockedAllocator<FreeListAllocator> = LockedAllocator::new(FreeListAllocator::new()); | ||
|
||
getrandom::register_custom_getrandom!(iroha_executor::stub_getrandom); | ||
|
||
#[derive(Constructor, ValidateEntrypoints, Validate, Visit)] | ||
struct Executor { | ||
verdict: Result, | ||
block_height: u64, | ||
} | ||
|
||
#[entrypoint] | ||
pub fn migrate(_block_height: u64) -> MigrationResult { | ||
// Note that actually migration will reset token schema to default (minus `CanUnregisterDomain`) | ||
// So any added custom permission tokens will be also removed | ||
let mut schema = default_permission_token_schema(); | ||
schema.remove::<iroha_executor::default::tokens::domain::CanUnregisterDomain>(); | ||
|
||
let (token_ids, schema_str) = schema.serialize(); | ||
iroha_executor::set_permission_token_schema( | ||
&iroha_executor::data_model::permission::PermissionTokenSchema::new(token_ids, schema_str), | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters