From bdb023f20a22453494e02271a727e3cee06d1754 Mon Sep 17 00:00:00 2001 From: sczembor Date: Wed, 23 Aug 2023 17:18:38 +0200 Subject: [PATCH] update the comments --- contracts/registry/src/migrate.rs | 2 +- contracts/registry/tests/workspaces.rs | 38 ++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/contracts/registry/src/migrate.rs b/contracts/registry/src/migrate.rs index bbd388c..5395592 100644 --- a/contracts/registry/src/migrate.rs +++ b/contracts/registry/src/migrate.rs @@ -26,7 +26,7 @@ impl Contract { let old_state: OldState = env::state_read().expect("failed"); // new field in the smart contract : // + flagged: LookupMap - // + admins_flagged: LazyOption> + // + authorized_flaggers: LazyOption> Self { authority: old_state.authority.clone(), diff --git a/contracts/registry/tests/workspaces.rs b/contracts/registry/tests/workspaces.rs index 5e6a48f..d0ccdae 100644 --- a/contracts/registry/tests/workspaces.rs +++ b/contracts/registry/tests/workspaces.rs @@ -1,7 +1,8 @@ use anyhow::Ok; use near_sdk::serde_json::json; use near_units::parse_near; -use sbt::{TokenMetadata, ClassSet}; +use registry::storage::AccountFlag; +use sbt::{ClassSet, TokenMetadata}; use workspaces::{network::Sandbox, Account, AccountId, Contract, Worker}; const MAINNET_REGISTRY_ID: &str = "registry.i-am-human.near"; @@ -227,7 +228,7 @@ async fn migration_mainnet() -> anyhow::Result<()> { // call the migrate method let res = new_registry_contract .call("migrate") - .args_json(json!({"authorized_flaggers": ["alice.near"]})) + .args_json(json!({"authorized_flaggers": [alice.id()]})) .max_gas() .transact() .await?; @@ -243,12 +244,43 @@ async fn migration_mainnet() -> anyhow::Result<()> { ) .await?; + let res = new_registry_contract + .call("account_flagged") + .args_json(json!({"account": "bob.near"})) + .max_gas() + .transact() + .await?; + assert!(res.is_success()); + let res: Option = res.json()?; + assert!(res.is_none()); + + let res = alice + .call(new_registry_contract.id(), "admin_flag_accounts") + .args_json( + json!({"flag": AccountFlag::Blacklisted,"accounts": vec!["bob.near"], "memo": "test"}), + ) + .max_gas() + .transact() + .await?; + assert!(res.is_success()); + + let res = new_registry_contract + .call("account_flagged") + .args_json(json!({"account": "bob.near"})) + .max_gas() + .transact() + .await?; + assert!(res.is_success()); + let res: Option = res.json()?; + assert_eq!(res.unwrap(), AccountFlag::Blacklisted); + Ok(()) } #[ignore = "this test is not valid after the migration"] // handler error: [State of contract registry.i-am-human.near is too large to be viewed] -// For current block 99,142,922 +// The current running registry contract is too large to be viewed. +// This test cannot be perfomed on real data anymore #[tokio::test] async fn migration_mainnet_real_data() -> anyhow::Result<()> { // import the registry contract from mainnet with data